-
Notifications
You must be signed in to change notification settings - Fork 109
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
Fix multiple bugs in Hera Input
and Output
classes
#1193
Fix multiple bugs in Hera Input
and Output
classes
#1193
Conversation
The current code will silently skip fields with: - a Pydantic annotation but no workflow annotation - a workflow annotation with no name field Fix the code to ignore unrecognized annotations (this is a requirement of the Annotated spec) and to default the model name to the field name if none is given explicitly. Signed-off-by: Alice Purcell <alicederyn@gmail.com>
Signed-off-by: Alice Purcell <alicederyn@gmail.com>
Signed-off-by: Alice Purcell <alicederyn@gmail.com>
Signed-off-by: Alice Purcell <alicederyn@gmail.com>
Signed-off-by: Alice Purcell <alicederyn@gmail.com>
OutputMixin._get_outputs was mutating the original annotation instead of copying it; not defaulting the name to the field name; and not copying the model default into the annotation. Signed-off-by: Alice Purcell <alicederyn@gmail.com>
519f83d
to
5d9ce17
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1193 +/- ##
=======================================
+ Coverage 81.7% 86.0% +4.3%
=======================================
Files 54 60 +6
Lines 4208 4038 -170
Branches 889 838 -51
=======================================
+ Hits 3439 3475 +36
+ Misses 574 391 -183
+ Partials 195 172 -23 ☔ View full report in Codecov by Sentry. |
5d9ce17
to
a87a7db
Compare
Multiple methods in _io_mixins resolve the same problem of iterating through all fields, constructing a workflow annotation based on the user's annotations, defaulting the name if unset or falling back to a Parameter if no annotation is found. Factor that logic out into an iterator, simplifying the various methods and reducing the risk of discrepancies and bugs in future. Signed-off-by: Alice Purcell <alicederyn@gmail.com>
a87a7db
to
d9363d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to have loads of tests! Saw a couple of places we could do some extra cleanup
This also fixes #1165, updated the PR description |
**Pull Request Checklist** - [x] Fixes #1198 - [ ] ~Tests added~ - [x] Documentation/examples added - [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR title **Description of PR** From issue description: * [Script basics "explicit" example](https://hera.readthedocs.io/en/stable/user-guides/script-basics/#script-decorator) passes `source=echo` in a Task - this is not possible * [Script annotations](https://hera.readthedocs.io/en/stable/user-guides/script-annotations/) is quite confusing to read. Examples are overly complex/wordy, some being incorrect. We can also show that `name` can be inferred when #1193 is merged * [expr guide](https://hera.readthedocs.io/en/stable/user-guides/expr/)'s first link is dead, also some formatting can be tidied up * README is duplicated due to mascot image link, but we can fix this. Also note the [PyPI page](https://pypi.org/project/hera/) has a broken image ![image](https://github.com/user-attachments/assets/1ac93d04-9f9a-4816-8123-9b8bab7ffc50) --------- Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
Input
and Output
classes
Pull Request Checklist
Description of PR
Currently, the methods that consume annotations in InputMixin and OutputMixin have multiple bugs:
OutputMixin._get_outputs
additionally was:This PR pulls out a common function to iterate through fields and yield annotations, which:
This ensures all functions treat an explicit Parameter and a missing workflow annotation the same way, solving the second issue with
OutputMixin._get_outputs
.