-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Issue when passing results in nested loops #5143
Comments
Will take a look |
Example on how to flatten: apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: nested-loops-issue-
spec:
entrypoint: start
templates:
- name: start
steps:
- - name: return-first-array
template: return-first-array
- - arguments:
parameters:
- name: param
value: '{{item}}'
name: return-second-array
template: return-second-array
withParam: '{{steps.return-first-array.outputs.result}}'
- - arguments:
parameters:
- name: param
value: '{{steps.return-second-array.outputs.result}}'
name: flatten
template: flatten
- - arguments:
parameters:
- name: message
value: '{{item}}'
name: print
template: whalesay
withParam: '{{steps.flatten.outputs.result}}'
- name: return-first-array
script:
command:
- python
image: python:alpine3.6
source: |
import json
import sys
json.dump(['11111111', '22222222', '33333333'], sys.stdout)
- inputs:
parameters:
- name: param
name: flatten
script:
command:
- python
image: python:alpine3.6
source: |
import json
import sys
out = []
for upper in {{inputs.parameters.param}}:
for lower in upper:
out.append(lower)
json.dump(out, sys.stdout)
- inputs:
parameters:
- name: param
name: return-second-array
script:
command:
- python
image: python:alpine3.6
source: |
import json
import sys
json.dump([{"name":"Foo - {{inputs.parameters.param}}"},{"name":"Doe - {{inputs.parameters.param}}"}], sys.stdout)
- container:
args:
- '{{inputs.parameters.message}}'
command:
- cowsay
image: docker/whalesay:latest
inputs:
parameters:
- name: message
name: whalesay |
@simster7 Thank you for pointing me in the right direction. It would be really cool when we can do it natively in the Argo. After running your example I realized one thing. Flattening would require all previous jobs to finish which wasn't my intention. I'd like to generate multiple branches which could continue independently and aggregate state from previous jobs. |
Summary
First of all, I'd like to thank the Argo community for sharing such a nice tool with everyone. ❤️
I'm trying to run the workflow with nested loops based on the output of the previous steps. An outer loop should add more parameters to the inner loop.
At the first step, everything works as expected but in the next step, Argo doesn't recognize the output parameter as an array with JSON objects. Instead, I'm getting the whole string. I was looking at some other examples and I saw similar usage, but after spending some time trying to debug this I've stuck.
Could someone point me if I'm doing something wrong or is it a legit bug?
Diagnostics
What Kubernetes provider are you using?
Argo Workflows: v2.12.5
Message from the maintainers:
Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.
The text was updated successfully, but these errors were encountered: