Skip to content

Commit 9207a96

Browse files
committed
small code cleanup
1 parent ee87619 commit 9207a96

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

metaflow/plugins/aip/aip.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -382,15 +382,17 @@ def _create_workflow_yaml(
382382
"template": "user-defined-exit-handler",
383383
}
384384

385-
if udf_handler.attributes.get(
386-
"on_success", True
387-
) and udf_handler.attributes.get("on_failure", True):
388-
# always run
385+
on_success = udf_handler.attributes.get("on_success", True)
386+
on_failure = udf_handler.attributes.get("on_failure", True)
387+
if on_success and on_failure:
388+
# always run, no condition
389389
pass
390-
elif udf_handler.attributes.get("on_success", True):
390+
elif on_success:
391391
udf_task["when"] = "{{workflow.status}} == 'Succeeded'"
392-
else:
392+
elif on_failure:
393393
udf_task["when"] = "{{workflow.status}} != 'Succeeded'"
394+
else:
395+
raise AIPException("on_success and on_failure cannot both be False")
394396

395397
exit_handler_template["dag"]["tasks"].append(udf_task)
396398

metaflow/plugins/aip/exit_handler_decorator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class ExitHandlerDecorator(FlowDecorator):
9696
>>> @exit_handler_resources(memory="2G")
9797
>>> def my_exit_handler(
9898
>>> status: str,
99-
>>> flow_parameters: Dict[str, str],
99+
>>> flow_parameters: dict,
100100
>>> argo_workflow_run_name: str,
101101
>>> metaflow_run_id: str,
102102
>>> argo_ui_url: str,

0 commit comments

Comments
 (0)