Skip to content

Commit

Permalink
add validation to argo events for incomplete project info in event spec
Browse files Browse the repository at this point in the history
  • Loading branch information
saikonen committed Jan 17, 2025
1 parent 667e77e commit 6c5f6f2
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions metaflow/plugins/argo/argo_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,16 @@ def _process_triggers(self):
for event in trigger_on_finish_deco.triggers:
# Actual filters are deduced here since we don't have access to
# the current object in the @trigger_on_finish decorator.
project_name = event.get("project") or current.get("project_name")
branch_name = event.get("branch") or current.get("branch_name")
# validate that we have complete project info for an event name
if project_name or branch_name:
if not (project_name and branch_name):
# if one of the two is missing, we would end up listening to an event that will never be broadcast.
raise ArgoWorkflowsException(
"Incomplete project info. Please specify both 'project' and 'project_branch' or use the @project decorator"
)

triggers.append(
{
# Make sure this remains consistent with the event name format
Expand All @@ -632,18 +642,16 @@ def _process_triggers(self):
% ".".join(
v
for v in [
event.get("project") or current.get("project_name"),
event.get("branch") or current.get("branch_name"),
project_name,
branch_name,
event["flow"],
]
if v
),
"filters": {
"auto-generated-by-metaflow": True,
"project_name": event.get("project")
or current.get("project_name"),
"branch_name": event.get("branch")
or current.get("branch_name"),
"project_name": project_name,
"branch_name": branch_name,
# TODO: Add a time filters to guard against cached events
},
"type": "run",
Expand Down

0 comments on commit 6c5f6f2

Please sign in to comment.