From 5d1a11f19aa61031f71026d34c63f313e4711951 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 19:58:16 +0000 Subject: [PATCH 1/2] Initial plan From adf1aec9f763531f17d138b13ee0f347fd4d9809 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 20:03:40 +0000 Subject: [PATCH 2/2] Use timezone-aware datetime for dataset lifecycle ops Co-authored-by: ponyisi <4177101+ponyisi@users.noreply.github.com> --- .../resources/internal/dataset_lifecycle_ops.py | 4 ++-- .../resources/internal/test_dataset_lifecycle_ops.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/servicex_app/servicex_app/resources/internal/dataset_lifecycle_ops.py b/servicex_app/servicex_app/resources/internal/dataset_lifecycle_ops.py index d984162c..a3dffe5d 100644 --- a/servicex_app/servicex_app/resources/internal/dataset_lifecycle_ops.py +++ b/servicex_app/servicex_app/resources/internal/dataset_lifecycle_ops.py @@ -25,7 +25,7 @@ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from flask import request, current_app @@ -39,7 +39,7 @@ def post(self): """ Obsolete cached datasets older than N hours """ - now = datetime.now() + now = datetime.now(timezone.utc) try: age = float(request.get_json().get("age", 24)) except Exception: diff --git a/servicex_app/servicex_app_test/resources/internal/test_dataset_lifecycle_ops.py b/servicex_app/servicex_app_test/resources/internal/test_dataset_lifecycle_ops.py index 800a6b4d..b08ca755 100644 --- a/servicex_app/servicex_app_test/resources/internal/test_dataset_lifecycle_ops.py +++ b/servicex_app/servicex_app_test/resources/internal/test_dataset_lifecycle_ops.py @@ -25,7 +25,7 @@ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from datetime import datetime +from datetime import datetime, timezone from unittest.mock import patch from pytest import fixture @@ -43,8 +43,8 @@ def fake_dataset_list(self): ) as dsfunc: dsfunc.return_value = [ Dataset( - last_used=datetime(2022, 1, 1), - last_updated=datetime(2022, 1, 1), + last_used=datetime(2022, 1, 1, tzinfo=timezone.utc), + last_updated=datetime(2022, 1, 1, tzinfo=timezone.utc), id=1, name="not-orphaned", events=100, @@ -54,8 +54,8 @@ def fake_dataset_list(self): did_finder="rucio", ), Dataset( - last_used=datetime.now(), - last_updated=datetime.now(), + last_used=datetime.now(timezone.utc), + last_updated=datetime.now(timezone.utc), id=2, name="orphaned", events=100,