I have sample Argo DAG as mentioned below. As seen below, I have hardcoded the parameter values for each of the tasks. Each task uses a different parameter value. I know that Argo provides a way to submit a parameter file either in JSON or YAML format to pass the parameter values dynamically. However, I was wondering if there is a way to pass a different value for each of the tasks in the DAG below via the parameter file.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: dag-diamond-custom-
spec:
entrypoint: diamond
templates:
- name: echo
retryStrategy:
limit: 3
inputs:
parameters:
- name: message
- name: task
container:
image: index_ruby:latest
imagePullPolicy: Never
command: [ruby, "index.rb", "-s" , "{{inputs.parameters.task}}" , "-r", "{{inputs.parameters.message}}"]
- name: diamond
dag:
tasks:
- name: A
template: echo
arguments:
parameters:
- name: message
value: |
{"key": "valueA"}
- name: task
value: A
- name: B
dependencies: [A]
template: echo
arguments:
parameters:
- name: message
value: |
{"key": "valueB"}
- name: task
value: B
- name: C
dependencies: [A]
template: echo
arguments:
parameters:
- name: message
value: |
{"key": "valueC"}
- name: task
value: C
- name: D
dependencies: [B, C]
template: echo
arguments:
parameters:
- name: message
value: |
{"key": "valueD"}
- name: task
value: D
The Argo Workflow spec includes
arguments
where a number of global parameters can be defined.You can define one parameter for each task and then access it via templating.
(I modified the
echo
container a bit because I was having trouble with the Ruby image.)As you mentioned, you can create a JSON file of parameters...
...and then pass the parameters from the file via
argo submit
.