-
Notifications
You must be signed in to change notification settings - Fork 106
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
Support Literal types in script runner #1173
Labels
type:bug
A general bug
Comments
4 tasks
sambhav
pushed a commit
that referenced
this issue
Oct 21, 2024
**Pull Request Checklist** - [ ] Fixes #<!--issue number goes here--> - [X] Tests added - [ ] Documentation/examples added - [X] [Good commit messages](https://cbea.ms/git-commit/) and/or PR title **Description of PR** PR #1168 changed the logic of `map_runner_input` and `_parse` to no longer pass incoming values to `json.loads` if their annotated type was a union that included str, rather than only when given a subtype of `Optional[str]`. This makes it impossible to, for instance, pass an int to a `Union[str, int]`. This PR splits `origin_type_issubclass` into two functions, `origin_type_issupertype` (which matches the previous behaviour) and `origin_type_issubtype`, and use the latter instead to restore the original behaviour. Additionally, it fixes a bug where we were passing an annotation to `issubclass` without first checking if it's a type, resulting in a `TypeError` (partially addresses #1173). --------- Signed-off-by: Alice Purcell <alicederyn@gmail.com>
4 tasks
sambhav
pushed a commit
that referenced
this issue
Nov 6, 2024
**Pull Request Checklist** - [X] Fixes #1173 - [X] Tests added - [ ] Documentation/examples added - [X] [Good commit messages](https://cbea.ms/git-commit/) and/or PR title **Description of PR** Currently, the script runner does not support `Literal` types, as `origin_type_issubtype` does not special-case them, so `_is_str_kwarg_of` does not return True. This PR adds supports for Literals to `origin_type_issubtype`, and additionally copies their values from the annotation into the `enum` field on input Parameters. It also combines two paths in `_get_inputs_from_callable` into one by using `construct_io_from_annotation` instead of having a fallback branch if `get_workflow_annotation` returns `None`; this fixes a bug where the default was being verified as None for optional strings only if there was no IO annotation. --------- Signed-off-by: Alice Purcell <alicederyn@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pre-bug-report checklist
1. This bug can be reproduced using pure Argo YAML
If yes, it is more likely to be an Argo bug unrelated to Hera. Please double check before submitting an issue to Hera.
2. This bug occurs in Hera when...
Bug report
Describe the bug
A clear and concise description of what the bug is:
Using a function with a Literal argument in the runner results in the following trace:
Error log if applicable:
To Reproduce
Full Hera code to reproduce the bug:
Expected behavior
A clear and concise description of what you expected to happen:
_is_str_kwarg_of
should returnTrue
Parameter.enum
should be inferred to be["foo", "bar"]
Environment
The text was updated successfully, but these errors were encountered: