fix(perception): bound LAB replay to AI window
This commit is contained in:
@@ -37,6 +37,9 @@ def test_publish_lab_replay_cache_hardlinks_rrd_and_rebinds_sidecars(
|
||||
"recording_byte_length": source_rrd.stat().st_size,
|
||||
"recording_mtime_ns": source_rrd.stat().st_mtime_ns,
|
||||
"recording_sha256": hashlib.sha256(source_rrd.read_bytes()).hexdigest(),
|
||||
"timeline": "session_time",
|
||||
"timeline_start_ns": 0,
|
||||
"timeline_end_ns": 1,
|
||||
}
|
||||
(source / RECORDING_CACHE_SIDECAR_FILENAME).write_text(
|
||||
json.dumps(source_sidecar),
|
||||
@@ -87,3 +90,81 @@ def test_publish_lab_replay_cache_hardlinks_rrd_and_rebinds_sidecars(
|
||||
|
||||
lab_rrd.unlink()
|
||||
assert source_rrd.read_bytes() == b"RRF2immutable"
|
||||
|
||||
|
||||
def test_publish_lab_replay_cache_materializes_exact_bounded_window(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
import numpy as np
|
||||
import rerun as rr
|
||||
|
||||
data = tmp_path / "mission-core"
|
||||
recordings = data / "recordings"
|
||||
source = recordings / "source-session"
|
||||
source.mkdir(parents=True)
|
||||
source_rrd = source / RECORDING_CACHE_FILENAME
|
||||
recording = rr.RecordingStream(
|
||||
"nodedc_mission_core_recorded",
|
||||
recording_id=source.name,
|
||||
)
|
||||
stream = rr.binary_stream(recording)
|
||||
try:
|
||||
for index, timestamp in enumerate((0, 2_000_000_000, 4_000_000_000, 8_000_000_000)):
|
||||
recording.set_time(
|
||||
"session_time",
|
||||
duration=np.timedelta64(timestamp, "ns"),
|
||||
)
|
||||
recording.log(
|
||||
"/world/points",
|
||||
rr.Points3D([[float(index), 0.0, 0.0]]),
|
||||
)
|
||||
payload = stream.read(flush=True, flush_timeout_sec=5.0)
|
||||
finally:
|
||||
recording.disconnect()
|
||||
assert payload is not None
|
||||
source_rrd.write_bytes(payload)
|
||||
source_sidecar = {
|
||||
"schema_version": CACHE_SCHEMA,
|
||||
"session_id": source.name,
|
||||
"recording_byte_length": source_rrd.stat().st_size,
|
||||
"recording_mtime_ns": source_rrd.stat().st_mtime_ns,
|
||||
"recording_sha256": hashlib.sha256(source_rrd.read_bytes()).hexdigest(),
|
||||
"timeline": "session_time",
|
||||
"timeline_start_ns": 0,
|
||||
"timeline_end_ns": 8_000_000_000,
|
||||
}
|
||||
(source / RECORDING_CACHE_SIDECAR_FILENAME).write_text(
|
||||
json.dumps(source_sidecar),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
publish_lab_replay_cache(
|
||||
data,
|
||||
source_session_id=source.name,
|
||||
lab_session_id="lab-e21-bounded",
|
||||
timeline_start_ns=2_000_000_000,
|
||||
timeline_end_ns=4_000_000_000,
|
||||
)
|
||||
|
||||
lab = recordings / "lab-e21-bounded"
|
||||
lab_rrd = lab / RECORDING_CACHE_FILENAME
|
||||
assert lab_rrd.stat().st_ino != source_rrd.stat().st_ino
|
||||
bounded = json.loads(
|
||||
(lab / RECORDING_CACHE_SIDECAR_FILENAME).read_text(encoding="utf-8")
|
||||
)
|
||||
assert bounded["timeline_start_ns"] == 2_000_000_000
|
||||
assert bounded["timeline_end_ns"] == 4_000_000_000
|
||||
assert bounded["recording_byte_length"] == lab_rrd.stat().st_size
|
||||
assert bounded["recording_sha256"] == hashlib.sha256(lab_rrd.read_bytes()).hexdigest()
|
||||
assert "lab_window" not in bounded
|
||||
|
||||
original_stat = lab_rrd.stat()
|
||||
publish_lab_replay_cache(
|
||||
data,
|
||||
source_session_id=source.name,
|
||||
lab_session_id="lab-e21-bounded",
|
||||
timeline_start_ns=2_000_000_000,
|
||||
timeline_end_ns=4_000_000_000,
|
||||
)
|
||||
assert lab_rrd.stat().st_ino == original_stat.st_ino
|
||||
assert lab_rrd.stat().st_mtime_ns == original_stat.st_mtime_ns
|
||||
|
||||
Reference in New Issue
Block a user