hera
hera copied to clipboard
Issue using with_param and Pydantic IO
Pre-bug-report checklist
1. This bug can be reproduced using pure Argo YAML
- [ ] Yes 👉 Please report a bug to the Argo Workflows GitHub 👈
- [X] No
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
- [X] Yes
3. This bug occurs in Hera when...
- [X] exporting to YAML
- [ ] submitting to Argo
- [ ] running on Argo with the Hera runner
- [ ] other:
Bug report
Describe the bug
When using with_param
with a function using Pydantic IO, an extra argument is added with a name matching the incidental argument name used by the script-decorated function, not the parameters from the Pydantic Input type.
To Reproduce Full Hera code to reproduce the bug:
from hera.workflows import Workflow, Input, Output, script, Steps
from hera.shared import global_config
global_config.experimental_features["script_pydantic_io"] = True
class ListOutput(Output):
values: list[str]
class PrintInput(Input):
value: str
@script()
def produce_list() -> ListOutput:
return ListOutput(values=["item1", "item2"])
@script()
def print_value(input: PrintInput) -> None:
print("Value:", input.value)
with Workflow(name="my-workflow") as w:
with Steps(name="steps"):
list_step = produce_list(arguments={})
print_value(with_param=list_step.get_parameter("values"))
Expected behavior
- arguments:
parameters:
- name: value # This is actually "input"
value: '{{item}}'
Environment
- Hera Version: 5.17.1
- Python Version: 3.11.8
- Argo Version: N/A
Additional context
This is the same root cause as https://github.com/argoproj-labs/hera/issues/861, i.e. the code in _get_params_items_from_source
, but can't be worked around by avoiding using alternative names. https://github.com/argoproj-labs/hera/blob/a08f744cd9d7ca30091e7ab51e80bd18e3116010/src/hera/workflows/_meta_mixins.py#L266-L288