From 1e893dcd080da1e8e063061a2676e4734c74fc3a Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Thu, 9 Jan 2025 16:49:06 +0000 Subject: [PATCH 1/3] fix: handle deprecation of datetime.utcnow() --- binderhub/events.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/binderhub/events.py b/binderhub/events.py index 02fa730e6..37a6ad957 100644 --- a/binderhub/events.py +++ b/binderhub/events.py @@ -4,7 +4,7 @@ import json import logging -from datetime import datetime +import datetime import jsonschema from jupyterhub.traitlets import Callable @@ -98,8 +98,9 @@ def emit(self, schema_name, version, event): schema = self.schemas[(schema_name, version)] jsonschema.validate(event, schema) + now_utc = datetime.datetime.now(tz=datetime.timezone.utc) capsule = { - "timestamp": datetime.utcnow().isoformat() + "Z", + "timestamp": now_utc.isoformat() + "Z", "schema": schema_name, "version": version, } From 4385e8d8a11d8683ae5a9b1e94cccd459910a8b3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:51:28 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- binderhub/events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binderhub/events.py b/binderhub/events.py index 37a6ad957..d0f9289fa 100644 --- a/binderhub/events.py +++ b/binderhub/events.py @@ -2,9 +2,9 @@ Emit structured, discrete events when various actions happen. """ +import datetime import json import logging -import datetime import jsonschema from jupyterhub.traitlets import Callable From 1fdc709bdbd9fe327297a37e90aca5c503c03756 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Thu, 23 Jan 2025 09:50:26 +0000 Subject: [PATCH 3/3] fix: use strformat to preserve formatting --- binderhub/events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binderhub/events.py b/binderhub/events.py index d0f9289fa..310be3452 100644 --- a/binderhub/events.py +++ b/binderhub/events.py @@ -100,7 +100,7 @@ def emit(self, schema_name, version, event): now_utc = datetime.datetime.now(tz=datetime.timezone.utc) capsule = { - "timestamp": now_utc.isoformat() + "Z", + "timestamp": now_utc.strftime("%Y-%m-%dT%H:%M:%S.%fZ"), "schema": schema_name, "version": version, }