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

CLI does not correctly generate script templates that use the runner #1161

Open
2 of 6 tasks
elliotgunton opened this issue Aug 20, 2024 · 0 comments
Open
2 of 6 tasks
Labels
type:bug A general bug

Comments

@elliotgunton
Copy link
Collaborator

elliotgunton commented Aug 20, 2024

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. 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
A clear and concise description of what the bug is:
See title/repro below

To Reproduce
Full Hera code to reproduce the bug:

  1. Create a folder with a Python file in it:
tree .
.
├── hera_example
│   ├── new_decorators.py
  1. Add Python code (adapted from new_decorators_basic_script.py example)
from hera.shared import global_config
from hera.workflows import Input, Output, WorkflowTemplate

global_config.experimental_features["decorator_syntax"] = True

w = WorkflowTemplate(name="my-template")

class MyInput(Input):
    user: str

@w.set_entrypoint
@w.script()
def hello_world(my_input: MyInput) -> Output:
    output = Output()
    output.result = f"Hello Hera User: {my_input.user}!"
    return output
  1. Run hera generate yaml hera_example/new_decorators.py to get the following yaml:
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: my-template
spec:
  entrypoint: hello-world
  templates:
  - inputs:
      parameters:
      - name: user
    name: hello-world
    script:
      args:
      - -m
      - hera.workflows.runner
      - -e
      - new_decorators:hello_world
      command:
      - python
      env:
      - name: hera__script_annotations
        value: ''
      - name: hera__outputs_directory
        value: /tmp/hera-outputs
      - name: hera__script_pydantic_io
        value: ''
      image: python:3.8
      source: '{{inputs.parameters}}'

Notice that the entrypoint is not hera_example.new_decorators:hello_world, meaning this script would not work as it won't find the module/file when installed in a Docker container.

Expected behavior
A clear and concise description of what you expected to happen:

hera generate should match w.to_yaml() output (when run from a separate Python script) with full module path:

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: my-template
spec:
  entrypoint: hello-world
  templates:
  - inputs:
      parameters:
      - name: user
    name: hello-world
    script:
      args:
      - -m
      - hera.workflows.runner
      - -e
      - hera_example.new_decorators:hello_world
      command:
      - python
      env:
      - name: hera__script_annotations
        value: ''
      - name: hera__outputs_directory
        value: /tmp/hera-outputs
      - name: hera__script_pydantic_io
        value: ''
      image: python:3.8
      source: '{{inputs.parameters}}'

Environment

  • hera[experimental]==5.16.2
  • Python Version: 3.12.4

Additional context
Add any other context about the problem here.

@elliotgunton elliotgunton added the type:bug A general bug label Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant