DataBiosphere / azul

Metadata indexer and query service used for AnVIL, HCA, LungMAP, and CGP
Apache License 2.0
7 stars 2 forks source link

DeprecationWarning for datetime methods in Python 3.12 #5953

Open dsotirho-ucsc opened 7 months ago

dsotirho-ucsc commented 7 months ago

Upgrading to Python 3.12 (https://github.com/DataBiosphere/azul/issues/5736) introduces DeprecationWarning with the datetime methods utcnow and utcfromtimestamp.

https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

Warning Because naive datetime objects are treated by many datetime methods as local times, it is preferred to use aware datetimes to represent times in UTC. As such, the recommended way to create an object representing the current time in UTC is by calling datetime.now(timezone.utc). Deprecated since version 3.12: Use datetime.now() with UTC instead.

https://docs.python.org/3/library/datetime.html#datetime.datetime.utcfromtimestamp

Warning Because naive datetime objects are treated by many datetime methods as local times, it is preferred to use aware datetimes to represent times in UTC. As such, the recommended way to create an object representing a specific timestamp in UTC is by calling datetime.fromtimestamp(timestamp, tz=timezone.utc). Deprecated since version 3.12: Use datetime.fromtimestamp() with UTC instead.

datetime.utcnow was found in Azul's codebase and will need to be updated.

In addition, the following imported dependencies were also found to make use of the deprecated datetime methods:

Blocked by:


dsotirho-ucsc commented 7 months ago

@hannes-ucsc: "Update moto and google-api-core as part of #5736 if that is easy to do. Link to blocking boto/botocore ticket in description. We will park this until those are resolved at which point we will also update our own code. According to the botocore team, the removal of utcnow() et al is slated for Python 3.16 so we have some time."

achave11-ucsc commented 7 months ago

This is parked because blocker is parked.