[Core feature] Allow dictionaries to be passed to execute workflows that take dataclasses#2013
Merged
Merged
Conversation
- Import the `json` module - Add a check for dictionary types in the `DataclassTransformer` class - Raise a `TypeTransformerFailedError` if a key in the dictionary does not match any field in the dataclass - Convert the dictionary to a JSON string using `json.dumps()` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Remove unnecessary code that checks if a key in the original dictionary matches a field in the dataclass Signed-off-by: jason.lai <jasonlai1218@gmail.com>
…e_engine.py - Import the `re` module in `test_type_engine.py` - Add a new test function `test_assert_dict_type` in `test_type_engine.py` - Define a dataclass `Args` in `test_assert_dict_type` function in `test_type_engine.py` - Test when `v` is a dictionary in `test_assert_dict_type` function in `test_type_engine.py` - Test when `v` is a dictionary but missing keys from dataclass in `test_assert_dict_type` function in `test_type_engine.py` - Test when `v` is a dictionary but has extra keys that are not in dataclass in `test_assert_dict_type` function in `test_type_engine.py` - Test when the type of value in the dictionary does not match the expected type in the dataclass in `test_assert_dict_type` function in `test_type_engine.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Add a new test `test_to_literal_dict` to `test_type_engine.py` - Implement logic to convert a Python dictionary to a literal type - Test the conversion when `python_val` is a dictionary - Test the conversion when `python_val` is not a dictionary or dataclass - Raise an exception when `python_val` is not a dictionary or dataclass with a specific error message Signed-off-by: jason.lai <jasonlai1218@gmail.com>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #2013 +/- ##
==========================================
- Coverage 85.70% 84.31% -1.40%
==========================================
Files 313 313
Lines 23364 23389 +25
Branches 3489 3499 +10
==========================================
- Hits 20025 19720 -305
- Misses 2733 3089 +356
+ Partials 606 580 -26 ☔ View full report in Codecov by Sentry. |
pingsutw
reviewed
Nov 30, 2023
…se errors properly - Modify the `to_literal` method in `flytekit/core/type_engine.py` - Add a condition to handle dictionaries in the `to_literal` method - Parse the JSON string and return a `Literal` object - Raise an error if the input is not a dataclass Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Raise the amount of returned recordings from `10` to `100` - Fix a typo in the github action name - Move the `octokit` initialization to a separate file - Add an OpenAI API for completions - Lower numeric tolerance for test files - Add 2 tests for the inclusive string split function Signed-off-by: jason.lai <jasonlai1218@gmail.com>
pingsutw
reviewed
Dec 16, 2023
…would be "refactor". This is because the changes involve adding and removing imports, which do not fix a bug or add a new feature, but rather modify the code structure.: refactor import statements in core and test files - Add `import json` to `flytekit/core/type_engine.py` - Remove `import json` from `flytekit/core/type_engine.py` - Add `import re` to `tests/flytekit/unit/core/test_type_engine.py` - Remove `import re` from `tests/flytekit/unit/core/test_type_engine.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
pingsutw
previously approved these changes
Dec 21, 2023
pingsutw
left a comment
Member
There was a problem hiding this comment.
Thanks @jasonlai1218. Could you resolve the merge conflict?
Merge branch 'master' into dataclass-execution-fix Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Add `import pandas as pd` to the test file Signed-off-by: jason.lai <jasonlai1218@gmail.com>
Contributor
Author
|
updated |
pingsutw
previously approved these changes
Dec 22, 2023
…tements in test files - Remove import of `pandas` from `test_type_engine.py` - Add import of `pandas` to `test_assert_dict_type()` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
pingsutw
approved these changes
Dec 22, 2023
pryce-turner
pushed a commit
that referenced
this pull request
Dec 26, 2023
…hat take dataclasses (#2013) Signed-off-by: jason.lai <jasonlai1218@gmail.com> Signed-off-by: pryce-turner <pryce.turner@gmail.com>
2 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Tracking issue
flyteorg/flyte#4098
Docs link
Describe your changes
jsonmoduleDataclassTransformerclassTypeTransformerFailedErrorif a key in the dictionary does not match any field in the dataclassjson.dumps()Check all the applicable boxes
Setup Process
data_class2.pyregister data_class2.py
execute cmd:
pyflyte register -p flytesnacks --domain development --version 4 data_class2.pywrite a
remote_wf2.pyand execute the program
Screenshots
Successful screenshot
FlyteFile
flytefile_data_class.pyregister flytefile_data_class.py
pyflyte register -p flytesnacks --domain development --version 1 flytefile_data_class.pywrite a
flytefile_remote_wf.pyand execute the program
Screenshots
Successful screenshot
StructuredDataset
structureddataset_data_class.pyregister flytefile_data_class.py
pyflyte register -p flytesnacks --domain development --version 1 structureddataset_data_class.pyupload parquet file to minio

write a
structureddataset_remote_wf.pyand execute the program
Screenshots
Successful screenshot
If the user configures the settings incorrectly, a screenshot of the error should be displayed
Scenario 1: Parameter type error
Scenario 2: Wrong field name
Note to reviewers
Related PRs