Giter Site home page Giter Site logo

Comments (2)

sam2x avatar sam2x commented on September 25, 2024 1

Hello @elliotgunton, thank you for the quick reply. I start to get more visibility on this.

  1. This was also my outcome, it doesnt seems yet supported under RunnerInput specific context usage.
  2. Just mixed my explanation. I thought this specific "output=True" would generate an "artifact" under the hood (since it provide a Path i would "write_text" to) without having to explicitly declare it in my "outputs" arguments.
  3. Awesome
  4. Oh, make sense now, thanks!

Following my exploration, It seems that the RunnerInput documentation sample is not working out-the-box. I used the documentation example:

class MyInput(RunnerInput):
    param_int: Annotated[int, Parameter(name="param-input")] = 42
    an_object: Annotated[MyObject, Parameter(name="obj-input")] = MyObject(
        a_dict={"my-key": "a-value"}, a_str="hello world!"
    )
    artifact_int: Annotated[int, Artifact(name="artifact-input", loader=ArtifactLoader.json)]

class MyOutput(RunnerOutput):
    param_int: Annotated[int, Parameter(name="param-output")] 
    artifact_int: Annotated[int, Artifact(name="artifact-output")]
    
@script(constructor="runner")
def pydantic_io(
    my_input: MyInput,
) -> MyOutput:
    return MyOutput(exit_code=1, result="Test!", param_int=42, artifact_int=my_input.param_int)

And in my workflow I tried several way to submit the pydantic_io :

  t_pydantic = pydantic_io()
Code Result Observation
pydantic_io() inputs.artifacts.artifact-input was not supplied` Legit, since there isn't default value and we haven't pass any value for artifact_int. But the doc doesnt mention anything about it.
pydantic_io(arguments=MyInput()) ValidationError: 1 validation error for MyInput artifact_int field required (type=value_error.missing) Similar call, so validation error make sense so far to me
pydantic_io(arguments=MyInput(artifact_int=0)) _Parameter.check_name (parameter.py:29) ValueError: name cannot be None or empty when used Expected, arguments is expected a dict of parameters/artifacts
pydantic_io(arguments={'my_input':MyInput(artifact_int=0)}) BadRequest: Server returned status code 400 with message: templates.main.tasks.pydantic-io templates.pydantic-io inputs.artifacts.artifact-input was not supplied I was hoping this one to work
args=MyInput(param_input=0, artifact_int=0) pydantic_io(arguments=args._get_parameters()) templates.main.tasks.pydantic-io.arguments.param-input.value is required Lost on this one, param-input is supposed to have default value already set, but i guess i am calling it wrongly
  1. Is there a working way to pass the missing value artifact_int ?
  2. What is the conventional way to "overwrite" a specific parameter (such as "my_object") ?

Thank you

from hera.

elliotgunton avatar elliotgunton commented on September 25, 2024

Hi @sam2x - thank you for the feedback on this new feature! I will answer your questions numbered 1-4:

  1. Currently, the use of output=True is not explicitly supported by the RunnerInput class (and I haven't tested it). You would need to workaround Pydantic's validation by setting a default value. I think it might work this way, but no guarantees!
class MyDefaultInput (RunnerInput):
    stdout: Annotated[Path, Parameter(global_name="stdout", name="stdout", output=True)] = Path("/tmp/stdout.txt")
  1. I think the answer is "no" but I'm not exactly clear on what you're asking - "If i use an artifact declaration in the function signature" vs "here I declare it as "Parameter" - you can only declare it as one or the other? Hera does different things for you automatically based on the type of function parameter, so you would have to use S3Artifact to "be recorded automatically".
  2. Yes that should work - I can add a test to confirm it
  3. The result is meant to emulate the script result (see docs) - to allow steps/dags to use the syntax of {{steps.my-step.outputs.result}}

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.