diff --git a/src/neptune_scale/api/attribute.py b/src/neptune_scale/api/attribute.py index 2d74d39..643f25c 100644 --- a/src/neptune_scale/api/attribute.py +++ b/src/neptune_scale/api/attribute.py @@ -2,7 +2,10 @@ import itertools import threading import warnings -from datetime import datetime +from datetime import ( + datetime, + timezone, +) from typing import ( Any, Callable, @@ -95,7 +98,7 @@ def log( if timestamp is None: timestamp = datetime.now() elif isinstance(timestamp, (float, int)): - timestamp = datetime.fromtimestamp(timestamp) + timestamp = datetime.fromtimestamp(timestamp, timezone.utc) with self._lock: self._verify_and_update_metrics_state(step, metrics) diff --git a/tests/unit/test_attribute.py b/tests/unit/test_attribute.py index 389e1ac..29f32ef 100644 --- a/tests/unit/test_attribute.py +++ b/tests/unit/test_attribute.py @@ -1,3 +1,4 @@ +import time from datetime import datetime from unittest.mock import Mock @@ -68,8 +69,9 @@ def test_tags(run, store): def test_series(run, store): - run["my/series"].append(1, step=1, timestamp=10) - store.log.assert_called_with(metrics={"my/series": 1}, step=1, timestamp=10) + timestamp = time.time() + run["my/series"].append(1, step=1, timestamp=timestamp) + store.log.assert_called_with(metrics={"my/series": 1}, step=1, timestamp=timestamp) run["my/series"].append({"foo": 1, "bar": 2}, step=2) store.log.assert_called_with(metrics={"my/series/foo": 1, "my/series/bar": 2}, step=2, timestamp=None)