test: re-audit reconstruction evidence across builds
This commit is contained in:
parent
b120ecbaac
commit
70bea0c9e1
@ -524,8 +524,9 @@ def resume_reconstruction_evidence(run: AcceptanceRun, report_path: Path) -> tup
|
||||
previous = json.loads(report_path.read_text(encoding="utf-8"))
|
||||
if previous.get("schema") != "real2sim.poc_acceptance_report.v1":
|
||||
raise AcceptanceError(f"unsupported resume report schema: {previous.get('schema')}")
|
||||
if previous.get("build_id") != run.build_id:
|
||||
raise AcceptanceError(f"resume report build_id {previous.get('build_id')} does not match {run.build_id}")
|
||||
source_build_id = str(previous.get("build_id") or "")
|
||||
if not source_build_id:
|
||||
raise AcceptanceError("resume report does not identify its source build")
|
||||
|
||||
prepared = next((item for item in previous.get("datasets", []) if item.get("role") == "playroom_prepared"), None)
|
||||
scenes = [item for item in previous.get("scenes", []) if str(item.get("role") or "").startswith("playroom_reconstruction_")]
|
||||
@ -568,7 +569,19 @@ def resume_reconstruction_evidence(run: AcceptanceRun, report_path: Path) -> tup
|
||||
run.report["datasets"] = [item for item in previous.get("datasets", []) if item.get("role") in {"playroom_upload", "playroom_prepared"}]
|
||||
run.report["scenes"] = scenes
|
||||
run.report["storage"] = dict(previous.get("storage") or {})
|
||||
run.report["resumed_from"] = str(report_path.resolve())
|
||||
run.report["resumed_evidence"] = {
|
||||
"report": str(report_path.resolve()),
|
||||
"source_build_id": source_build_id,
|
||||
"target_build_id": run.build_id,
|
||||
"cross_build": source_build_id != run.build_id,
|
||||
"reaudited_task_ids": [
|
||||
str(task["id"])
|
||||
for task_type, count in required_counts.items()
|
||||
for task in by_type[task_type][:count]
|
||||
],
|
||||
"prepared_dataset_id": prepared_id,
|
||||
"scene_ids": scene_ids,
|
||||
}
|
||||
run.save()
|
||||
return prepared_id, scene_ids
|
||||
|
||||
|
||||
@ -387,6 +387,73 @@ def test_source_revision_rejects_unverified_archive_marker(tmp_path: Path) -> No
|
||||
assert read_source_revision(root) == ""
|
||||
|
||||
|
||||
def test_acceptance_reaudits_reconstruction_evidence_across_builds(tmp_path: Path) -> None:
|
||||
script_path = ROOT / "scripts/acceptance_poc_cluster.py"
|
||||
spec = importlib.util.spec_from_file_location("real2sim_acceptance_poc_cluster", script_path)
|
||||
assert spec and spec.loader
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
tasks = [
|
||||
{"id": "media", "type": "media_prepare"},
|
||||
{"id": "preflight", "type": "reconstruction_preflight"},
|
||||
{"id": "recon-a", "type": "scene_reconstruction"},
|
||||
{"id": "recon-b", "type": "scene_reconstruction"},
|
||||
{"id": "sim-a", "type": "simulator_validation"},
|
||||
{"id": "sim-b", "type": "simulator_validation"},
|
||||
]
|
||||
report_path = tmp_path / "prior-report.json"
|
||||
report_path.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"schema": "real2sim.poc_acceptance_report.v1",
|
||||
"build_id": "prior-build",
|
||||
"tasks": tasks,
|
||||
"datasets": [{"id": "prepared", "role": "playroom_prepared"}],
|
||||
"scenes": [
|
||||
{"id": "scene-a", "role": "playroom_reconstruction_1"},
|
||||
{"id": "scene-b", "role": "playroom_reconstruction_2"},
|
||||
],
|
||||
"storage": {"source_image_count": 225},
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
class FakeClient:
|
||||
def get(self, path: str) -> dict:
|
||||
if path == "/api/datasets/prepared/manifest":
|
||||
return {"frame_count": 225}
|
||||
return {"assets": [{"name": "scene.ply"}, {"name": "scene.xml"}]}
|
||||
|
||||
class FakeRun:
|
||||
build_id = "current-build"
|
||||
client = FakeClient()
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.report = {"datasets": [], "scenes": [], "storage": {}, "checks": []}
|
||||
self.audited: list[str] = []
|
||||
|
||||
def wait_task(self, task_id: str, required_artifacts: tuple[str, ...]) -> dict:
|
||||
assert required_artifacts
|
||||
self.audited.append(task_id)
|
||||
return {"id": task_id, "status": "succeeded"}
|
||||
|
||||
def check(self, name: str, ok: bool, detail=None) -> None:
|
||||
assert ok, (name, detail)
|
||||
self.report["checks"].append({"name": name, "ok": ok})
|
||||
|
||||
def save(self) -> None:
|
||||
return None
|
||||
|
||||
run = FakeRun()
|
||||
prepared_id, scene_ids = module.resume_reconstruction_evidence(run, report_path)
|
||||
assert prepared_id == "prepared"
|
||||
assert scene_ids == ["scene-a", "scene-b"]
|
||||
assert run.audited == ["media", "preflight", "recon-a", "recon-b", "sim-a", "sim-b"]
|
||||
assert run.report["resumed_evidence"]["cross_build"] is True
|
||||
assert run.report["resumed_evidence"]["source_build_id"] == "prior-build"
|
||||
|
||||
|
||||
def test_motrixsim_runtime_scene_uses_current_python_when_module_is_installed(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
script_path = ROOT / "scripts/generate_motrixsim_runtime_scene.py"
|
||||
spec = importlib.util.spec_from_file_location("real2sim_generate_motrixsim_runtime_scene", script_path)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user