refactor(perception): isolate detector runtime

This commit is contained in:
DCCONSTRUCTIONS
2026-08-05 16:05:26 +03:00
parent 8e161a197f
commit 8bd632509e
14 changed files with 81 additions and 263 deletions
+5 -5
View File
@@ -11,11 +11,6 @@ import numpy as np
import pytest
from numpy.typing import NDArray
from k1link.compute.yolox_object_detector import (
YOLOX_CONFIG_SHA256,
YOLOX_MODEL_SHA256,
YOLOX_VALID_FOV_SHA256,
)
from k1link.perception.contracts import (
ClockBasis,
ModalityOutcome,
@@ -34,6 +29,11 @@ from k1link.perception.detector_replay_result import (
require_m4_detector_replay_acceptance,
)
from k1link.perception.providers import SourcePacket
from k1link.perception.yolox_object_detector import (
YOLOX_CONFIG_SHA256,
YOLOX_MODEL_SHA256,
YOLOX_VALID_FOV_SHA256,
)
class _Source:
+30
View File
@@ -19,6 +19,20 @@ REPOSITORY_ROOT = Path(__file__).resolve().parents[1]
PERCEPTION_ROOT = REPOSITORY_ROOT / "src" / "k1link" / "perception"
BASELINE_PATH = REPOSITORY_ROOT / "config" / "perception" / "m4-recorded-realtime-baseline-v1.json"
REUSE_PATH = REPOSITORY_ROOT / "config" / "perception" / "m4-reuse-inventory-v1.json"
DETECTOR_RUNTIME_MODULES = (
"__init__.py",
"baseline.py",
"contracts.py",
"detector.py",
"detector_replay.py",
"detector_replay_cli.py",
"detector_replay_contracts.py",
"detector_replay_result.py",
"detector_replay_validation.py",
"providers.py",
"recorded_source.py",
"yolox_object_detector.py",
)
def _imports(path: Path) -> set[str]:
@@ -151,6 +165,22 @@ def test_perception_contracts_import_no_compute_lab_graph_or_web_module() -> Non
assert forbidden == set()
def test_perception_package_initializer_is_side_effect_free() -> None:
assert _imports(PERCEPTION_ROOT / "__init__.py") == set()
def test_detector_runtime_closure_imports_no_legacy_compute_package() -> None:
violations = {
name: sorted(
module
for module in _imports(PERCEPTION_ROOT / name)
if module.startswith("k1link.compute")
)
for name in DETECTOR_RUNTIME_MODULES
}
assert {name: modules for name, modules in violations.items() if modules} == {}
def test_new_perception_boundary_has_no_experiment_specific_imports() -> None:
violations: dict[str, str] = {}
for path in PERCEPTION_ROOT.glob("*.py"):
+8 -8
View File
@@ -9,14 +9,6 @@ import numpy as np
import pytest
from numpy.typing import NDArray
from k1link.compute.yolox_object_detector import (
FrozenYoloxConfig,
TritonHttpInferenceBackend,
YoloxDetection,
YoloxDetectorError,
postprocess_yolox,
preprocess_raw_kb4,
)
from k1link.perception.contracts import (
ClockBasis,
ModalityOutcome,
@@ -31,6 +23,14 @@ from k1link.perception.detector import (
proposals_from_detections,
)
from k1link.perception.providers import SourcePacket
from k1link.perception.yolox_object_detector import (
FrozenYoloxConfig,
TritonHttpInferenceBackend,
YoloxDetection,
YoloxDetectorError,
postprocess_yolox,
preprocess_raw_kb4,
)
REPOSITORY_ROOT = Path(__file__).resolve().parents[1]
E46J_FRAMES = (