Skip to content

Conversation

Copy link

Copilot AI commented Nov 17, 2025

Addresses feedback from #1211: datetime comparisons in dataset lifecycle operations were mixing naive and timezone-aware datetime objects, causing inconsistent behavior.

Changes

  • dataset_lifecycle_ops.py: Changed datetime.now() to datetime.now(timezone.utc) for timezone-aware comparisons
  • test_dataset_lifecycle_ops.py: Updated test fixtures to use timezone-aware datetimes for consistency

Context

The last_updated field is set using datetime.now(tz=timezone.utc) in dataset_manager.py. Comparing it with a naive datetime from datetime.now() can fail or produce incorrect results depending on the Python version and database driver.

# Before
now = datetime.now()  # naive datetime
if _.last_updated and (now - _.last_updated) > delta:  # comparing naive with tz-aware

# After  
now = datetime.now(timezone.utc)  # timezone-aware datetime
if _.last_updated and (now - _.last_updated) > delta:  # consistent comparison

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: ponyisi <4177101+ponyisi@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on dataset cache purge cronjob PR Use timezone-aware datetime for dataset lifecycle comparisons Nov 17, 2025
Copilot AI requested a review from ponyisi November 17, 2025 20:06
Copilot finished work on behalf of ponyisi November 17, 2025 20:06
@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.10%. Comparing base (4d609d9) to head (adf1aec).
⚠️ Report is 1 commits behind head on dataset-cache-cleanup.

Additional details and impacted files
@@                    Coverage Diff                    @@
##           dataset-cache-cleanup    #1214      +/-   ##
=========================================================
+ Coverage                  86.04%   86.10%   +0.06%     
=========================================================
  Files                         95       95              
  Lines                       3261     3261              
  Branches                     373      373              
=========================================================
+ Hits                        2806     2808       +2     
+ Misses                       380      378       -2     
  Partials                      75       75              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ponyisi ponyisi marked this pull request as ready for review November 17, 2025 20:10
@ponyisi ponyisi merged commit 25d022e into dataset-cache-cleanup Nov 17, 2025
55 checks passed
@ponyisi ponyisi deleted the copilot/sub-pr-1211 branch November 17, 2025 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants