Skip to content
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 #1249

Merged
merged 7 commits into from
Nov 6, 2024

Conversation

alicederyn
Copy link
Collaborator

Pull Request Checklist

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.

@alicederyn alicederyn changed the title Input.only.literal.types Support Literal types in script runner Oct 28, 2024
@alicederyn alicederyn added semver:patch A change requiring a patch version bump type:enhancement A general enhancement labels Oct 28, 2024
Copy link

codecov bot commented Oct 28, 2024

Codecov Report

Attention: Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.2%. Comparing base (52670c4) to head (3c11a14).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/hera/workflows/script.py 92.8% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1249   +/-   ##
=====================================
  Coverage   86.2%   86.2%           
=====================================
  Files         60      60           
  Lines       4109    4113    +4     
  Branches     659     660    +1     
=====================================
+ Hits        3543    3547    +4     
  Misses       393     393           
  Partials     173     173           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alicederyn alicederyn force-pushed the input.only.literal.types branch 6 times, most recently from 3aa8505 to 3ee9ef3 Compare October 28, 2024 11:11
@alicederyn alicederyn marked this pull request as ready for review October 28, 2024 11:35
@alicederyn alicederyn closed this Nov 5, 2024
Combine the two non-Pydantic paths of _get_inputs_from_callable into one
using construct_io_from_annotation. 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 <[email protected]>
@alicederyn alicederyn reopened this Nov 5, 2024
src/hera/shared/_type_util.py Outdated Show resolved Hide resolved
src/hera/shared/_type_util.py Outdated Show resolved Hide resolved
Signed-off-by: Alice Purcell <[email protected]>
This function only support setting the enum field, and it doesn't appear
likely that we will want to set other fields in future, so make the name
more specific. Additionally, add a docstring, and refactor the function
to use the early-return pattern now adding other metadata is ruled out.

Signed-off-by: Alice Purcell <[email protected]>
Copy link
Collaborator

@jeongukjae jeongukjae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@sambhav sambhav merged commit 4328576 into argoproj-labs:main Nov 6, 2024
23 checks passed
@alicederyn alicederyn deleted the input.only.literal.types branch November 6, 2024 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:patch A change requiring a patch version bump type:enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Literal types in script runner
3 participants