Initial ZeroGPU Simam3D runtime
Browse files- summarize_runs.py +58 -0
summarize_runs.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Summarize Simam3D run manifests for reproducible backend comparisons."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import argparse
|
| 6 |
+
import json
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def _mean(values) -> float | None:
|
| 11 |
+
numbers = [float(value) for value in values if value is not None]
|
| 12 |
+
return sum(numbers) / len(numbers) if numbers else None
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def summarize_manifest(manifest: dict, path: str | Path = "") -> dict:
|
| 16 |
+
metrics = manifest.get("metrics") or {}
|
| 17 |
+
reprojection = metrics.get("reprojection_consistency") or []
|
| 18 |
+
coverage = metrics.get("projection_coverage") or []
|
| 19 |
+
return {
|
| 20 |
+
"manifest": str(path),
|
| 21 |
+
"run_id": manifest.get("run_id"),
|
| 22 |
+
"status": manifest.get("status", "completed"),
|
| 23 |
+
"stage": manifest.get("stage"),
|
| 24 |
+
"backend": manifest.get("backend"),
|
| 25 |
+
"runtime": manifest.get("runtime"),
|
| 26 |
+
"view_count": manifest.get("view_count"),
|
| 27 |
+
"fused_point_count": metrics.get("fused_point_count"),
|
| 28 |
+
"projection_coverage_mean": _mean(coverage),
|
| 29 |
+
"reprojection_mae_mean": _mean(item.get("mean_absolute_error") for item in reprojection),
|
| 30 |
+
"fallback_error": metrics.get("fallback_error"),
|
| 31 |
+
"failure_error": manifest.get("error"),
|
| 32 |
+
"claims": manifest.get("claims", {}),
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def find_manifests(root: Path) -> list[Path]:
|
| 37 |
+
if root.is_file():
|
| 38 |
+
return [root]
|
| 39 |
+
return sorted(set(root.rglob("*_run.json")) | set(root.rglob("*_failure.json")))
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def main(argv: list[str] | None = None) -> int:
|
| 43 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 44 |
+
parser.add_argument("path", type=Path, help="A run manifest or directory containing manifests")
|
| 45 |
+
args = parser.parse_args(argv)
|
| 46 |
+
rows = []
|
| 47 |
+
for path in find_manifests(args.path):
|
| 48 |
+
try:
|
| 49 |
+
manifest = json.loads(path.read_text(encoding="utf-8"))
|
| 50 |
+
rows.append(summarize_manifest(manifest, path))
|
| 51 |
+
except (OSError, json.JSONDecodeError) as exc:
|
| 52 |
+
print(f"warning: skipped {path}: {exc}")
|
| 53 |
+
print(json.dumps(rows, indent=2))
|
| 54 |
+
return 0 if rows else 1
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
if __name__ == "__main__":
|
| 58 |
+
raise SystemExit(main())
|