Upload strict640x480-v2/code/upload_strict_task_hf.py with huggingface_hub
Browse files
strict640x480-v2/code/upload_strict_task_hf.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Upload one audited strict640x480-v2 task atomically to the public Hub repo."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import argparse
|
| 5 |
+
import json
|
| 6 |
+
import os
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
from huggingface_hub import HfApi
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def main() -> None:
|
| 13 |
+
parser = argparse.ArgumentParser()
|
| 14 |
+
parser.add_argument("--task", required=True)
|
| 15 |
+
parser.add_argument("--source", required=True)
|
| 16 |
+
args = parser.parse_args()
|
| 17 |
+
source = Path(args.source)
|
| 18 |
+
audit = source / "strict_audit.json"
|
| 19 |
+
report = json.loads(audit.read_text(encoding="utf-8"))
|
| 20 |
+
if report.get("status") != "PASS_STRICT640X480_V2" or report.get("episodes") != 100:
|
| 21 |
+
raise ValueError(f"refusing upload of non-formal task audit: {report}")
|
| 22 |
+
api = HfApi(token=os.environ.get("HF_TOKEN"))
|
| 23 |
+
result = api.upload_folder(
|
| 24 |
+
repo_id="B111ue/RoboFactory-5Task-RGBD-Decentralized", repo_type="dataset",
|
| 25 |
+
folder_path=str(source), path_in_repo=f"strict640x480-v2/data/{args.task}",
|
| 26 |
+
commit_message=f"strict640x480-v2: add audited {args.task} (100 demos)",
|
| 27 |
+
)
|
| 28 |
+
(source / "hf_upload_receipt.json").write_text(json.dumps({
|
| 29 |
+
"task": args.task, "revision": str(result), "audit": report,
|
| 30 |
+
}, indent=2), encoding="utf-8")
|
| 31 |
+
print(f"HF_UPLOAD_VERIFIED {args.task} {result}")
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
if __name__ == "__main__":
|
| 35 |
+
main()
|