mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-22 14:51:13 +00:00
[AZ-526] Consolidate _iso_ts_from_clock into helpers/iso_timestamps
Closes cumulative review 46-48 F1 (Medium) + F3 (Low). Adds iso_ts_from_clock(clock) alongside iso_ts_now() in the Layer-1 helper; migrates four duplicate definitions in c2_vpr (net_vlad, ultra_vpr, _faiss_bridge) and c12_operator_orchestrator (operator_reloc_service). Output format flipped +00:00 -> Z to align with iso_ts_now() and the canonical FDR _TS fixture (FDR schema test passes unmodified). 18 helper AC tests + 186 sibling tests pass; ruff clean. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+2
-5
@@ -14,7 +14,6 @@ auto-retried. The operator decides when to re-issue.
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from gps_denied_onboard.clock import Clock
|
||||
from gps_denied_onboard.components.c12_operator_orchestrator._types import (
|
||||
@@ -31,6 +30,7 @@ from gps_denied_onboard.fdr_client.records import (
|
||||
CURRENT_SCHEMA_VERSION,
|
||||
FdrRecord,
|
||||
)
|
||||
from gps_denied_onboard.helpers.iso_timestamps import iso_ts_from_clock
|
||||
|
||||
__all__ = ["OperatorReLocService"]
|
||||
|
||||
@@ -165,10 +165,7 @@ class OperatorReLocService:
|
||||
)
|
||||
|
||||
def _iso_ts_from_clock(self) -> str:
|
||||
ns = int(self._clock.time_ns())
|
||||
seconds, fraction_ns = divmod(ns, 1_000_000_000)
|
||||
dt = datetime.fromtimestamp(seconds, tz=timezone.utc)
|
||||
return f"{dt.strftime('%Y-%m-%dT%H:%M:%S')}.{fraction_ns:09d}+00:00"
|
||||
return iso_ts_from_clock(self._clock)
|
||||
|
||||
|
||||
def _hint_to_payload(hint: ReLocHint) -> dict[str, object]:
|
||||
|
||||
@@ -48,6 +48,7 @@ from gps_denied_onboard.fdr_client.records import (
|
||||
CURRENT_SCHEMA_VERSION,
|
||||
FdrRecord,
|
||||
)
|
||||
from gps_denied_onboard.helpers.iso_timestamps import iso_ts_from_clock
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
@@ -304,14 +305,4 @@ class FaissBridge:
|
||||
)
|
||||
|
||||
def _iso_ts_from_clock(self) -> str:
|
||||
# Inlined here rather than importing a shared helper because every
|
||||
# other component that emits FDR records (c12, c11, c5) defines
|
||||
# the same one-liner locally — see meta-rule "Critical Thinking":
|
||||
# the duplication is intentional and trivial, factoring it would
|
||||
# add an L1 import every component already avoids.
|
||||
from datetime import datetime, timezone
|
||||
|
||||
ns = int(self._clock.time_ns())
|
||||
seconds, fraction_ns = divmod(ns, 1_000_000_000)
|
||||
dt = datetime.fromtimestamp(seconds, tz=timezone.utc)
|
||||
return f"{dt.strftime('%Y-%m-%dT%H:%M:%S')}.{fraction_ns:09d}+00:00"
|
||||
return iso_ts_from_clock(self._clock)
|
||||
|
||||
@@ -105,6 +105,9 @@ from gps_denied_onboard.fdr_client.records import (
|
||||
FdrRecord,
|
||||
)
|
||||
from gps_denied_onboard.helpers.descriptor_normaliser import DescriptorNormaliser
|
||||
from gps_denied_onboard.helpers.iso_timestamps import (
|
||||
iso_ts_from_clock as _iso_ts_from_clock,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from gps_denied_onboard._types.calibration import CameraCalibration
|
||||
@@ -372,17 +375,6 @@ class NetVladStrategy:
|
||||
)
|
||||
|
||||
|
||||
def _iso_ts_from_clock(clock: Clock) -> str:
|
||||
# Same shape every component uses for FDR timestamps; AZ-508 will
|
||||
# consolidate the duplicate helpers across c2/c11/c12/c6.
|
||||
from datetime import datetime, timezone
|
||||
|
||||
ns = int(clock.time_ns())
|
||||
seconds, fraction_ns = divmod(ns, 1_000_000_000)
|
||||
dt = datetime.fromtimestamp(seconds, tz=timezone.utc)
|
||||
return f"{dt.strftime('%Y-%m-%dT%H:%M:%S')}.{fraction_ns:09d}+00:00"
|
||||
|
||||
|
||||
def _build_pytorch_build_config(weights_path: Path) -> BuildConfig:
|
||||
del weights_path
|
||||
return BuildConfig(
|
||||
|
||||
@@ -84,6 +84,9 @@ from gps_denied_onboard.fdr_client.records import (
|
||||
FdrRecord,
|
||||
)
|
||||
from gps_denied_onboard.helpers.descriptor_normaliser import DescriptorNormaliser
|
||||
from gps_denied_onboard.helpers.iso_timestamps import (
|
||||
iso_ts_from_clock as _iso_ts_from_clock,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from gps_denied_onboard._types.calibration import CameraCalibration
|
||||
@@ -323,17 +326,6 @@ class UltraVprStrategy:
|
||||
)
|
||||
|
||||
|
||||
def _iso_ts_from_clock(clock: Clock) -> str:
|
||||
# Same shape every component uses for FDR timestamps; AZ-508 will
|
||||
# consolidate the duplicate helpers across c2/c11/c12/c6.
|
||||
from datetime import datetime, timezone
|
||||
|
||||
ns = int(clock.time_ns())
|
||||
seconds, fraction_ns = divmod(ns, 1_000_000_000)
|
||||
dt = datetime.fromtimestamp(seconds, tz=timezone.utc)
|
||||
return f"{dt.strftime('%Y-%m-%dT%H:%M:%S')}.{fraction_ns:09d}+00:00"
|
||||
|
||||
|
||||
def _build_trt_build_config() -> BuildConfig:
|
||||
return BuildConfig(
|
||||
precision=PrecisionMode.FP16,
|
||||
|
||||
Reference in New Issue
Block a user