Skip to content

Commit 2e19510

Browse files
authored
Add --run-id-file option to step-functions trigger (#590)
1 parent 8e68732 commit 2e19510

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

metaflow/plugins/aws/step_functions/step_functions_cli.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,13 @@ def resolve_token(name,
347347

348348
@parameters.add_custom_parameters(deploy_mode=False)
349349
@step_functions.command(help="Trigger the workflow on AWS Step Functions.")
350+
@click.option('--run-id-file',
351+
default=None,
352+
show_default=True,
353+
type=str,
354+
help="Write the ID of this run to the file specified.")
350355
@click.pass_obj
351-
def trigger(obj, **kwargs):
356+
def trigger(obj, run_id_file=None, **kwargs):
352357
def _convert_value(param):
353358
# Swap `-` with `_` in parameter name to match click's behavior
354359
val = kwargs.get(param.name.replace('-', '_').lower())
@@ -362,9 +367,15 @@ def _convert_value(param):
362367
response = StepFunctions.trigger(obj.state_machine_name, params)
363368

364369
id = response['executionArn'].split(':')[-1]
370+
run_id = 'sfn-' + id
371+
372+
if run_id_file:
373+
with open(run_id_file, 'w') as f:
374+
f.write(str(run_id))
375+
365376
obj.echo("Workflow *{name}* triggered on AWS Step Functions "
366-
"(run-id *sfn-{id}*)."
367-
.format(name=obj.state_machine_name, id=id), bold=True)
377+
"(run-id *{run_id}*)."
378+
.format(name=obj.state_machine_name, run_id=run_id), bold=True)
368379

369380

370381
@step_functions.command(

0 commit comments

Comments
 (0)