Upload strict640x480-v2/code/make_strict640x480_result_table.py with huggingface_hub
Browse files
strict640x480-v2/code/make_strict640x480_result_table.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
from __future__ import annotations
|
| 3 |
|
| 4 |
import argparse
|
|
|
|
| 5 |
import json
|
| 6 |
from pathlib import Path
|
| 7 |
|
|
@@ -23,7 +24,7 @@ METHODS = [
|
|
| 23 |
]
|
| 24 |
|
| 25 |
|
| 26 |
-
def read_result(root: Path, method: str, task: str):
|
| 27 |
# The watcher writes one audited JSON per task beside the exact final
|
| 28 |
# checkpoint. Keeping the path tied to the training run prevents a stale
|
| 29 |
# result from a historical run from entering the formal All-5 table.
|
|
@@ -33,6 +34,10 @@ def read_result(root: Path, method: str, task: str):
|
|
| 33 |
raw = json.loads(path.read_text(encoding="utf-8"))
|
| 34 |
if raw.get("episodes") != 100:
|
| 35 |
raise ValueError(f"not formal 100-seed output: {path}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
return int(raw["successes"]), int(raw["episodes"])
|
| 37 |
|
| 38 |
|
|
@@ -41,7 +46,8 @@ def main() -> None:
|
|
| 41 |
parser.add_argument("--root", default="/workspace/RoboFactory/runs/strict640x480_v2/results")
|
| 42 |
parser.add_argument("--output", default="/workspace/RoboFactory/runs/strict640x480_v2/final_report")
|
| 43 |
args = parser.parse_args(); root, out = Path(args.root), Path(args.output); out.mkdir(parents=True, exist_ok=True)
|
| 44 |
-
|
|
|
|
| 45 |
lines = ["| Training corpus | Test task (robots) | " + " | ".join(name for name, _ in METHODS) + " |",
|
| 46 |
"|---|---|" + "---|" * len(METHODS)]
|
| 47 |
table = []
|
|
@@ -56,6 +62,12 @@ def main() -> None:
|
|
| 56 |
lines.append("| All-5 strict640x480-v2 | " + f"{task_name} ({robots}) | " + " | ".join(cells) + " |")
|
| 57 |
table.append(cells)
|
| 58 |
(out / "performance_table.md").write_text("\n".join(lines) + "\n", encoding="utf-8")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
fig, axis = plt.subplots(figsize=(16, 4.8)); axis.axis("off")
|
| 60 |
rendered = axis.table(cellText=table, colLabels=[name for name, _ in METHODS],
|
| 61 |
rowLabels=[f"{name} ({robots})" for name, robots, _ in TASKS],
|
|
|
|
| 2 |
from __future__ import annotations
|
| 3 |
|
| 4 |
import argparse
|
| 5 |
+
import hashlib
|
| 6 |
import json
|
| 7 |
from pathlib import Path
|
| 8 |
|
|
|
|
| 24 |
]
|
| 25 |
|
| 26 |
|
| 27 |
+
def read_result(root: Path, method: str, task: str, seed_root: Path):
|
| 28 |
# The watcher writes one audited JSON per task beside the exact final
|
| 29 |
# checkpoint. Keeping the path tied to the training run prevents a stale
|
| 30 |
# result from a historical run from entering the formal All-5 table.
|
|
|
|
| 34 |
raw = json.loads(path.read_text(encoding="utf-8"))
|
| 35 |
if raw.get("episodes") != 100:
|
| 36 |
raise ValueError(f"not formal 100-seed output: {path}")
|
| 37 |
+
expected = hashlib.sha256((seed_root / f"{task}.json").read_bytes()).hexdigest()
|
| 38 |
+
protocol = raw.get("seed_protocol", {})
|
| 39 |
+
if protocol.get("sha256") != expected or protocol.get("training_seed_overlap") != 0:
|
| 40 |
+
raise ValueError(f"seed audit failed: {path}")
|
| 41 |
return int(raw["successes"]), int(raw["episodes"])
|
| 42 |
|
| 43 |
|
|
|
|
| 46 |
parser.add_argument("--root", default="/workspace/RoboFactory/runs/strict640x480_v2/results")
|
| 47 |
parser.add_argument("--output", default="/workspace/RoboFactory/runs/strict640x480_v2/final_report")
|
| 48 |
args = parser.parse_args(); root, out = Path(args.root), Path(args.output); out.mkdir(parents=True, exist_ok=True)
|
| 49 |
+
seed_root = root.parent / "heldout_seeds"
|
| 50 |
+
values = [[read_result(root, method_dir, task_id, seed_root) for _, _, task_id in TASKS] for _, method_dir in METHODS]
|
| 51 |
lines = ["| Training corpus | Test task (robots) | " + " | ".join(name for name, _ in METHODS) + " |",
|
| 52 |
"|---|---|" + "---|" * len(METHODS)]
|
| 53 |
table = []
|
|
|
|
| 62 |
lines.append("| All-5 strict640x480-v2 | " + f"{task_name} ({robots}) | " + " | ".join(cells) + " |")
|
| 63 |
table.append(cells)
|
| 64 |
(out / "performance_table.md").write_text("\n".join(lines) + "\n", encoding="utf-8")
|
| 65 |
+
(out / "formal_seed_audit.json").write_text(json.dumps({
|
| 66 |
+
"status": "PASS", "episodes_per_cell": 100,
|
| 67 |
+
"tasks": [task_id for _, _, task_id in TASKS],
|
| 68 |
+
"methods": [method_id for _, method_id in METHODS],
|
| 69 |
+
"condition": "each result uses the matching frozen manifest with zero training-seed overlap",
|
| 70 |
+
}, indent=2) + "\n", encoding="utf-8")
|
| 71 |
fig, axis = plt.subplots(figsize=(16, 4.8)); axis.axis("off")
|
| 72 |
rendered = axis.table(cellText=table, colLabels=[name for name, _ in METHODS],
|
| 73 |
rowLabels=[f"{name} ({robots})" for name, robots, _ in TASKS],
|