-
Notifications
You must be signed in to change notification settings - Fork 244
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 mashumaro DataClassORJSONMixin #2080
Support mashumaro DataClassORJSONMixin #2080
Conversation
Thank you for opening this pull request! 🙌 These tips will help get your PR across the finish line:
|
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 for the PR!
For the CI to run, we need to add orjson
as a developer dependency in https://github.com/flyteorg/flytekit/blob/master/dev-requirements.in
As for testing, can you add a test that checks the expected behavior for your NumPy use case?
flytekit/core/type_engine.py
Outdated
@@ -24,6 +23,7 @@ | |||
from google.protobuf.struct_pb2 import Struct | |||
from marshmallow_enum import EnumField, LoadDumpOptions | |||
from mashumaro.mixins.json import DataClassJSONMixin | |||
from mashumaro.mixins.orjson import DataClassORJSONMixin |
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.
I prefer not to add orjson
as a hard dependency for flytekit
. Can you write the PR in way where orjson
is a soft dependency?
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 idea, orjson is a soft dependency now
Hi Thomas, thank you for your feedback! I will incorporate it. As for dev dependendies, we need both orjson and mashumaro>=3.11. What is the best way for me to specify a minimal version in the dev dependencies? |
👋 Hi, author of mashumaro here.
To avoid all possible unwanted changes made on false conclusions, I’d like to make a correction. |
Signed-off-by: Quinten Roets <quinten.roets@flawlessai.com>
6289151
to
afd5253
Compare
Hi @Fatal1ty! Thank you for reaching out and reminding me that The reason why I had mashumaro 3.11 in mind is because we internally use |
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.
Thanks for the update!
wider variety of attributes, including numpy arrays.
Does your NumPy array use case work out of the box after this PR? If so, can you add a test where a NumPy array is an attribute?
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #2080 +/- ##
==========================================
+ Coverage 82.58% 85.15% +2.56%
==========================================
Files 233 284 +51
Lines 19541 22197 +2656
Branches 3512 3520 +8
==========================================
+ Hits 16138 18901 +2763
+ Misses 2824 2686 -138
- Partials 579 610 +31 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Quinten Roets <quinten.roets@flawlessai.com>
Signed-off-by: Quinten Roets <quinten.roets@flawlessai.com>
Thank you for reviewing! Unfortunately, Numpy array attributes do not work out of the box. However, other attribute types like datetime do. I added a datetime attribute as an example in the tests. I hope that suffices to demonstrate the use case. Let me know if it does not! |
Signed-off-by: Quinten Roets <quinten.roets@flawlessai.com>
bbce66c
to
76bc91e
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.
Minor nits, but otherwise LGTM
Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
Congrats on merging your first pull request! 🎉 |
Thank you for the feedback and the help! |
Why are the changes needed?
The mashumaro
DataClassORJSONMixin
class works like the mashumaroDataClassJSONMixin
class. Additionally, it allows for serializing dataclasses with a wider variety of attributes types, including:Currently, flytekit does not yet support the
DataClassJSONMixin
class and throws an error when classes derived fromDataClassORJSONMixin
are serialized.What changes were proposed in this pull request?
This PR introduces support for classes derived from the mashumaro
DataClassORJSONMixins
class.How was this patch tested?
Added DataClassORJSONMixin instances in
test_type_engine.py
Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link