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

Cannot set default values for workflow template arguments #1268

Open
3 of 7 tasks
tzielaski opened this issue Nov 18, 2024 · 0 comments
Open
3 of 7 tasks

Cannot set default values for workflow template arguments #1268

tzielaski opened this issue Nov 18, 2024 · 0 comments

Comments

@tzielaski
Copy link

Pre-bug-report checklist

1. This bug can be reproduced using pure Argo YAML

If yes, it is more likely to be an Argo bug unrelated to Hera. Please double check before submitting an issue to Hera.

2. I have searched for existing issues

  • Yes

3. This bug occurs in Hera when...

  • exporting to YAML
  • submitting to Argo
  • running on Argo with the Hera runner
  • other:

Bug report

Describe the bug
Setting default values for workflow template's arguments doesn't work but is supported by Argo if specified directly in the YAML.

To Reproduce
Full Hera code to reproduce the bug:

from hera.workflows import DAG, script, WorkflowTemplate, Parameter


@script()
def foo(a, b=42, c=None):
    print(a, b, c)


with WorkflowTemplate(
        name="test-default-param",
        entrypoint="d",
        arguments=[
            Parameter(name='a', default='1', description='This should have a default')
        ]
) as w:
    with DAG(
            name="d",
            inputs=[
                Parameter(name='a', default='1')
            ]):
        foo(name="b-unset-c-unset", arguments={"a": "{{ inputs.parameters.a }}"})

generates

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: test-default-param
spec:
  arguments:
    parameters:
    - description: This should have a default
      name: a
  entrypoint: d
  templates:
  - dag:
      tasks:
      - arguments:
          parameters:
          - name: a
            value: '{{ inputs.parameters.a }}'
        name: b-unset-c-unset
        template: foo
    inputs:
      parameters:
      - default: '1'
        name: a
    name: d
  - inputs:
      parameters:
      - name: a
      - default: '42'
        name: b
      - default: 'null'
        name: c
    name: foo
    script:
      command:
      - python
      image: python:3.8
      source: |-
        import os
        import sys
        sys.path.append(os.getcwd())
        import json
        try: a = json.loads(r'''{{inputs.parameters.a}}''')
        except: a = r'''{{inputs.parameters.a}}'''
        try: b = json.loads(r'''{{inputs.parameters.b}}''')
        except: b = r'''{{inputs.parameters.b}}'''
        try: c = json.loads(r'''{{inputs.parameters.c}}''')
        except: c = r'''{{inputs.parameters.c}}'''

        print(a, b, c)

The default value is not present in the UI:
image

Expected behavior
The generated YAML contains default values:

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: test-default-param
spec:
  arguments:
    parameters:
    - description: This should have a default
      default: '1'
      name: a
  entrypoint: d
  templates:
  - dag:
      tasks:
      - arguments:
          parameters:
          - name: a
            value: '{{ inputs.parameters.a }}'
        name: b-unset-c-unset
        template: foo
    inputs:
      parameters:
      - default: '1'
        name: a
    name: d
  - inputs:
      parameters:
      - name: a
      - default: '42'
        name: b
      - default: 'null'
        name: c
    name: foo
    script:
      command:
      - python
      image: python:3.8
      source: |-
        import os
        import sys
        sys.path.append(os.getcwd())
        import json
        try: a = json.loads(r'''{{inputs.parameters.a}}''')
        except: a = r'''{{inputs.parameters.a}}'''
        try: b = json.loads(r'''{{inputs.parameters.b}}''')
        except: b = r'''{{inputs.parameters.b}}'''
        try: c = json.loads(r'''{{inputs.parameters.c}}''')
        except: c = r'''{{inputs.parameters.c}}'''

        print(a, b, c)

and the default value is set in Argo UI
image

Environment

  • Hera Version: 5.16.2
  • Python Version: 3.12.5
  • Argo Version: 3.6.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant