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

Parameter Validation Error when using get_parameter with a parameter set using ValueFrom #550

Closed
inari-ldenton opened this issue Apr 4, 2023 · 0 comments · Fixed by #565 or #624
Closed
Labels
note:good-first-issue A good first issue to get started with type:bug A general bug

Comments

@inari-ldenton
Copy link

Overview

Currently if you attempt to generate a workflow with the following snippet you will get a validation error, this is occuring on hera version 5.1.0. I believe this is occurring due to the way the get_parameter function returns a Parameter. It will copy over the existing value_from field and set the value field for the task output. This leads to both value_from and value being set on the new parameter causing the validation to fail. In my testing, removing the value_from=obj.value_from, from the parameter being returned fixes the issue.

Example Code

from hera.workflows import DAG, Parameter, Task, Workflow, script
from hera.workflows.models import ValueFrom


@script(
    outputs=[
        Parameter(
            name="a",
            value_from=ValueFrom(path="/test_out"),
        )
    ]
)
def out():
    with open("/test_out", "w") as f_out:
        f_out.write("TESTEST")


@script()
def in_(a):
    print(a)


with Workflow(generate_name="script-param-passing-", entrypoint="d") as w:
    with DAG(name="d"):
        t1: Task = out()
        t2 = in_(arguments=t1.get_parameter("a"))
        t1 >> t2

# Write the workflow
with open("param_test.yaml", "w") as f_out:
    f_out.write(w.to_yaml())

Error

Traceback (most recent call last):
  File "**/param_passing.py", line 27, in <module>
    t2 = in_(arguments=t1.get_parameter("a"))
  File "**/lib/python3.10/site-packages/hera/workflows/task.py", line 185, in get_parameter
    return Parameter(
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for Parameter
__root__
  Cannot specify both `value` and `value_from` when instantiating `Parameter` (type=value_error)
@sambhav sambhav added type:bug A general bug note:good-first-issue A good first issue to get started with labels Apr 4, 2023
flaviuvadan added a commit that referenced this issue Apr 8, 2023
Fixes: #550
Fixes: #565 

---------

Signed-off-by: Flaviu Vadan <flaviuvadan@gmail.com>
Signed-off-by: lakhanjindam <lakhanj569@gmail.com>
Co-authored-by: Lakhan Jindam <48401688+lakhanjindam@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
note:good-first-issue A good first issue to get started with type:bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants