Does Argo support dynamic fan-out? #5740
-
Is it possible for Argo to dynamically loop over a set which is generated by the output of a previous step? So for example suppose I would like a workflow which processes a CSV file. For each line in that CSV file I would like to run a sub-workflow. Or suppose I would like to process a video frame by frame, I want to fan-out every frame of the video and process each frame. I can't know how many frames there are, I need to essentially iterate the file to decode it and get the frames. Also there are far more frames then I can reasonably process in parallel so I need some way to limit the parallelism of the processing of the sub-frames. Once completed I would like to fan-in all of the results and re-encode a new video file. I would really appreciate any examples of how to accomplish such a task. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Sure! Here is a simple example # This workflow demonstrates the use of a generator step which produces a list of items as a result.
# This list is subsequently used for expanding the next step into multiple parallel steps.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: loops-param-result-
spec:
entrypoint: loop-param-result-example
templates:
- name: loop-param-result-example
steps:
- - name: generate
template: gen-number-list
- - name: sleep
template: sleep-n-sec
arguments:
parameters:
- name: seconds
value: "{{item}}"
withParam: "{{steps.generate.outputs.result}}"
- name: gen-number-list
script:
image: python:alpine3.6
command: [python]
source: |
import json
import sys
json.dump([i for i in range(20, 31)], sys.stdout)
- name: sleep-n-sec
inputs:
parameters:
- name: seconds
container:
image: alpine:latest
command: [sh, -c]
args: ["echo sleeping for {{inputs.parameters.seconds}} seconds; sleep {{inputs.parameters.seconds}}; echo done"] from https://github.com/argoproj/argo-workflows/blob/master/examples/loops-param-result.yaml. Looping and output-passing between And here is a newer map-reduce example: https://github.com/argoproj/argo-workflows/blob/master/examples/map-reduce.yaml This has a fan-out and fan-in passing data around with an artifact repository. |
Beta Was this translation helpful? Give feedback.
-
It v3 you can use data template too. |
Beta Was this translation helpful? Give feedback.
Sure!
Here is a simple example