feat(perception): project recorded results into Rerun

This commit is contained in:
DCCONSTRUCTIONS
2026-07-19 17:39:13 +03:00
parent 31fc4f6567
commit 2b53168149
13 changed files with 1328 additions and 8 deletions
+66
View File
@@ -35,6 +35,7 @@ from k1link.web.camera_archive import CameraArchiveWriter
from k1link.web.session_api import (
LayoutPutRequest,
RecordedBlueprintRequest,
RecordedPerceptionRequest,
ReplayRequest,
build_session_router,
)
@@ -1036,9 +1037,11 @@ def test_recorded_blueprint_endpoint_is_small_strict_and_session_scoped(
store = SessionStore(repository, data_dir=tmp_path / "data")
store.reconcile_archive(xgrids_k1_archive_source(sessions))
observed_settings: list[RerunSceneSettings] = []
observed_kwargs: list[dict[str, Any]] = []
def capture_settings(settings: RerunSceneSettings, **kwargs: Any) -> bytes:
observed_settings.append(settings)
observed_kwargs.append(kwargs)
return recorded_blueprint_rrd(settings, **kwargs)
monkeypatch.setattr(
@@ -1065,6 +1068,7 @@ def test_recorded_blueprint_endpoint_is_small_strict_and_session_scoped(
point_size=6.25,
palette="custom",
custom_color="#112233",
active_view="perception",
),
)
)
@@ -1078,6 +1082,7 @@ def test_recorded_blueprint_endpoint_is_small_strict_and_session_scoped(
assert len(observed_settings) == 1
assert observed_settings[0].show_points is False
assert observed_settings[0].show_trajectory is True
assert observed_kwargs[0]["active_view"] == "perception"
with pytest.raises(ValueError):
RecordedBlueprintRequest.model_validate(
@@ -1106,6 +1111,67 @@ def test_recorded_blueprint_endpoint_is_small_strict_and_session_scoped(
assert missing.value.status_code == 404
def test_recorded_perception_endpoint_returns_one_complete_optional_overlay(
tmp_path: Path,
) -> None:
repository = tmp_path / "repo"
sessions = repository / "sessions"
session = make_legacy_session(sessions, "20260716T205632Z_viewer_live")
store = SessionStore(repository, data_dir=tmp_path / "data")
store.reconcile_archive(xgrids_k1_archive_source(sessions))
calls: list[tuple[str, str, str]] = []
class Provider:
def render(
self,
session_id: str,
*,
application_id: str,
recording_id: str,
) -> bytes:
calls.append((session_id, application_id, recording_id))
return b"RRF2perception"
router = build_session_router(store, perception_overlay_provider=Provider())
perception_route = endpoint(
router,
"/api/v1/observation-sessions/{session_id}/perception.rrd",
"POST",
)
response = asyncio.run(
perception_route(
session_id=session.name,
request=RecordedPerceptionRequest(
application_id="nodedc_mission_core_recorded",
recording_id="recording-001",
),
)
)
assert response.body == b"RRF2perception"
assert response.media_type == "application/vnd.rerun.rrd"
assert response.headers["content-length"] == str(len(response.body))
assert calls == [
(session.name, "nodedc_mission_core_recorded", "recording-001")
]
empty_router = build_session_router(store)
empty_route = endpoint(
empty_router,
"/api/v1/observation-sessions/{session_id}/perception.rrd",
"POST",
)
empty = asyncio.run(
empty_route(
session_id=session.name,
request=RecordedPerceptionRequest(
application_id="nodedc_mission_core_recorded",
recording_id="recording-001",
),
)
)
assert empty.status_code == 204
def test_session_router_exposes_opaque_recorded_media_manifest_and_ranges(
tmp_path: Path,
) -> None: