Conversion to time zone aware time series: example#634
Merged
Conversation
Collaborator
Author
|
Need to adjust the script to the simple thermal model, closing for now |
Collaborator
Author
|
Decided to add a |
Comment on lines
+201
to
+209
| if validate_points_alignment(session=session, ts_key=TS_KEYS[0]) == False: | ||
| fix_ts_1111(session) | ||
| convert_to_time_zone_aware(session, TS_KEYS[0]) | ||
| convert_to_time_zone_naive(session, TS_KEYS[0]) | ||
|
|
||
| if validate_points_alignment(session=session, ts_key=TS_KEYS[1]) == False: | ||
| fix_ts_2222(session) | ||
| convert_to_time_zone_aware(session, TS_KEYS[1]) | ||
| convert_to_time_zone_naive(session, TS_KEYS[1]) |
Collaborator
There was a problem hiding this comment.
I think this would be equivalent:
Suggested change
| if validate_points_alignment(session=session, ts_key=TS_KEYS[0]) == False: | |
| fix_ts_1111(session) | |
| convert_to_time_zone_aware(session, TS_KEYS[0]) | |
| convert_to_time_zone_naive(session, TS_KEYS[0]) | |
| if validate_points_alignment(session=session, ts_key=TS_KEYS[1]) == False: | |
| fix_ts_2222(session) | |
| convert_to_time_zone_aware(session, TS_KEYS[1]) | |
| convert_to_time_zone_naive(session, TS_KEYS[1]) | |
| fix_functions = { | |
| 1111: fix_ts_1111, | |
| 2222: fix_ts_2222, | |
| } | |
| for ts_key, fix_ts_points in fix_functions.items(): | |
| if validate_points_alignment(session, ts_key) == False: | |
| fix_ts_points(session) | |
| convert_to_time_zone_aware(session, ts_key) | |
| convert_to_time_zone_naive(session, ts_key) |
Comment on lines
+174
to
+181
| aligned = True | ||
| for timestamp in utc_time: | ||
| if timestamp.as_py().hour != DB_ZONE_MIDNIGHT_IN_UTC: | ||
| print( | ||
| f"Time series key {ts_key}: the timestamp {timestamp.as_py()} is not aligned to the DB time zone midnight" | ||
| ) | ||
| aligned = False | ||
| break |
Collaborator
There was a problem hiding this comment.
I think this is simpler:
Suggested change
| aligned = True | |
| for timestamp in utc_time: | |
| if timestamp.as_py().hour != DB_ZONE_MIDNIGHT_IN_UTC: | |
| print( | |
| f"Time series key {ts_key}: the timestamp {timestamp.as_py()} is not aligned to the DB time zone midnight" | |
| ) | |
| aligned = False | |
| break | |
| misaligned = next((timestamp for timestamp in utc_time if timestamp.as_py().hour != DB_ZONE_MIDNIGHT_IN_UTC), None) | |
| if misaligned: | |
| print(f"Time series key {ts_key}: the timestamp {timestamp.as_py()} is not aligned to the DB time zone midnight") | |
| return misaligned != None |
Collaborator
Author
There was a problem hiding this comment.
I think it's just more pythonic
tnoczyns-volue
approved these changes
Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an example script
Refers to https://github.com/Volue/energy-mesh/issues/8332