Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle keyboard exceptions in expansions deploy #127

Open
cartermak opened this issue Mar 15, 2024 · 1 comment
Open

Handle keyboard exceptions in expansions deploy #127

cartermak opened this issue Mar 15, 2024 · 1 comment

Comments

@cartermak
Copy link
Member

Right now, aerie-cli expansions deploy catches all exceptions when uploading rules and sets. Update this to abort the full bulk deployment for base exceptions (Ctrl + C).

for rule in configuration.rules:
try:
with open(rules_path.joinpath(rule.file_name), "r") as fid:
expansion_logic = fid.read()
rule_id = client.create_expansion_rule(
expansion_logic=expansion_logic,
activity_name=rule.activity_type,
model_id=model_id,
command_dictionary_id=command_dictionary_id,
name=rule.name + name_suffix
)
typer.echo(f"Created expansion rule {rule.name + name_suffix}: {rule_id}")
uploaded_rules[rule.name] = rule_id
except:
typer.echo(f"Failed to create expansion rule {rule.name}")
for set in configuration.sets:
try:
rule_ids = []
for rule_name in set.rules:
if rule_name in uploaded_rules.keys():
rule_ids.append(uploaded_rules[rule_name])
else:
typer.echo(f"No uploaded rule {rule_name} for set {set.name}")
assert len(rule_ids)
set_id = client.create_expansion_set(
command_dictionary_id=command_dictionary_id,
model_id=model_id,
expansion_ids=rule_ids,
name=set.name + name_suffix
)
typer.echo(f"Created expansion set {set.name + name_suffix}: {set_id}")
except:
typer.echo(f"Failed to create expansion set {set.name}")

@cartermak
Copy link
Member Author

Actually, just drop all the heavy-handed exception catching. It also catches things like FileNotFoundError.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant