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

add datetime hashing for st.cache_data and st.cache_resource #6812

Merged
merged 5 commits into from Jun 21, 2023

Conversation

kajarenc
Copy link
Collaborator

@kajarenc kajarenc commented Jun 7, 2023

Describe your changes

Previously hashing of datetime objects happens via calling __reduce__, but that fails when datetime object was aware (containing information about the timezone).

This changes adding special hashing handling for DateTime objects, by converting them to isoformat(which contains information about timezone offset).

Please note that via that we lose information about the exact time zone in hashing, but information about UTC offset will be preserved. So e.g. same date-times with different timezones, but the same time stamp and offset will be hashed to the same value. Which should be fine in the vast majority of cases.

GitHub Issue Link #5110 , #6690

Testing Plan

  • Explanation of why no additional tests are needed
  • Unit Tests (JS and/or Python) DONE!
  • E2E Tests
  • Any manual testing needed?

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@kajarenc kajarenc marked this pull request as ready for review June 16, 2023 17:23
@tconkling tconkling self-requested a review June 21, 2023 15:47
Copy link
Contributor

@tconkling tconkling left a comment

Choose a reason for hiding this comment

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

This is great!

@kajarenc kajarenc merged commit 8f2d3ac into develop Jun 21, 2023
46 checks passed
@vdonato vdonato deleted the datetime-hashing branch November 1, 2023 23:58
eric-skydio pushed a commit to eric-skydio/streamlit that referenced this pull request Dec 20, 2023
…it#6812)

Previously hashing of datetime objects happens via calling __reduce__, but that fails when datetime object was aware (containing information about the timezone).

This changes adding special hashing handling for DateTime objects, by converting them to isoformat(which contains information about timezone offset).

Please note that via that we lose information about the exact time zone in hashing, but information about UTC offset will be preserved. So e.g. same date-times with different timezones, but the same time stamp and offset will be hashed to the same value. Which should be fine in the vast majority of cases.
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Mar 22, 2024
…it#6812)

Previously hashing of datetime objects happens via calling __reduce__, but that fails when datetime object was aware (containing information about the timezone).

This changes adding special hashing handling for DateTime objects, by converting them to isoformat(which contains information about timezone offset).

Please note that via that we lose information about the exact time zone in hashing, but information about UTC offset will be preserved. So e.g. same date-times with different timezones, but the same time stamp and offset will be hashed to the same value. Which should be fine in the vast majority of cases.
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Apr 16, 2024
…it#6812)

Previously hashing of datetime objects happens via calling __reduce__, but that fails when datetime object was aware (containing information about the timezone).

This changes adding special hashing handling for DateTime objects, by converting them to isoformat(which contains information about timezone offset).

Please note that via that we lose information about the exact time zone in hashing, but information about UTC offset will be preserved. So e.g. same date-times with different timezones, but the same time stamp and offset will be hashed to the same value. Which should be fine in the vast majority of cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants