From 49a730707ee6c497b3fa089a74e264330977ae80 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Mon, 7 Oct 2024 14:26:47 +0530 Subject: [PATCH] Add default auction params for deployment auction --- .../webapp/publish_deployment_auction.py | 86 +++++++++---------- stack_orchestrator/deploy/webapp/util.py | 2 +- 2 files changed, 41 insertions(+), 47 deletions(-) diff --git a/stack_orchestrator/deploy/webapp/publish_deployment_auction.py b/stack_orchestrator/deploy/webapp/publish_deployment_auction.py index b6694638..f6f20653 100644 --- a/stack_orchestrator/deploy/webapp/publish_deployment_auction.py +++ b/stack_orchestrator/deploy/webapp/publish_deployment_auction.py @@ -12,9 +12,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import shutil import sys -import tempfile import click import yaml @@ -43,23 +41,23 @@ def fatal(msg: str): ) @click.option( "--commits-duration", - help="Auction commits duration (in seconds).", - required=True, + help="Auction commits duration (in seconds) (default: 600).", + default=600, ) @click.option( "--reveals-duration", - help="Auction reveals duration (in seconds).", - required=True, + help="Auction reveals duration (in seconds) (default: 600).", + default=600, ) @click.option( "--commit-fee", - help="Auction bid commit fee (in alnt).", - required=True, + help="Auction bid commit fee (in alnt) (default: 100000).", + default=100000, ) @click.option( "--reveal-fee", - help="Auction bid reveal fee (in alnt).", - required=True, + help="Auction bid reveal fee (in alnt) (default: 100000).", + default=100000, ) @click.option( "--max-price", @@ -88,44 +86,40 @@ def command( max_price, num_providers, dry_run, -): # noqa: C901 - tempdir = tempfile.mkdtemp() - try: - laconic = LaconicRegistryClient(laconic_config) +): + laconic = LaconicRegistryClient(laconic_config) - app_record = laconic.get_record(app) - if not app_record: - fatal(f"Unable to locate app: {app}") + app_record = laconic.get_record(app) + if not app_record: + fatal(f"Unable to locate app: {app}") - provider_auction_params = { - "kind": AUCTION_KIND_PROVIDER, - "commits_duration": commits_duration, - "reveals_duration": reveals_duration, - "denom": TOKEN_DENOM, - "commit_fee": commit_fee, - "reveal_fee": reveal_fee, - "max_price": max_price, - "num_providers": num_providers, + provider_auction_params = { + "kind": AUCTION_KIND_PROVIDER, + "commits_duration": commits_duration, + "reveals_duration": reveals_duration, + "denom": TOKEN_DENOM, + "commit_fee": commit_fee, + "reveal_fee": reveal_fee, + "max_price": max_price, + "num_providers": num_providers, + } + auction_id = laconic.create_auction(provider_auction_params) + print("Deployment auction created:", auction_id) + + if not auction_id: + fatal("Unable to create a provider auction") + + deployment_auction = { + "record": { + "type": "ApplicationDeploymentAuction", + "application": app, + "auction": auction_id, } - auction_id = laconic.create_auction(provider_auction_params) - print("Deployment auction created:", auction_id) + } - if not auction_id: - fatal("Unable to create a provider auction") + if dry_run: + print(yaml.dump(deployment_auction)) + return - deployment_auction = { - "record": { - "type": "ApplicationDeploymentAuction", - "application": app, - "auction": auction_id, - } - } - - if dry_run: - print(yaml.dump(deployment_auction)) - return - - # Publish the deployment auction record - laconic.publish(deployment_auction) - finally: - shutil.rmtree(tempdir, ignore_errors=True) + # Publish the deployment auction record + laconic.publish(deployment_auction) diff --git a/stack_orchestrator/deploy/webapp/util.py b/stack_orchestrator/deploy/webapp/util.py index 8a4f321a..f4c4343b 100644 --- a/stack_orchestrator/deploy/webapp/util.py +++ b/stack_orchestrator/deploy/webapp/util.py @@ -465,7 +465,7 @@ class LaconicRegistryClient: return AttrDict(json.loads(logged_cmd(self.log_file, *args))) def create_auction(self, auction): - if auction["kind"] == "provider": + if auction["kind"] == AUCTION_KIND_PROVIDER: args = [ "laconic", "-c",