Skip to content
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

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

gibsondan
Copy link
Member

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

@gibsondan gibsondan force-pushed the runrecorddatetime branch 5 times, most recently from b8980a6 to 49238a4 Compare July 2, 2024 19:26
@@ -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)
Copy link
Member Author

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

Comment on lines 614 to 626
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"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why through _asdict ?

Comment on lines 612 to 626
@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"]
Copy link
Member

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?

@gibsondan
Copy link
Member Author

Took out the new fields on RunRecord since that's a whole other can of worms

@gibsondan gibsondan changed the base branch from master to utilstotime July 2, 2024 21:05
Base automatically changed from utilstotime to master July 3, 2024 00:55
….datetime_from_timestamp and move utc_datetime_from_naive into dagster._time

Summary:
Consolidating all the datetime utils into one place.
@gibsondan gibsondan merged commit 473b545 into master Jul 3, 2024
1 check failed
@gibsondan gibsondan deleted the runrecorddatetime branch July 3, 2024 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants