Difficulty: Beginner
Estimated Time: 15 to 20 minutes

In this scenario you will:

  1. Learn about parameters.
  2. Create a workflow that uses parameters
  3. Learn about artifacts and storage.
  4. Create a workflow that generates and consumes artifacts.

Let's recap:

  • There are two types of input and output: parameters and artifacts.
  • parameters are just short strings.
  • artifacts are simply files or directories that are compressed and uploaded to an artifact repository such as S3.
  • For one task to use the the output of another task, you can use DAG or steps templates.

Please let us know what can be improved.

Inputs and Outputs

Step 1 of 2

Parameters

One type of input or output is a parameter. Unlike artifacts, these are plain string values, and are useful for most simple cases.

Input Parameters

Lets have a look at an example:

    - name: main
      inputs:
        parameters:
          - name: message
      container:
        image: docker/whalesay
        command: [ cowsay ]
        args: [ "{{inputs.parameters.message}}" ]

This template declare that it has one input parameter named "message".

See the complete workflow:

cat input-parameters-workflow.yaml

See how the workflow itself has arguments.

Run it:

argo submit --watch input-parameters-workflow.yaml

You should see:

STEP                       TEMPLATE  PODNAME                 DURATION  MESSAGE
 ✔ input-parameters-mvtcw  main      input-parameters-mvtcw  8s

If a workflow has parameters, you can change the parameters using -p:

argo submit --watch input-parameters-workflow.yaml -p message='Hi Katacoda!'

You should see:

STEP                       TEMPLATE  PODNAME                 DURATION  MESSAGE
 ✔ input-parameters-lwkdx  main      input-parameters-lwkdx  5s

Lets check the output in the logs:

argo logs @latest

You should see:

 ______________ 
< Hi Katacoda! >
 -------------- 
    \
     \
      \     
                    ##        .            
              ## ## ##       ==            
           ## ## ## ##      ===            
       /""""""""""""""""___/ ===        
  ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~   
       \______ o          __/            
        \    \        __/             
          \____\______/

Output Parameters

Output parameters can be from a few places, but typically the most versatile is from a file. It this example, the container creates a file with a message in it:

  - name: whalesay
    container:
      image: docker/whalesay
      command: [sh, -c]
      args: ["echo -n hello world > /tmp/hello_world.txt"] 
    outputs:
      parameters:
      - name: hello-param        
        valueFrom:
          path: /tmp/hello_world.txt

In DAGs and steps template, you can reference the output from one task, as the input to another task using a template tag:

      dag:
        tasks:
          - name: generate-parameter
            template: whalesay
          - name: consume-parameter
            template: print-message
            dependencies:
              - generate-parameter
            arguments:
              parameters:
                - name: message
                  value: "{{tasks.generate-parameter.outputs.parameters.hello-param}}"

See the complete workflow:

cat parameters-workflow.yaml

Run it:

argo submit --watch parameters-workflow.yaml

You should see:

STEP TEMPLATE PODNAME DURATION MESSAGE ✔ parameters-vjvwg main ├─✔ generate-parameter whalesay parameters-vjvwg-4019940555 43s └─✔ consume-parameter print-message parameters-vjvwg-1497618270 8s