-
Notifications
You must be signed in to change notification settings - Fork 297
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 default values in typing.List[dataclass] and typing.Dict[str, dataclass] #2603
Support default values in typing.List[dataclass] and typing.Dict[str, dataclass] #2603
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2603 +/- ##
===========================================
+ Coverage 39.16% 71.67% +32.51%
===========================================
Files 187 187
Lines 19236 19221 -15
Branches 4019 2785 -1234
===========================================
+ Hits 7533 13776 +6243
+ Misses 11470 4770 -6700
- Partials 233 675 +442 ☔ View full report in Codecov by Sentry. |
Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: mao3267 <chenvincent610@gmail.com>
* truncate sagemaker agent outputs Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * fix tests and update agent output Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * lint Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * fix test Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add idempotence token to workflow Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * fix type Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * fix mixin Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * modify output handler Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * make the dictionary deterministic Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * nit Signed-off-by: Samhita Alla <aallasamhita@gmail.com> --------- Signed-off-by: Samhita Alla <aallasamhita@gmail.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: Kevin Su <pingsutw@apache.org> Signed-off-by: mao3267 <chenvincent610@gmail.com>
…tionable (flyteorg#2594) Signed-off-by: Fabio Grätz <fabiogratz@googlemail.com> Co-authored-by: Fabio Grätz <fabiogratz@googlemail.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
…-auth credentials in auth interceptor (flyteorg#2591) Signed-off-by: Fabio Grätz <fabiogratz@googlemail.com> Co-authored-by: Fabio Grätz <fabiogratz@googlemail.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
* validate idempotence token length in subsequent tasks Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * remove redundant param Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add tests Signed-off-by: Samhita Alla <aallasamhita@gmail.com> --------- Signed-off-by: Samhita Alla <aallasamhita@gmail.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> Co-authored-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
…teorg#2602) * eliminate redundant literal conversion for type Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add test Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * lint Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add isclass check Signed-off-by: Samhita Alla <aallasamhita@gmail.com> --------- Signed-off-by: Samhita Alla <aallasamhita@gmail.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: Future-Outlier <eric901201@gmail.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
* add nim plugin Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * move nim to inference Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * import fix Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * fix port Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add pod_template method Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add containers Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * update Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * clean up Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * remove cloud import Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * fix extra config Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * remove decorator Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add tests, update readme Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add env Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add support for lora adapter Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * minor fixes Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add startup probe Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * increase failure threshold Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * remove ngc secret group Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * move plugin to flytekit core Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * fix docs Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * remove hf group Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * modify podtemplate import Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * fix import Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * fix ngc api key Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * fix tests Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * fix formatting Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * lint Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * docs fix Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * docs fix Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * update secrets interface Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add secret prefix Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * fix tests Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add urls Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add urls Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * remove urls Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * minor modifications Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * remove secrets prefix; add failure threshold Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add hard-coded prefix Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * add comment Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * make secrets prefix a required param Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * move nim to flytekit plugin Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * update readme Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * update readme Signed-off-by: Samhita Alla <aallasamhita@gmail.com> * update readme Signed-off-by: Samhita Alla <aallasamhita@gmail.com> --------- Signed-off-by: Samhita Alla <aallasamhita@gmail.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: Jan Fiedler <jan@union.ai> Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> Co-authored-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: JackUrb <jack@datologyai.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
* set up array node Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * wip array node task wrapper Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * support function like callability Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * temp check in some progress on python func wrapper Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * only support launch plans in new array node class for now Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * add map task array node implementation wrapper Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * ArrayNode only supports LPs for now Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * support local execute for new array node implementation Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * add local execute unit tests for array node Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * set exeucution version in array node spec Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * check input types for local execute Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * remove code that is un-needed for now Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * clean up array node class Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * improve naming Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * clean up Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * utilize enum execution mode to set array node execution path Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * default execution mode to FULL_STATE for new array node class Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * support min_successes for new array node Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * add map task wrapper unit test Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * set min successes for array node map task wrapper Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * update docstrings Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * Install flyteidl from master in plugins tests Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> * lint Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * clean up min success/ratio setting Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * lint Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> * make array node class callable Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> --------- Signed-off-by: Paul Dittamo <pvdittamo@gmail.com> Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> Co-authored-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: Kevin Su <pingsutw@apache.org> Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> Signed-off-by: Future-Outlier <eric901201@gmail.com> Co-authored-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> Co-authored-by: Future-Outlier <eric901201@gmail.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
* Added alt prefix head to FlyteFile.new_remote Signed-off-by: pryce-turner <pryce.turner@gmail.com> * Added get_new_path method to FileAccessProvider, fixed new_remote method of FlyteFile Signed-off-by: pryce-turner <pryce.turner@gmail.com> * Updated tests and added new path creator to FlyteFile/Dir new_remote methods Signed-off-by: pryce-turner <pryce.turner@gmail.com> * Improved docstrings, fixed minor path sep bug, more descriptive naming, better test Signed-off-by: pryce-turner <pryce.turner@gmail.com> * Formatting Signed-off-by: pryce-turner <pryce.turner@gmail.com> --------- Signed-off-by: pryce-turner <pryce.turner@gmail.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: Kevin Su <pingsutw@apache.org> Signed-off-by: mao3267 <chenvincent610@gmail.com>
* Remove use of multiprocessing from the OAuth client Signed-off-by: Robert Deaton <robert.deaton@freenome.com> * Lint Signed-off-by: Robert Deaton <robert.deaton@freenome.com> --------- Signed-off-by: Robert Deaton <robert.deaton@freenome.com> Signed-off-by: mao3267 <chenvincent610@gmail.com>
cc @pingsutw Please help me review. In this PR, we have supported list[dataclass], dict[dataclass], and more nested dataclass types. However, since we haven't supported the conversion of dataclass with Flyte types members, now we also don't support other nested dataclass with Flyte Types. |
…dle-dataclass-default-value
from dataclasses import dataclass | ||
|
||
@dataclass | ||
class Datum: |
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.
Thank you! could we also add a few more tests?
- Another dataclass in the
Datum
- List of dataclass in the
Datum
- Flyte type in the dataclass (expect to see an error?)
- Add a nested dataclass in this test
# In python 3.7, 3.8, DataclassJson will deserialize Annotated[StructuredDataset, kwtypes(..)] to a dict, | ||
# so here we convert it back to the Structured Dataset. | ||
from flytekit.types.structured import StructuredDataset | ||
|
||
if python_val is None: |
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.
when will python_val
be None here? could we add a small test for it?
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.
When dataclass members of type typing.Dict
or typing.List
default to None
, this can lead to exceptions when iterating the list/dict from L552-588. We do need to add a test here.
@@ -307,9 +309,29 @@ def convert( | |||
|
|||
parsed_value = self._parse(value, param) | |||
|
|||
def has_nested_dataclass(t: typing.Type) -> bool: |
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.
Add some comment for this function. If I pass a dataclass (not flyte type) to this function, it will return True
here as well. That seems like not correct.
Signed-off-by: mao3267 <chenvincent610@gmail.com>
… None, and flyte type exceptions Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: mao3267 <chenvincent610@gmail.com>
Signed-off-by: mao3267 <chenvincent610@gmail.com>
…dle-dataclass-default-value
Signed-off-by: mao3267 <chenvincent610@gmail.com>
…dle-dataclass-default-value
Signed-off-by: Future-Outlier <eric901201@gmail.com>
if python_val is None: | ||
return None | ||
return [self._make_dataclass_serializable(v, get_args(python_type)[0]) for v in cast(list, python_val)] | ||
|
||
if hasattr(python_type, "__origin__") and get_origin(python_type) is dict: | ||
if python_val is None: | ||
return None |
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.
This is amazing, thank you for fixing this.
…_with_optional_fields Signed-off-by: Future-Outlier <eric901201@gmail.com>
if get_args(self._python_type) == (): | ||
return parsed_value |
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.
what is this for?
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.
comment added by Vincent.
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.
This is for native list and dict types, which don't have covariant types. Therefore, we can not index the return value from get_args
.
Signed-off-by: Future-Outlier <eric901201@gmail.com>
…ass, add comments Signed-off-by: mao3267 <chenvincent610@gmail.com>
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.
LGTM, thank you so much
Tracking issue
flyteorg/flyte#5569
Why are the changes needed?
We want to support typing.List[dataclass] and typing.Dict[dataclass] to fix the bug.
What changes were proposed in this pull request?
How was this patch tested?
Simple Tests in CLI:
Dict[str, dataclass]
List[dataclass]
Run on remote
Unit test
A new unit test
test_nested_dataclass_type
is added to check if it supports nested dataclass types and default values.Setup process
Check all the applicable boxes
Related PRs
None
Docs link
TODO