File size: 3,866 Bytes
4356eca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
"""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()