RoboFactory-5Task-RGBD-Decentralized / strict640x480-v2 /code /publish_all5_final_artifacts.py
B111ue's picture
Upload strict640x480-v2/code/publish_all5_final_artifacts.py with huggingface_hub
4356eca verified
Raw
History Blame Contribute Delete
3.87 kB
"""Publish the audited All-5 formal artifacts after every evaluation is complete.
This intentionally publishes only the strict-v2 final checkpoints, held-out
seed manifests, formal rollout JSONs, and rendered report. It excludes all
intermediate/invalid collection roots and temporary checkpoints.
"""
from __future__ import annotations
import hashlib
import json
from pathlib import Path
from huggingface_hub import HfApi
REPO_ID = "B111ue/RoboFactory-5Task-RGBD-Decentralized"
RUN_ROOT = Path("/workspace/RoboFactory/runs/strict640x480_v2")
METHODS = {
"frozen_dinov3_act": "frozen_dinov3_act_all5_80k",
"stereo_cross_relbias": "stereo_cross_relbias_all5_80k",
"stereo_ffn_moe": "stereo_ffn_moe_all5_80k",
"local_arca": "local_arca_all5_80k",
}
TASKS = (
"lift_barrier",
"camera_alignment",
"three_robots_stack_cube",
"long_pipeline_delivery",
"take_photo",
)
def sha256(path: Path) -> str:
digest = hashlib.sha256()
with path.open("rb") as stream:
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
def main() -> None:
report = RUN_ROOT / "final_report"
required = [report / "COMPLETE", report / "performance_table.md", report / "performance_table.png"]
for method_dir in METHODS.values():
output = RUN_ROOT / "results" / method_dir / "formal_heldout_100"
required.extend(output / f"eval_{task}.json" for task in TASKS)
required.append(RUN_ROOT / "results" / method_dir / "checkpoint_080000.pt")
missing = [str(path) for path in required if not path.is_file()]
if missing:
raise RuntimeError("refusing partial publication: " + ", ".join(missing))
manifest = {
"protocol": "strict640x480-v2; wrist-only RGB-D; 30x40 aligned RGB/depth patch grid; frozen unseen 100 seeds",
"tasks": list(TASKS),
"methods": {},
}
for name, method_dir in METHODS.items():
base = RUN_ROOT / "results" / method_dir
manifest["methods"][name] = {
"checkpoint": {
"path": str(base / "checkpoint_080000.pt"),
"sha256": sha256(base / "checkpoint_080000.pt"),
},
"formal_results": {
task: sha256(base / "formal_heldout_100" / f"eval_{task}.json")
for task in TASKS
},
}
manifest_path = report / "hf_artifact_manifest.json"
manifest_path.write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
api = HfApi()
base_path = "strict640x480-v2/formal_all5_80k"
api.upload_folder(
folder_path=str(RUN_ROOT / "heldout_seeds"),
path_in_repo=f"{base_path}/heldout_seeds",
repo_id=REPO_ID,
repo_type="dataset",
commit_message="formal All-5: audited frozen held-out manifests",
)
api.upload_folder(
folder_path=str(report),
path_in_repo=f"{base_path}/report",
repo_id=REPO_ID,
repo_type="dataset",
commit_message="formal All-5: result table and audit",
)
for name, method_dir in METHODS.items():
base = RUN_ROOT / "results" / method_dir
api.upload_folder(
folder_path=str(base / "formal_heldout_100"),
path_in_repo=f"{base_path}/results/{name}",
repo_id=REPO_ID,
repo_type="dataset",
commit_message=f"formal All-5: {name} rollout JSON",
)
api.upload_file(
path_or_fileobj=str(base / "checkpoint_080000.pt"),
path_in_repo=f"{base_path}/checkpoints/{name}/checkpoint_080000.pt",
repo_id=REPO_ID,
repo_type="dataset",
commit_message=f"formal All-5: {name} final checkpoint",
)
print("PUBLISHED_FORMAL_ALL5_ARTIFACTS")
if __name__ == "__main__":
main()