Skip to content

[ENH] Replace deprecated utcnow() invocations#1059

Open
peytondmurray wants to merge 1 commit intoconda-incubator:mainfrom
peytondmurray:1025-tz-deprecations
Open

[ENH] Replace deprecated utcnow() invocations#1059
peytondmurray wants to merge 1 commit intoconda-incubator:mainfrom
peytondmurray:1025-tz-deprecations

Conversation

@peytondmurray
Copy link
Contributor

Fixes #1025.

Description

This PR replaces all calls to datetime.datetime.utcnow() with datetime.datetime.now(tz=datetime.UTC) to avoid deprecation warnings.

Pull request checklist

  • Did you test this change locally?
  • Did you update the documentation (if required)?
  • Did you add/update relevant tests for this change (if required)?

@peytondmurray peytondmurray requested a review from soapy1 January 27, 2025 20:24
@netlify
Copy link

netlify bot commented Jan 27, 2025

Deploy Preview for conda-store canceled.

Name Link
🔨 Latest commit 7b034bf
🔍 Latest deploy log https://app.netlify.com/sites/conda-store/deploys/679807dbc94eb40008119fb6

@soapy1
Copy link
Contributor

soapy1 commented Jan 27, 2025

It looks like this won't work for python 3.10. From the test logs:

conda-store-worker-1  | [2025-01-27 20:27:50,453: ERROR/ForkPoolWorker-4] Task task_update_conda_channel[6a768418-841e-4606-8ea2-107a61e6e34b] raised unexpected: AttributeError("module 'datetime' has no attribute 'UTC'")
conda-store-worker-1  | Traceback (most recent call last):
conda-store-worker-1  |   File "/opt/conda/envs/conda-store-server/lib/python3.10/site-packages/celery/app/trace.py", line 453, in trace_task
conda-store-worker-1  |     R = retval = fun(*args, **kwargs)
conda-store-worker-1  |   File "/opt/conda/envs/conda-store-server/lib/python3.10/site-packages/celery/app/trace.py", line 736, in __protected_call__
conda-store-worker-1  |     return self.run(*args, **kwargs)
conda-store-worker-1  |   File "/opt/conda-store-server/conda_store_server/_internal/worker/tasks.py", line 190, in task_update_conda_channel
conda-store-worker-1  |     channel.update_packages(db, subdirs=settings.conda_platforms)
conda-store-worker-1  |   File "/opt/conda-store-server/conda_store_server/_internal/orm.py", line 719, in update_packages
conda-store-worker-1  |     self.last_update = datetime.datetime.now(tz=datetime.UTC)
conda-store-worker-1  | AttributeError: module 'datetime' has no attribute 'UTC'

Copy link
Contributor

@soapy1 soapy1 left a comment

Choose a reason for hiding this comment

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

🎠

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In review 👀

Development

Successfully merging this pull request may close these issues.

Fix deprecation warnings for datetime.datetime.utcnow

2 participants