-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[2/n subset refactor] Make TimeWindowPartitionsDefinition serializable #17660
[2/n subset refactor] Make TimeWindowPartitionsDefinition serializable #17660
Conversation
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite. |
timezone: Optional[str] = None, | ||
end: Union[datetime, str, None] = 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.
we can't actually re-order args here because we don't require kwargs, so this change would break users.
for now, leaving this as is for a proof of concept
8a95de4
to
828e5a4
Compare
cc35ffe
to
27d3b83
Compare
828e5a4
to
3e7006e
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.
Agree that we are (unfortunately) somewhat locked in to the ordering of the fields on the __new__
method, but we should have free reign on reordering the fields of the underlying NamedTuple
to match the __new__
method rather than vice-versa, right?
@OwenKephart unfortunately I don't think adjusting the order of the named tuple fields will fix -- the I think the only way to fix this would be to change the placement of |
Would it be possible to remove that constraint, e.g. by adding an option to disable it? I think life will be way simpler if we can avoid introducing a new |
338e8b8
to
d264af4
Compare
Deploy preview for dagit-core-storybook ready! ✅ Preview Built with commit d264af4. |
Deploy preview for dagit-storybook ready! ✅ Preview Built with commit d264af4. |
d024b99
to
e9dc40f
Compare
d264af4
to
f320752
Compare
f320752
to
0b5fa15
Compare
92c25eb
to
af983ea
Compare
0b5fa15
to
d629763
Compare
af983ea
to
ecc6f42
Compare
d629763
to
322db16
Compare
3dad787
to
f0de555
Compare
if require_args_to_match_field_ordering: | ||
value_param = value_params[index] | ||
if value_param.name != field: | ||
error_msg = ( |
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.
@alangenfeld do you know if we can remove this check altogether? Looks like when rebuild named tuples during deserialization we use kwargs, so this might not be needed anymore
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.
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.
- might be better to rename the toggling bool to something along the lines of
cant_pickle
to more clearly advertise what opting out of the protection represents - probably want to put pickle round tripping under test to demonstrate that it is known to fail in whatever way it does (if possible make it fail clearly)
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 context here.
I renamed the param to is_pickleable
. I also overrode a __getstate__
method on TimeWindowPartitionsDefinition
that enables raising an error when attempting to pickle:
https://docs.python.org/3/library/pickle.html#handling-stateful-objects
f0de555
to
2cdad9c
Compare
2cdad9c
to
e97b5b2
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.
cool by me
This PR supports serializing
TimeWindowPartitionsDefinition
objects.whitelist_for_serdes
enforces a constraint where the arguments to__new__
must match the ordering of fields in the named tuple. This constraint is required to pack and unpack objects properly during pickling.Unfortunately this ordering doesn't match in
TimeWindowPartitionsDefinition
, and we can't reorder the fields without breaking users :( This PR loosens the ordering restriction via a newis_pickleable
arg, and raises an error when attempting to pickle aTimeWindowPartitionsDefinition
.