-
Notifications
You must be signed in to change notification settings - Fork 27
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
WIP: ♻️ adding UTC timezone to the project #3912
WIP: ♻️ adding UTC timezone to the project #3912
Conversation
Kudos, SonarCloud Quality Gate passed!
|
Codecov Report
@@ Coverage Diff @@
## master #3912 +/- ##
========================================
+ Coverage 83.4% 84.8% +1.3%
========================================
Files 933 847 -86
Lines 40063 37269 -2794
Branches 839 538 -301
========================================
- Hits 33436 31611 -1825
+ Misses 6406 5519 -887
+ Partials 221 139 -82
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…hub.com:matusdrobuliak66/osparc-simcore into maintenance/propagating-UTC-timezone-everywhere
…hub.com:matusdrobuliak66/osparc-simcore into maintenance/propagating-UTC-timezone-everywhere
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.
Ok I am not sure I understand this now.
I see you replaced utcnow() by now(timezone.utc).replace(tzinfo=None) correct?
but this does not make the time timezone aware or am I missing something?
# TODO: use dict for deep include/exclude! SEE https://pydantic-docs.helpmanual.io/usage/exporting_models/ | ||
|
||
if include is None: | ||
include = set(f.name for f in model_fields) | ||
include = {f.name for f in model_fields} |
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.
is this done automatically or you had to change manually?
small test. Let's discuss that tomorrow: import datetime
t = datetime.now()
t_aware = datetime.datetime.now(datetime.timezone.utc)
print(t)
print(t_aware)
print(t_aware.replace(tzinfo=None))
print(datetime.datetime.utcnow()) --> 2023-02-23 18:51:32.492593
2023-02-23 17:52:05.490572+00:00
2023-02-23 17:52:05.490572
2023-02-23 17:54:45.181448 |
@sanderegg I think this was requested by this comment: #3790 (comment) Update: I will make all the datetime "aware" of the timezone |
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.
You have 2 styles of replacement, which confuse me a bit:
.now(timezone.utc).replace(tzinfo=None)
.now(timezone.utc)
Why is it not the same everywhere?
NOTE: I have only comment on a few of them then I stopped.
@@ -23,7 +23,7 @@ | |||
status_code=status.HTTP_200_OK, | |||
) | |||
async def get_service_alive(): | |||
return f"{__name__}@{datetime.utcnow().isoformat()}" | |||
return f"{__name__}@{datetime.now(timezone.utc).isoformat()}" |
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.
no replace timezone here?
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.
Places, where the .repace(tzinfo=None) was added, were necessary because we later worked with the datetime that needed the format without tzinfo included inside. In the other cases (where .repace(tzinfo=None) was not included) it probably wasn't needed and it was ok to work with tzinfo included there (at least the unit tests were not complaining). But I can add it everywhere to be consistent if needed.
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.
maybe also check the feedback from @sanderegg about this, I see that he also has some doubts.
In theory I would prefer to be working with UTC times all across the place, if possible. I'm not sure if this is doable though.
services/director-v2/src/simcore_service_director_v2/api/routes/health.py
Show resolved
Hide resolved
services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_runs.py
Show resolved
Hide resolved
services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_runs.py
Show resolved
Hide resolved
services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_tasks.py
Show resolved
Hide resolved
services/invitations/src/simcore_service_invitations/api/_invitations.py
Show resolved
Hide resolved
Code Climate has analyzed commit 1da531d and detected 1 issue on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
Kudos, SonarCloud Quality Gate passed!
|
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.
Is this draft (WIP) or should I review ? :-)
Still work in progress. But I would welcome a consultation when you will have time. |
What do these changes do?
Adding timezone.utc to the whole repository. Now we will represent current time by the UTC time zone.
![image](https://user-images.githubusercontent.com/60785969/220845447-5680e891-8c77-438d-8e21-606a4ded6db3.png)
Related issue/s
How to test
Checklist