B111ue commited on
Commit
4356eca
·
verified ·
1 Parent(s): f0e5095

Upload strict640x480-v2/code/publish_all5_final_artifacts.py with huggingface_hub

Browse files
strict640x480-v2/code/publish_all5_final_artifacts.py ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Publish the audited All-5 formal artifacts after every evaluation is complete.
2
+
3
+ This intentionally publishes only the strict-v2 final checkpoints, held-out
4
+ seed manifests, formal rollout JSONs, and rendered report. It excludes all
5
+ intermediate/invalid collection roots and temporary checkpoints.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import hashlib
10
+ import json
11
+ from pathlib import Path
12
+
13
+ from huggingface_hub import HfApi
14
+
15
+
16
+ REPO_ID = "B111ue/RoboFactory-5Task-RGBD-Decentralized"
17
+ RUN_ROOT = Path("/workspace/RoboFactory/runs/strict640x480_v2")
18
+ METHODS = {
19
+ "frozen_dinov3_act": "frozen_dinov3_act_all5_80k",
20
+ "stereo_cross_relbias": "stereo_cross_relbias_all5_80k",
21
+ "stereo_ffn_moe": "stereo_ffn_moe_all5_80k",
22
+ "local_arca": "local_arca_all5_80k",
23
+ }
24
+ TASKS = (
25
+ "lift_barrier",
26
+ "camera_alignment",
27
+ "three_robots_stack_cube",
28
+ "long_pipeline_delivery",
29
+ "take_photo",
30
+ )
31
+
32
+
33
+ def sha256(path: Path) -> str:
34
+ digest = hashlib.sha256()
35
+ with path.open("rb") as stream:
36
+ for chunk in iter(lambda: stream.read(1024 * 1024), b""):
37
+ digest.update(chunk)
38
+ return digest.hexdigest()
39
+
40
+
41
+ def main() -> None:
42
+ report = RUN_ROOT / "final_report"
43
+ required = [report / "COMPLETE", report / "performance_table.md", report / "performance_table.png"]
44
+ for method_dir in METHODS.values():
45
+ output = RUN_ROOT / "results" / method_dir / "formal_heldout_100"
46
+ required.extend(output / f"eval_{task}.json" for task in TASKS)
47
+ required.append(RUN_ROOT / "results" / method_dir / "checkpoint_080000.pt")
48
+ missing = [str(path) for path in required if not path.is_file()]
49
+ if missing:
50
+ raise RuntimeError("refusing partial publication: " + ", ".join(missing))
51
+
52
+ manifest = {
53
+ "protocol": "strict640x480-v2; wrist-only RGB-D; 30x40 aligned RGB/depth patch grid; frozen unseen 100 seeds",
54
+ "tasks": list(TASKS),
55
+ "methods": {},
56
+ }
57
+ for name, method_dir in METHODS.items():
58
+ base = RUN_ROOT / "results" / method_dir
59
+ manifest["methods"][name] = {
60
+ "checkpoint": {
61
+ "path": str(base / "checkpoint_080000.pt"),
62
+ "sha256": sha256(base / "checkpoint_080000.pt"),
63
+ },
64
+ "formal_results": {
65
+ task: sha256(base / "formal_heldout_100" / f"eval_{task}.json")
66
+ for task in TASKS
67
+ },
68
+ }
69
+ manifest_path = report / "hf_artifact_manifest.json"
70
+ manifest_path.write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
71
+
72
+ api = HfApi()
73
+ base_path = "strict640x480-v2/formal_all5_80k"
74
+ api.upload_folder(
75
+ folder_path=str(RUN_ROOT / "heldout_seeds"),
76
+ path_in_repo=f"{base_path}/heldout_seeds",
77
+ repo_id=REPO_ID,
78
+ repo_type="dataset",
79
+ commit_message="formal All-5: audited frozen held-out manifests",
80
+ )
81
+ api.upload_folder(
82
+ folder_path=str(report),
83
+ path_in_repo=f"{base_path}/report",
84
+ repo_id=REPO_ID,
85
+ repo_type="dataset",
86
+ commit_message="formal All-5: result table and audit",
87
+ )
88
+ for name, method_dir in METHODS.items():
89
+ base = RUN_ROOT / "results" / method_dir
90
+ api.upload_folder(
91
+ folder_path=str(base / "formal_heldout_100"),
92
+ path_in_repo=f"{base_path}/results/{name}",
93
+ repo_id=REPO_ID,
94
+ repo_type="dataset",
95
+ commit_message=f"formal All-5: {name} rollout JSON",
96
+ )
97
+ api.upload_file(
98
+ path_or_fileobj=str(base / "checkpoint_080000.pt"),
99
+ path_in_repo=f"{base_path}/checkpoints/{name}/checkpoint_080000.pt",
100
+ repo_id=REPO_ID,
101
+ repo_type="dataset",
102
+ commit_message=f"formal All-5: {name} final checkpoint",
103
+ )
104
+ print("PUBLISHED_FORMAL_ALL5_ARTIFACTS")
105
+
106
+
107
+ if __name__ == "__main__":
108
+ main()