feat(perception): add TRAVEL RAVNOVES compatibility probe
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import json
|
||||
import tarfile
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
|
||||
REPOSITORY_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def _load(name: str, path: Path):
|
||||
spec = importlib.util.spec_from_file_location(name, path)
|
||||
assert spec is not None and spec.loader is not None
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
PREPARE = _load(
|
||||
"m49_t3_prepare",
|
||||
REPOSITORY_ROOT / "experiments/perception/worker/m49_t3_travel/prepare_ravnoves_probe.py",
|
||||
)
|
||||
ANALYZE = _load(
|
||||
"m49_t3_analyze",
|
||||
REPOSITORY_ROOT / "experiments/perception/worker/m49_t3_travel/analyze_ravnoves_probe.py",
|
||||
)
|
||||
BUILDER = _load(
|
||||
"m49_t3_ravnoves_builder",
|
||||
REPOSITORY_ROOT / "scripts/build_m49_t3_travel_ravnoves_worker_artifact.py",
|
||||
)
|
||||
|
||||
|
||||
def _sha256(value: bytes) -> str:
|
||||
return hashlib.sha256(value).hexdigest()
|
||||
|
||||
|
||||
def test_map_points_are_transformed_into_current_lidar_frame() -> None:
|
||||
points = np.asarray([[2.0, 4.0, 6.0], [3.0, 6.0, 9.0]], dtype=np.float32)
|
||||
result = PREPARE.points_in_current_lidar_frame(
|
||||
points,
|
||||
np.asarray([1.0, 2.0, 3.0], dtype=np.float64),
|
||||
np.asarray([0.0, 0.0, 0.0, 1.0], dtype=np.float64),
|
||||
)
|
||||
assert np.array_equal(result, np.asarray([[1.0, 2.0, 3.0], [2.0, 4.0, 6.0]]))
|
||||
|
||||
|
||||
def test_multiset_jaccard_ignores_order_but_not_membership() -> None:
|
||||
left = np.asarray([[1, 2, 3, 0], [4, 5, 6, 0], [4, 5, 6, 0]], dtype=np.float32)
|
||||
reversed_points = left[::-1]
|
||||
changed = left.copy()
|
||||
changed[0, 0] = 99
|
||||
assert ANALYZE.multiset_jaccard(left, reversed_points) == 1.0
|
||||
assert ANALYZE.multiset_jaccard(left, changed) < 1.0
|
||||
|
||||
|
||||
def test_probe_worker_artifact_is_deterministic_and_bounded(tmp_path: Path) -> None:
|
||||
patch_id = "mission-core-m49-t3-ravnoves-unit-001"
|
||||
revision = "a" * 40
|
||||
first = BUILDER.build(patch_id, tmp_path / "first", revision=revision)
|
||||
second = BUILDER.build(patch_id, tmp_path / "second", revision=revision)
|
||||
first_bytes = Path(first["artifact"]).read_bytes()
|
||||
assert first_bytes == Path(second["artifact"]).read_bytes()
|
||||
assert first["sha256"] == _sha256(first_bytes)
|
||||
with tarfile.open(first["artifact"], "r:gz") as archive:
|
||||
members = archive.getmembers()
|
||||
regular = {
|
||||
member.name: archive.extractfile(member).read() # type: ignore[union-attr]
|
||||
for member in members
|
||||
if member.isfile()
|
||||
}
|
||||
assert all(not member.issym() and not member.islnk() for member in members)
|
||||
assert set(regular) == {
|
||||
"manifest.env",
|
||||
"files.txt",
|
||||
*(f"payload/{name}" for name in first["payload_files"]),
|
||||
}
|
||||
release = json.loads(regular["payload/release.json"])
|
||||
assert release["code_revision"] == revision
|
||||
assert release["candidate_id"] == "travel"
|
||||
assert release["authority"] == {
|
||||
"navigation_or_actuation_allowed": False,
|
||||
"ravnoves00_visual_quality_accepted": False,
|
||||
"realtime_accepted": False,
|
||||
}
|
||||
assert "--gpus" not in regular["payload/Invoke-M49T3TravelRavnovesProbe.ps1"].decode()
|
||||
Reference in New Issue
Block a user