Skip to content
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

Default output parameters don't work (anymore?) #2494

Closed
4 tasks done
samath117 opened this issue Mar 22, 2020 · 7 comments · Fixed by #2500
Closed
4 tasks done

Default output parameters don't work (anymore?) #2494

samath117 opened this issue Mar 22, 2020 · 7 comments · Fixed by #2500
Assignees
Labels

Comments

@samath117
Copy link

Checklist:

  • I've included the version.
  • I've included reproduction steps.
  • I've included the workflow YAML.
  • I've included the logs.

According to #954, it should be possible to specify default values for output parameters when the valueFrom.path does not actually have a file. Here's how @jessesuen described his proposal:

One thing we might consider is having default values for output parameters. So if you have the following:

outputs:
  parameters:
  - name: hello
    default: ''
    valueFrom:
      path: /hello.json

if /hello.json does not exist, then we would return empty string, which I think addresses your use case.

That issue was later closed by PR #1277. However, that closure looks wrong to me: That PR only covered the case of output artifacts, not output parameters. The default field gets past the linter, but that's the only evidence I have that this has been actually implemented.

Here's a full-blown example to try out:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: default-output-parameter-
spec:
  entrypoint: output-parameter
  templates:
  - name: output-parameter
    steps:
    - - name: generate-parameter
        template: whalesay
    - - name: consume-parameter
        template: print-message
        arguments:
          parameters:
          - name: message
            value: "{{steps.generate-parameter.outputs.parameters.hello-param}}"

  - name: whalesay
    container:
      image: docker/whalesay:latest
      command: [sh, -c]
      args: ["sleep 1; echo -n hello world > /tmp/hello_world.txt"]
    outputs:
      parameters:
      - name: hello-param
        default: hello
        valueFrom:
          path: /wrong/path/to/file.txt

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

When I submit this, after the generate-parameter step runs, it fails with a failed to save outputs: exit status 2 error message.

This has the same behavior in v2.4.0 through v2.6.3. Was this feature never actually implemented? I have a vague memory of this working, and even incorporated it into some of my templates, but I guess I must never have fully tested it.


Message from the maintainers:

If you are impacted by this bug please add a 👍 reaction to this issue! We often sort issues this way to know what to prioritize.

@simster7
Copy link
Member

simster7 commented Mar 23, 2020

Was this feature never actually implemented?

I doesn't look like it from the code, seems like the field parameter.default has been unused for a while. (In fact #2222 seems to have deprecated it).

Is there a use case where having default output parameters would be significantly more useful versus a solution that takes advantage #1277? If so, we can implement it.

@simster7
Copy link
Member

I'll close this in favor of #2495, since this is now a feature request. No need to provide motivation anymore, since you've done it there.

@samath117
Copy link
Author

Is there a use case where having default output parameters would be significantly more useful versus a solution that takes advantage #1277? If so, we can implement it.
Well, yes, in the case that you want to use an output parameter, not an output artifact, in this way.

This issue covers the case of container/script templates; #2495 covers the case of steps/dag templates. The trigger condition (file at path does not exist versus parameter does not exist) is slightly different but if you can solve both in one fell swoop, that'd be great.

@samath117
Copy link
Author

This bug still exists in v2.7.0. I ran exactly the workflow listed above and it failed in exactly the same way.

@simster7
Copy link
Member

simster7 commented Apr 4, 2020

Hi @samath117, I haven't had a chance to re-run the Workflow on 2.7.0 yet, but keep in mind that the field was actually added to parameters.valueFrom.default (not parameters.default), so the example workflow listed above would still not work.

Here's an example of the correct spec:

    outputs:
      parameters:
        - name: nested-out-parameter
          valueFrom:
            default: "Default value"
            parameter: "{{steps.generate-2.outputs.parameters.out-parameter}}"

@simster7
Copy link
Member

simster7 commented Apr 4, 2020

Just to catalogue: I decided to introduce the new field (parameters.valueFrom.default) as opposed to using the existing (and deprecated parameters.default) mainly because I wanted it to be clear that it would only override a failed valueFrom retrieval, and not a successfully retrieved and empty parameter value. I feared that having parameters.default would give the impression that it would override said empty parameter.value field, when that was not the desired behavior.

@samath117
Copy link
Author

samath117 commented Apr 6, 2020

Sweet, this example now succeeds:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: default-output-parameter-
spec:
  entrypoint: output-parameter
  templates:
  - name: output-parameter
    steps:
    - - name: generate-parameter
        template: whalesay
    - - name: consume-parameter
        template: print-message
        arguments:
          parameters:
          - name: message
            value: "{{steps.generate-parameter.outputs.parameters.hello-param}}"

  - name: whalesay
    container:
      image: docker/whalesay:latest
      command: [sh, -c]
      args: ["sleep 1; echo -n hello world > /tmp/hello_world.txt"]
    outputs:
      parameters:
      - name: hello-param
        valueFrom:
          path: /wrong/path/to/file.txt
          default: hello

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants