perf(lab): stream sealed spatial playback tracks
This commit is contained in:
@@ -8,7 +8,10 @@ from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
|
||||
from k1link.laboratory.m49_tgs_full_shadow import seal_m49_tgs_full_shadow
|
||||
from k1link.laboratory.m49_tgs_full_shadow import (
|
||||
M49TgsFullShadowResult,
|
||||
seal_m49_tgs_full_shadow,
|
||||
)
|
||||
from k1link.web import m49_tgs_full_shadow_api as full_shadow_api
|
||||
|
||||
REPOSITORY_ROOT = Path(__file__).resolve().parents[1]
|
||||
@@ -96,24 +99,34 @@ def test_full_shadow_seal_binds_visual_and_semantic_timelines(tmp_path: Path) ->
|
||||
"files": files,
|
||||
}
|
||||
(source / "result.json").write_text(json.dumps(worker), encoding="utf-8")
|
||||
(source / "worker-summary.json").write_text(json.dumps({
|
||||
"schema_version": "missioncore.m49-tgs-full-shadow-worker-summary/v1",
|
||||
"gpu_requested": False,
|
||||
"aos_used": False,
|
||||
"all_timeline_frames_accounted": True,
|
||||
"all_eligible_points_accounted": True,
|
||||
"canonical_triton_health": "healthy",
|
||||
"canonical_triton_id": "triton",
|
||||
"wall_seconds": 1.0,
|
||||
}), encoding="utf-8")
|
||||
(source / "worker-summary.json").write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"schema_version": "missioncore.m49-tgs-full-shadow-worker-summary/v1",
|
||||
"gpu_requested": False,
|
||||
"aos_used": False,
|
||||
"all_timeline_frames_accounted": True,
|
||||
"all_eligible_points_accounted": True,
|
||||
"canonical_triton_health": "healthy",
|
||||
"canonical_triton_id": "triton",
|
||||
"wall_seconds": 1.0,
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
profile = tmp_path / "profile.json"
|
||||
profile.write_text(json.dumps({
|
||||
"schema_version": "missioncore.m49-tgs-full-shadow-profile/v1",
|
||||
"profile_id": "test",
|
||||
"profile": {"history_seconds": 1.0},
|
||||
"costmap": {"state_priority": ["NONGROUND_OCCUPIED"]},
|
||||
"state_codes": {"UNOBSERVED": 0},
|
||||
}), encoding="utf-8")
|
||||
profile.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"schema_version": "missioncore.m49-tgs-full-shadow-profile/v1",
|
||||
"profile_id": "test",
|
||||
"profile": {"history_seconds": 1.0},
|
||||
"costmap": {"state_priority": ["NONGROUND_OCCUPIED"]},
|
||||
"state_codes": {"UNOBSERVED": 0},
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
visual = "m4-threat-replay-" + "d" * 64
|
||||
semantic = "e47-semantic-slam-" + "e" * 64
|
||||
|
||||
@@ -176,3 +189,35 @@ def test_full_shadow_chunk_contract_keeps_missing_lidar_unobserved(
|
||||
assert len(payload["costmap"]["centers_xy_m"]) == 2244
|
||||
assert payload["frames"][1]["sample_available"] is False
|
||||
assert set(payload["frames"][1]["states"]) == {0}
|
||||
|
||||
|
||||
def test_full_shadow_playback_manifest_exposes_sealed_binary_tracks(tmp_path: Path) -> None:
|
||||
names = {descriptor[0] for descriptor in full_shadow_api.PLAYBACK_TRACKS.values()}
|
||||
artifacts = [
|
||||
{
|
||||
"path": name,
|
||||
"byte_length": index + 10,
|
||||
"sha256": f"{index + 1:064x}",
|
||||
}
|
||||
for index, name in enumerate(sorted(names))
|
||||
]
|
||||
result = M49TgsFullShadowResult(
|
||||
"m49-tgs-full-shadow-" + "a" * 64,
|
||||
tmp_path,
|
||||
{"artifacts": artifacts},
|
||||
{},
|
||||
)
|
||||
|
||||
payload = full_shadow_api._playback_manifest(result)
|
||||
|
||||
assert payload["schema_version"] == "missioncore.m49-tgs-full-shadow-playback/v1"
|
||||
assert payload["frame_count"] == 4489
|
||||
assert payload["cell_count"] == 2244
|
||||
assert payload["total_byte_length"] == sum(item["byte_length"] for item in artifacts)
|
||||
assert {item["id"] for item in payload["tracks"]} == {
|
||||
"frames",
|
||||
"centers",
|
||||
"states",
|
||||
"z-bounds",
|
||||
}
|
||||
assert all("/playback/tracks/" in item["url"] for item in payload["tracks"])
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi.routing import APIRoute
|
||||
@@ -126,6 +127,7 @@ def test_m4_6_lab_api_projects_report_and_exact_visual_frame() -> None:
|
||||
def test_m4_6_timeline_is_indexed_and_spatial_evidence_is_chunked() -> None:
|
||||
get_timeline = _endpoint("/api/v1/laboratory/m4-threat/results/{result_id}/timeline")
|
||||
get_chunk = _endpoint("/api/v1/laboratory/m4-threat/results/{result_id}/timeline/chunk")
|
||||
get_playback = _endpoint("/api/v1/laboratory/m4-threat/results/{result_id}/timeline/playback")
|
||||
|
||||
timeline = get_timeline(RESULT_ID)
|
||||
assert timeline["schema_version"] == "missioncore.recorded-spatial-evidence-timeline/v1"
|
||||
@@ -160,6 +162,23 @@ def test_m4_6_timeline_is_indexed_and_spatial_evidence_is_chunked() -> None:
|
||||
assert 0 < first["point_cloud_sample_count"] <= 4096
|
||||
assert first["camera_url"].endswith(f"/{RESULT_ID}/timeline/frames/1880/camera")
|
||||
|
||||
lightweight_response = get_chunk(RESULT_ID, start=1880, count=1, include_points=False)
|
||||
lightweight = json.loads(lightweight_response.body)
|
||||
assert lightweight["frames"][0]["point_cloud_body_xyz_m"] == []
|
||||
assert lightweight["frames"][0]["point_cloud_source_count"] == first["point_cloud_source_count"]
|
||||
assert lightweight["frames"][0]["point_cloud_sample_count"] == first["point_cloud_sample_count"]
|
||||
|
||||
playback = get_playback(RESULT_ID)
|
||||
assert playback["schema_version"] == "missioncore.recorded-spatial-playback/v1"
|
||||
assert playback["frame_count"] == 4489
|
||||
assert playback["point_count"] == 9_207_270
|
||||
assert len(playback["point_offsets"]) == 4490
|
||||
assert playback["point_offsets"][-1] == playback["point_count"]
|
||||
assert playback["track"]["dtype"] == "<f4"
|
||||
assert playback["track"]["shape"] == [9_207_270, 3]
|
||||
assert playback["track"]["bytes"] == 110_487_240
|
||||
assert len(playback["track"]["sha256"]) == 64
|
||||
|
||||
|
||||
def test_m4_6_exact_camera_endpoint_is_bound_to_selected_visual_sequence() -> None:
|
||||
calls: list[tuple[str, int]] = []
|
||||
|
||||
Reference in New Issue
Block a user