From 6ae7f3d176a6b3ebc901c057c2879783264dc403 Mon Sep 17 00:00:00 2001 From: David Souther Date: Tue, 8 Oct 2024 16:09:17 -0400 Subject: [PATCH 1/3] Weathertop: Fix flake8 issue in deploy.py --- .tools/test/stacks/deploy.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.tools/test/stacks/deploy.py b/.tools/test/stacks/deploy.py index 1f4bdc639aa..51b91e2bbd1 100644 --- a/.tools/test/stacks/deploy.py +++ b/.tools/test/stacks/deploy.py @@ -6,7 +6,6 @@ import os import yaml import time -import logging import re @@ -31,9 +30,12 @@ def run_shell_command(command, env_vars=None): try: output = subprocess.check_output(command, stderr=subprocess.STDOUT, env=env) print(f"Command output: {output.decode()}") - except Exception as e: + except subprocess.CalledProcessError as e: print(f"Error executing command: {e.output.decode()}") raise + except Exception as e: + print(f"Exception executing command: {e!r}") + raise def validate_alphanumeric(value, name): @@ -100,6 +102,8 @@ def main(): parser.add_argument("type", choices=["admin", "images", "plugin"]) args = parser.parse_args() + accounts = None + if args.type in {"admin", "images"}: try: with open("config/resources.yaml", "r") as file: @@ -119,6 +123,9 @@ def main(): except Exception as e: print(f"Failed to read config data: \n{e}") + if accounts is None: + raise ValueError(f"Could not load accounts for stack {args.type}") + for account_name, account_info in accounts.items(): print( f"Reading from account {account_name} with ID {account_info['account_id']}" From 5b4777ac85f5b826dfa5a8d8c3ffec4f84e05551 Mon Sep 17 00:00:00 2001 From: David Souther Date: Tue, 8 Oct 2024 15:57:55 -0400 Subject: [PATCH 2/3] Add --language flag to deploy.py runner. --- .tools/test/DEPLOYMENT.md | 5 +++-- .tools/test/stacks/deploy.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.tools/test/DEPLOYMENT.md b/.tools/test/DEPLOYMENT.md index 464fa7a8e14..bdc7c9f13c6 100644 --- a/.tools/test/DEPLOYMENT.md +++ b/.tools/test/DEPLOYMENT.md @@ -25,14 +25,15 @@ python -m venv .venv && source .venv/bin/activate && pip install -r requirements #### Command Syntax ```bash -python stacks/deploy.py --type +cd stacks ; python deploy.py ``` -Replace `` with one of the supported types: +Replace `` with one of the supported stacks: - `admin`: Deploys admin-specific resources. - `images`: Deploys image-related resources. - `plugin`: Deploys plugin-specific resources. + - To deploy only a specific language's plugin, pass `--language ` where language is an account in ./stacks/config/targets.yaml. #### Additional Notes diff --git a/.tools/test/stacks/deploy.py b/.tools/test/stacks/deploy.py index 51b91e2bbd1..cba855ce41e 100644 --- a/.tools/test/stacks/deploy.py +++ b/.tools/test/stacks/deploy.py @@ -98,8 +98,9 @@ def deploy_resources(account_id, account_name, dir, lang="typescript"): def main(): - parser = argparse.ArgumentParser(description="admin, images, or plugin flag.") + parser = argparse.ArgumentParser(description="admin, images, or plugin stack.") parser.add_argument("type", choices=["admin", "images", "plugin"]) + parser.add_argument("--language") args = parser.parse_args() accounts = None @@ -122,11 +123,16 @@ def main(): accounts = yaml.safe_load(file) except Exception as e: print(f"Failed to read config data: \n{e}") - + if accounts is None: raise ValueError(f"Could not load accounts for stack {args.type}") - for account_name, account_info in accounts.items(): + if args.language: + items = [(args.language, accounts[args.language])] + else: + items = accounts.items() + + for account_name, account_info in items: print( f"Reading from account {account_name} with ID {account_info['account_id']}" ) From 64a7de04090a8e018c216bb95667b5949d45e524 Mon Sep 17 00:00:00 2001 From: David Souther Date: Wed, 9 Oct 2024 12:24:46 -0700 Subject: [PATCH 3/3] Update .tools/test/DEPLOYMENT.md Co-authored-by: ford prior --- .tools/test/DEPLOYMENT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tools/test/DEPLOYMENT.md b/.tools/test/DEPLOYMENT.md index bdc7c9f13c6..e4557a49928 100644 --- a/.tools/test/DEPLOYMENT.md +++ b/.tools/test/DEPLOYMENT.md @@ -33,7 +33,7 @@ Replace `` with one of the supported stacks: - `admin`: Deploys admin-specific resources. - `images`: Deploys image-related resources. - `plugin`: Deploys plugin-specific resources. - - To deploy only a specific language's plugin, pass `--language ` where language is an account in ./stacks/config/targets.yaml. + - To deploy only a specific language's plugin, pass `--language ` where language is an account in [targets.yaml](stacks/config/targets.yaml). #### Additional Notes