-
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
Make run record datetime fields in UTC instead of naive datetimes, remove datetime_as_float #22818
Conversation
b8980a6
to
49238a4
Compare
@@ -271,16 +271,24 @@ def _add_filters_to_query(self, query: SqlAlchemyQuery, filters: RunsFilter) -> | |||
query = query.where(RunsTable.c.snapshot_id == filters.snapshot_id) | |||
|
|||
if filters.updated_after: | |||
query = query.where(RunsTable.c.update_timestamp > filters.updated_after) | |||
query = query.where( | |||
RunsTable.c.update_timestamp > filters.updated_after.replace(tzinfo=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 a pre-existing bug that this PR surfaced, if you didn't pass in a naive datetime we weren't passing it in correctly
return self._asdict()["create_timestamp"] | ||
|
||
@property | ||
def update_time(self) -> datetime: | ||
return self._asdict()["update_timestamp"] | ||
|
||
@property | ||
def start_timestamp(self) -> Optional[float]: | ||
return self._asdict()["start_time"] | ||
|
||
@property | ||
def end_timestamp(self) -> Optional[float]: | ||
return self._asdict()["end_time"] |
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.
why through _asdict
?
@property | ||
def create_time(self) -> datetime: | ||
return self._asdict()["create_timestamp"] | ||
|
||
@property | ||
def update_time(self) -> datetime: | ||
return self._asdict()["update_timestamp"] | ||
|
||
@property | ||
def start_timestamp(self) -> Optional[float]: | ||
return self._asdict()["start_time"] | ||
|
||
@property | ||
def end_timestamp(self) -> Optional[float]: | ||
return self._asdict()["end_time"] |
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 should probably be a comment somewhere in here about this time / timestamp flip flopping
should we like do serdes stuff to "correct" the model to the right way and then add the back compat accessors as deprecated?
49238a4
to
8785238
Compare
Took out the new fields on RunRecord since that's a whole other can of worms |
8785238
to
53b605c
Compare
….datetime_from_timestamp and move utc_datetime_from_naive into dagster._time Summary: Consolidating all the datetime utils into one place.
53b605c
to
5120be8
Compare
Summary:
This brings run records in OSS in line with run records that are returned over our API in that it has non-naive datetimes - UTC datetimes are strictly better than naive datetimes. It also allows us to remove this datetime_as_float utiliyt method which was designed as a way to reliably handle these naive datetimes coming out of sqlite - my claim is that the new syntax that I have replaced it with (utc_datetime_from_naive(...).timestamp()) is much clearer about what is going on.
Somewhat unfortunate that the field on RunRecord is "update_timestamp" and not "update_time", but that would be a breaking change.
Summary & Motivation
How I Tested These Changes