-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Clarify SerializableTimeDelta is for internal use only in docstring
#29492
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
Clarify SerializableTimeDelta is for internal use only in docstring
#29492
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
SerializableTimeDelta
|
agreed that this stuff is very confusing but generally would prefer for SerializableTimeDeltas to not really make their way into our application code -- basically I think they should be thought of as purely an implementation detail and code that interacts with them should basically always do so by accessing a property that does the conversion for you on the class that has SerializableTimeDelta values. do you have the example where in code this specific bug came up? just trying to visualize the scenario a bit better |
|
The exact example I laid out in the PR description (trying to get timedelta duration for a 24 hour SerializableTimeDelta) caused a bug with asset freshness evaluation, where basically every asset in Hear you on not using
|
|
If we don't want |
smackesey
left a comment
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.
Strong agree with @OwenKephart that we don't want SerializableTimeDelta in application code. Any place it pops up it should be turned into a regular timedelta.
- remove total_seconds() helper method added in this PR
- add a helper or properties on TimeWindowFreshnessPolicy to convert fail_window and warn_window from SerializableTimeDelta to plain old timedelta for us
Yes ^^
OwenKephart
left a comment
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.
req'ing changes for queue management but yeah I think that we're on the same page here -- in fact I think we really want to rename the fields fail_window and warn_window to serializable_fail_window and serializable_warn_window to make room for the fail_window and warn_window properties to be the "correct" properties to set. my bad on missing that on the initial round of reviews
that might have some backcompat implications for our internal users if these things are already getting serialized, we can talk through the pros/cons of some different approaches but if it's just Nick using these right now we could probably just wrap the current deserialization callsite in a try/except so that we ignore deserialization errors. this would mean that:
- when we merge this in and push to cloud, all existing freshness policies would be disabled (but no errors would occur)
- once Nick updates the dagster version, freshness policies would get turned back on.
it's possible to avoid turning freshness policies off in (1) with some extra effort, it's just mildly complicated to do this in a way that doesn't have us serializing the old storage names forever so it might be nice to avoid that extra work if the above series of events is acceptable
|
I think it's acceptable to turn off freshness for a day or so, as long as we give Roach a heads up. I will stack a separate PR for the field renaming. |
SerializableTimeDeltaSerializableTimeDelta
SerializableTimeDeltaSerializableTimeDelta is for internal usage only in docstring
SerializableTimeDelta is for internal usage only in docstringSerializableTimeDelta is for internal use only in docstring
Merge activity
|

Summary & Motivation
[EDIT 04/23] - based on PR feedback, limiting this PR to docstring only, will remove direct usages of
SerializableTimeDeltain cloud code.I ran into a pretty subtle "bug" with
SerializableTimeDelta- or an accessibility issue, really - when trying to use it for some datetime arithmetic. This PR adds some docstrings and atotal_seconds()method as guardrails to hopefully make it less likely to bite someone else in future.Let's say you create a
SerializableTimeDeltafrom adatetime.timedeltathat is 24 hours long:If you now want to get the duration of
serializable_tdin seconds, you may naturally reach for thesecondsattribute. You would expect this to equal 86,400 seconds. However, this is not the case - it would actually be 0!So I added atotal_seconds()method that is pass through todatetime.timedelta.total_secondsand some docstrings warning not to use thedays,secondsormicrosecondsproperties for any datetime arithmetic.How I Tested These Changes
bk
Changelog