-
Notifications
You must be signed in to change notification settings - Fork 104
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
Add pydantic IO docs #939
Merged
Merged
Add pydantic IO docs #939
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elliotgunton
added
type:documentation
A documentation update
semver:minor
A change requiring a minor version bump
labels
Jan 22, 2024
elliotgunton
force-pushed
the
pydantic-v2-io
branch
from
January 23, 2024 15:24
56b1756
to
2a2a6cc
Compare
elliotgunton
force-pushed
the
pydantic-io-docs
branch
from
January 23, 2024 15:25
cd24e65
to
42a329a
Compare
4 tasks
elliotgunton
force-pushed
the
pydantic-v2-io
branch
8 times, most recently
from
January 29, 2024 10:58
552727e
to
9bfdb1c
Compare
elliotgunton
force-pushed
the
pydantic-io-docs
branch
2 times, most recently
from
January 29, 2024 11:11
fa13f8d
to
826c13a
Compare
samj1912
pushed a commit
that referenced
this pull request
Jan 30, 2024
**Pull Request Checklist** - [x] Part of #858 - [x] Tests added - [ ] ~Documentation/examples added~ See #939 - [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR title **Description of PR** Currently hera i/o with annotated params can become extremely verbose. The output syntax is especially error-prone. This PR introduces custom Input/Output BaseModels for users to subclass, which allow a cleaner arrangement of inputs and outputs for functions. These are available under the `script_pydantic_io` experimental feature flag. With these Pydantic input/output models, the following should be noted: * duplicated param names (for normal Parameters as well as the new models) are now detected in Hera rather than when linted by Argo (as well as duplicated artifact names). Parameters and Artifacts having the same name is legal in the Argo spec as they exist in different scopes e.g. ```yaml ... inputs: parameters: - name: my-name default: test artifacts: - name: my-name path: /tmp optional: true ... ``` * `exit_code` and `result` are reserved attributes for the `RunnerOutput`. A user trying to use their own parameters with these names would have to be specified with an annotated parameter e.g. `my_exit_code: Annotated[int, Parameter(name="exit_code")]` (TBC with a test) * Scripts cannot have a return tuple containing any `RunnerOutput` to avoid multiple `exit_code`s being specified. @samj1912 / @flaviuvadan this is up for debate but I think would encourage better practices to discourage tuples and have a single script template outputting a single `RunnerOutput` subclass, and it keeps the logic clearer from the Hera side. Users can still use inline output parameters alongside the `RunnerOutput` return annotation * Multiple input parameters when using a `RunnerInput` in the function params **is not legal** * A `RunnerInput`'s `__fields__` as defined by pydantic are used to "explode" the input class into constituent parameters for the Argo spec. i.e. using the following class as an input param to a script function: ```py class MyInput(RunnerInput): my_input_str: str my_input_int: int @script(constructor="runner") def my_func(my_input: MyInput): ... ``` will create the script template `my_func` in yaml with Parameters `my_input_str` and `my_input_int`, NOT `my_input`, [see the example](https://github.com/argoproj-labs/hera/blob/92f11d341eb29d2501b9ee5be57a703160b35e24/docs/examples/workflows/experimental/script_pydantic_io.md) --------- Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
elliotgunton
force-pushed
the
pydantic-v2-io
branch
from
January 30, 2024 16:52
9bfdb1c
to
8447a73
Compare
elliotgunton
force-pushed
the
pydantic-io-docs
branch
from
January 30, 2024 16:52
826c13a
to
1172466
Compare
elliotgunton
force-pushed
the
pydantic-v2-io
branch
3 times, most recently
from
January 31, 2024 11:20
cc03607
to
4ded421
Compare
elliotgunton
force-pushed
the
pydantic-io-docs
branch
from
January 31, 2024 11:24
1172466
to
7e0d3d1
Compare
elliotgunton
force-pushed
the
pydantic-v2-io
branch
from
January 31, 2024 11:24
4ded421
to
a394e6c
Compare
elliotgunton
force-pushed
the
pydantic-io-docs
branch
from
January 31, 2024 11:24
7e0d3d1
to
87c2f8d
Compare
elliotgunton
force-pushed
the
pydantic-v2-io
branch
from
January 31, 2024 11:34
a394e6c
to
a920ca6
Compare
elliotgunton
force-pushed
the
pydantic-io-docs
branch
from
January 31, 2024 11:40
87c2f8d
to
80dfdae
Compare
elliotgunton
force-pushed
the
pydantic-v2-io
branch
from
January 31, 2024 13:38
a920ca6
to
edfea25
Compare
elliotgunton
force-pushed
the
pydantic-io-docs
branch
from
January 31, 2024 13:38
80dfdae
to
1413916
Compare
flaviuvadan
approved these changes
Feb 1, 2024
elliotgunton
force-pushed
the
pydantic-v2-io
branch
from
February 2, 2024 11:07
edfea25
to
6e5141b
Compare
elliotgunton
force-pushed
the
pydantic-io-docs
branch
from
February 2, 2024 11:08
1413916
to
720f650
Compare
elliotgunton
force-pushed
the
pydantic-v2-io
branch
from
February 7, 2024 11:38
6e5141b
to
5c9322d
Compare
elliotgunton
force-pushed
the
pydantic-io-docs
branch
2 times, most recently
from
February 7, 2024 12:30
7941610
to
d0f47a9
Compare
elliotgunton
force-pushed
the
pydantic-v2-io
branch
from
February 7, 2024 12:30
5c9322d
to
bc9bf45
Compare
elliotgunton
force-pushed
the
pydantic-io-docs
branch
from
February 7, 2024 12:48
9892e5e
to
d0f47a9
Compare
elliotgunton
force-pushed
the
pydantic-v2-io
branch
from
February 12, 2024 12:09
045c23d
to
83b70ae
Compare
elliotgunton
force-pushed
the
pydantic-io-docs
branch
from
February 12, 2024 12:11
d0f47a9
to
23e2929
Compare
elliotgunton
force-pushed
the
pydantic-v2-io
branch
from
February 12, 2024 12:15
83b70ae
to
6dafbb6
Compare
elliotgunton
force-pushed
the
pydantic-io-docs
branch
2 times, most recently
from
February 12, 2024 12:21
213cbf1
to
db65509
Compare
samj1912
approved these changes
Feb 12, 2024
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #939 +/- ##
=======================================
- Coverage 81.8% 81.7% -0.2%
=======================================
Files 54 54
Lines 4188 4208 +20
Branches 883 889 +6
=======================================
+ Hits 3428 3439 +11
- Misses 566 574 +8
- Partials 194 195 +1 ☔ View full report in Codecov by Sentry. |
* Enables users to use Pydantic V2 objects in their scripts while maintaining V1 usage internally for Hera * RunnerInput/Output classes are defined in hera.workflows.io.v1 and hera.workflows.io.v2, allowing users to use v1 or v2 depending on their installation and migration progress. Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
**Pull Request Checklist** - [x] Fixes #948 - [x] Tests added - [ ] Documentation/examples added - [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR title **Description of PR** When running a script via the Hera Runner, if it raises an error, the declared outputs of the (script) template are not created as files in the container, leading to confusing Argo logs such as: ``` msg="cannot save parameter /tmp/hera-outputs/parameters/my-parameter" argo=true error="open /tmp/hera-outputs/parameters/my-parameter: no such file or directory"` ``` This PR makes the runner catch the exception, write dummy values, then pass the exception up. Signed-off-by: Elliot Gunton <egunton@bloomberg.net> Co-authored-by: Sambhav Kothari <skothari44@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
elliotgunton
force-pushed
the
pydantic-io-docs
branch
from
February 12, 2024 12:51
54453ad
to
3b92519
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add docs to script user guide and experimental features section