argo: implement fanout switch case support - #3331
Open
npow wants to merge 3 commits into
Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Switch `switch-step` output from a scalar step name to a comma-separated
list of chosen targets so a single Argo output parameter can represent
both single-target cases ("step") and list-valued fanout cases
("step1,step2").
Update all three `when`-condition patterns in argo_workflows.py from
the old equality format (`==step`) to a CEL membership test
(`split(',').exists(x, x == 'step')`), which handles both cases uniformly
without changing behavior for existing single-target flows.
Add switch_fanout core integration test (hit and miss cases) and update
the test formatter to emit list-valued case values.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Contributor
Greptile SummaryImplements list-valued switch cases for Argo Workflows by serializing selected targets into one output parameter and using membership-based branch conditions.
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code failure identified. The new serialized switch output is consumed consistently at each routing site, and the reconverging fanout path retains both selected inputs while allowing the unselected path to be skipped without blocking completion.
|
| Filename | Overview |
|---|---|
| metaflow/plugins/argo/argo_workflows.py | Removes fanout rejection and consistently changes all three switch-routing sites from scalar equality to membership checks. |
| metaflow/plugins/argo/argo_workflows_decorator.py | Serializes every selected switch target into the scalar Argo output parameter using a comma-delimited representation. |
| test/core/metaflow_test/formatter.py | Extends generated test flows to emit list-valued switch cases while retaining scalar-case formatting. |
| test/core/graphs/switch_fanout.json | Adds a graph covering a scalar case and a two-target fanout that reconverges at a join. |
| test/core/tests/switch_fanout_case.py | Verifies both the single-target path and the fanout path, including merged artifacts from both selected branches. |
Reviews (1): Last reviewed commit: "argo: implement fanout switch case suppo..." | Re-trigger Greptile
talsperre
force-pushed
the
npow/switch-fanout-cases
branch
from
August 13, 2026 16:41
753cc95 to
c1dde7e
Compare
saikonen
reviewed
Aug 18, 2026
| .template(sanitized_name) | ||
| .when( | ||
| "{{steps.%s-internal.outputs.parameters.switch-step}}==%s" | ||
| "{{=steps['%s-internal'].outputs.parameters['switch-step'].split(',').exists(x, x == '%s')}}" |
Collaborator
There was a problem hiding this comment.
this is leading to
Invalid 'when' expression '({{=(tasks['start'].status == 'Succeeded' ? tasks['start'].outputs.parameters['switch-step'].split(',').exists(x, x == 'branch_a') : false)}})': Invalid token: '{{=' (hint: try wrapping the affected expression in quotes ("))
in many test flows of mine.
| in_func = node.in_funcs[0] | ||
| foreach_task.when( | ||
| "{{tasks.%s.outputs.parameters.switch-step}}==%s" | ||
| "{{=tasks['%s'].outputs.parameters['switch-step'].split(',').exists(x, x == '%s')}}" |
Collaborator
There was a problem hiding this comment.
possibly similar issue with this expression.
talsperre
force-pushed
the
npow/switch-fanout-cases
branch
from
August 21, 2026 21:35
64889dd to
91f39e6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #3328 (Support fanout switch cases).
Implements Argo Workflows support for list-valued switch cases. The approach:
switch-stepArgo parameter from a scalar step name to a comma-separated list of chosen targets ("step1,step2"for fanout,"step"for single-target — no format change for existing flows).when-condition sites inargo_workflows.pyfrom==stepequality to a CEL membership test:split(',').exists(x, x == 'step'). This is backwards-compatible — a single-element list behaves identically to the old scalar comparison.switch_fanoutcore integration graph + hit/miss test cases; updates the testFlowFormatterto emit list-valued switch case values.Test plan
pytest test/unit/test_switch_fanout_cases.py— existing unit tests still passpytest test/unit/test_graph_structure.py— graph structure tests still passswitch_fanoutgraph (hit and miss cases)split(',').exists(...)condition is equivalent to==for single-target cases🤖 Generated with Claude Code