Giter Site home page Giter Site logo

Comments (1)

elliotgunton avatar elliotgunton commented on June 23, 2024

We can show the problem with this workflow. The CustomScriptConstructor just wraps the runner script constructor to print the incoming kwargs list for sanity checks (i.e. it does receive a json str)

import json
from typing import Annotated

from hera.workflows import Parameter, Steps, WorkflowTemplate, script
from testrunnerloading.custom_runner import CustomScriptConstructor

@script(constructor=CustomScriptConstructor())
def take_json_str(my_json: Annotated[str, Parameter(name="my-json")]):
    """Take a json string, load it and print it."""
    print(json.loads(my_json))


def get_workflow_template() -> WorkflowTemplate:
    """Create and return the test-runner-loading WorkflowTemplate."""
with WorkflowTemplate(
    name="mlplatform.test-runner-loading",
    entrypoint="steps",
) as wt:
    with Steps(name="steps"):
        take_json_str(arguments={"my_json": json.dumps({"key": "value"})})

Which gets an error like:

source contents: [{"name":"my_json","value":"{\"key\": \"value\"}"}]
kwargs_list: [{'name': 'my_json', 'value': '{"key": "value"}'}]
calling function
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/workspace/testrunnerloading/custom_runner.py", line 350, in <module>
    _run()
  File "/workspace/testrunnerloading/custom_runner.py", line 343, in _run
    result = _runner(args.entrypoint, kwargs_list)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/testrunnerloading/custom_runner.py", line 315, in _runner
    return function(**kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/workspace/testrunnerloading/custom_runner.py", line 58, in inner
    return f(**filtered_kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
  File "pydantic/decorator.py", line 133, in pydantic.decorator.ValidatedFunction.call
  File "pydantic/decorator.py", line 130, in pydantic.decorator.ValidatedFunction.init_model_instance
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for TakeJsonStr
my_json
  str type expected (type=type_error.str)
time="2023-11-09T11:53:38 UTC" level=info msg="sub-process exited" argo=true error="<nil>"
Error: exit status 1

from hera.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.