feat(viewer): add recorded point colors and trajectory follow

This commit is contained in:
DCCONSTRUCTIONS
2026-07-23 13:33:08 +03:00
parent 9f712bf353
commit ecd95a22f0
16 changed files with 1218 additions and 36 deletions
+95
View File
@@ -37,6 +37,7 @@ from k1link.web.session_api import (
LayoutPutRequest,
RecordedBlueprintRequest,
RecordedPerceptionRequest,
RecordedPointColorsRequest,
ReplayRequest,
build_session_router,
)
@@ -1083,6 +1084,7 @@ def test_recorded_blueprint_endpoint_is_small_strict_and_session_scoped(
show_trajectory=True,
show_grid=False,
point_size=6.25,
color_mode="height",
palette="custom",
custom_color="#112233",
active_view="perception",
@@ -1091,6 +1093,7 @@ def test_recorded_blueprint_endpoint_is_small_strict_and_session_scoped(
show_detections_2d=True,
show_segmentation=True,
show_cuboids_3d=True,
follow_trajectory=True,
),
)
)
@@ -1104,6 +1107,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_settings[0].color_mode == "height"
assert observed_kwargs[0]["blueprint_session_id"] == "a" * 32
assert observed_kwargs[0]["active_view"] == "perception"
assert observed_kwargs[0]["view_reset_generation"] == 1
@@ -1111,6 +1115,7 @@ def test_recorded_blueprint_endpoint_is_small_strict_and_session_scoped(
assert observed_kwargs[0]["show_detections_2d"] is True
assert observed_kwargs[0]["show_segmentation"] is True
assert observed_kwargs[0]["show_cuboids_3d"] is True
assert observed_kwargs[0]["follow_trajectory"] is True
with pytest.raises(ValueError):
RecordedBlueprintRequest.model_validate(
@@ -1201,6 +1206,96 @@ def test_recorded_perception_endpoint_returns_one_complete_optional_overlay(
assert empty.status_code == 204
def test_recorded_point_color_endpoint_is_strict_and_forwards_confined_command(
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, str, str, str]] = []
class Provider:
def __call__(
self,
command: ReplayCommand,
*,
application_id: str,
recording_id: str,
color_mode: str,
palette: str,
custom_color: str,
) -> bytes:
calls.append(
(
command.session_id,
application_id,
recording_id,
color_mode,
palette,
custom_color,
)
)
return b"RRF2colors"
router = build_session_router(
store,
point_color_renderers={"nodedc.device.xgrids-lixelkity-k1": Provider()},
)
color_route = endpoint(
router,
"/api/v1/observation-sessions/{session_id}/point-colors.rrd",
"POST",
)
response = asyncio.run(
color_route(
session_id=session.name,
request=RecordedPointColorsRequest(
application_id="nodedc_mission_core_recorded",
recording_id="recording-001",
color_mode="distance",
palette="viridis",
custom_color="#112233",
),
)
)
assert response.body == b"RRF2colors"
assert response.media_type == "application/vnd.rerun.rrd"
assert response.headers["content-length"] == str(len(response.body))
assert len(calls) == 1
assert calls[0] == (
session.name,
"nodedc_mission_core_recorded",
"recording-001",
"distance",
"viridis",
"#112233",
)
unavailable_router = build_session_router(store)
unavailable_route = endpoint(
unavailable_router,
"/api/v1/observation-sessions/{session_id}/point-colors.rrd",
"POST",
)
with pytest.raises(HTTPException) as unavailable:
asyncio.run(
unavailable_route(
session_id=session.name,
request=RecordedPointColorsRequest(
application_id="nodedc_mission_core_recorded",
recording_id="recording-001",
color_mode="intensity",
palette="turbo",
custom_color="#35d7c1",
),
)
)
assert unavailable.value.status_code == 409
def test_session_router_exposes_opaque_recorded_media_manifest_and_ranges(
tmp_path: Path,
) -> None: