You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The inline runner code generated for Pydantic IO functions is illegal. For example, I'm seeing the following error:
Traceback (most recent call last):
File "/argo/staging/script", line 9, in <module>
print(input.message)
^^^^^^^^^^^^^
AttributeError: 'builtin_function_or_method' object has no attribute 'message'
To Reproduce
Full Hera code to reproduce the bug:
fromhera.sharedimportglobal_configfromhera.workflowsimportInput, Steps, Workflow, scriptglobal_config.experimental_features["script_pydantic_io"] =TrueclassEchoInput(Input):
"""Inputs to the echo function."""# TODO Remove class or replace with your inputsmessage: Annotated[str, Parameter(description="A message to print")]
@script(constructor="inline")defecho(input: EchoInput) ->None:
print(input.message) ## ERROR IS HEREwithWorkflow(name="my-workflow") asw:
withSteps(name="steps"):
echo{arguments={"message": "Hello world"})
Expected behavior
Either an error when generating the YAML that inline mode is not compatible with Pydantic IO, or valid generated Python.
Environment
Hera Version: 5.17.1
Python Version: 3.11.8
Argo Version: 3.4.17.1
Additional context
The source of the problem is obvious when looking at the YAML:
source: |- import os import sys sys.path.append(os.getcwd()) import json try: message = json.loads(r'''{{inputs.parameters.message}}''') except: message = r'''{{inputs.parameters.message}}''' """Prints out a message.""" print(input.message)
It would be very helpful for teaching purposes if at least a subset of the Pydantic IO features could be supported with the inline runner. In our setup, changing and deploying a non-inline script requires pushing a commit to a PR and waiting for CI, while inline scripts can be modified and tested with a simpler, local, make-based flow. This would probably require introspecting the Pydantic types and generating equivalent classes in the generated code.
Failing that, a more explanatory failure mode would be valuable for users migrating old flows to Pydantic IO.
The text was updated successfully, but these errors were encountered:
Hera provides the Input and Output Pydantic classes which can be used to more succinctly write your script function inputs and outputs, and requires use of the Hera Runner.
We could add an error, but I'm also concerned about increasing the complexity of the codebase for all the handholding for user errors.
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
3. This bug occurs in Hera when...
Bug report
Describe the bug
The inline runner code generated for Pydantic IO functions is illegal. For example, I'm seeing the following error:
To Reproduce
Full Hera code to reproduce the bug:
Expected behavior
Either an error when generating the YAML that inline mode is not compatible with Pydantic IO, or valid generated Python.
Environment
Additional context
The source of the problem is obvious when looking at the YAML:
It would be very helpful for teaching purposes if at least a subset of the Pydantic IO features could be supported with the inline runner. In our setup, changing and deploying a non-inline script requires pushing a commit to a PR and waiting for CI, while inline scripts can be modified and tested with a simpler, local, make-based flow. This would probably require introspecting the Pydantic types and generating equivalent classes in the generated code.
Failing that, a more explanatory failure mode would be valuable for users migrating old flows to Pydantic IO.
The text was updated successfully, but these errors were encountered: