JSHNSL's picture
Upload sync_docs.py with huggingface_hub
8a9c144 verified
Raw
History Blame Contribute Delete
2.78 kB
#!/usr/bin/env python3
"""Update every repo's README *and* the helper scripts in one run.
Korean README <- WORKFLOW.md -> JSHNSL/humanoid-imitation-learning (model)
English README <- WORKFLOW_en.md -> JSHNSL/humanoid-imitation-learning-en (model)
HDF5 hub README <- HDF5_HUB_README.md -> JSHNSL/ffw_sg2_hdf5 (dataset)
Scripts (push_dataset.py, push_hdf5.py, hpo_optuna.py, ...) -> Korean repo root
Whenever you edit a WORKFLOW/README or a script, run:
lerobot-python sync_docs.py
Note: recent huggingface_hub versions accept keyword arguments only.
"""
import os
from huggingface_hub import create_repo, upload_file
KO = "JSHNSL/humanoid-imitation-learning"
EN = "JSHNSL/humanoid-imitation-learning-en"
HDF5_HUB = "JSHNSL/ffw_sg2_hdf5"
# Scripts published at the repo root (must match the tree in WORKFLOW.md).
SCRIPTS = [
"push_dataset.py", # LeRobot dataset -> training dataset repo
"push_hdf5.py", # raw HDF5 -> HDF5 hub dataset repo
"merge_hdf5_demos.py", # HDF5 merge
"hpo_optuna.py", # Optuna HPO + train from tuned params
"hpo_train_shim.py", # lerobot_train w/ EpisodeAwareSampler fixed for subsets
"sync_docs.py", # this file
]
# (local_file, path_in_repo, repo_id, repo_type)
DOCS = [
("WORKFLOW.md", "README.md", KO, "model"),
("WORKFLOW.md", "WORKFLOW.md", KO, "model"),
("WORKFLOW_en.md", "README.md", EN, "model"),
("WORKFLOW_en.md", "WORKFLOW_en.md", EN, "model"),
("HDF5_HUB_README.md", "README.md", HDF5_HUB, "dataset"),
# Guides published alongside the KO workflow.
("SETUP_CYCLO_GROOT.md", "SETUP_CYCLO_GROOT.md", KO, "model"),
("GROOT_FINETUNE.md", "GROOT_FINETUNE.md", KO, "model"),
("WRIST_CAM.md", "WRIST_CAM.md", KO, "model"),
]
def push(local: str, dest: str, repo_id: str, repo_type: str = "model") -> None:
upload_file(
path_or_fileobj=local,
path_in_repo=dest,
repo_id=repo_id,
repo_type=repo_type,
)
# The HDF5 hub may not exist yet (its README can land before any HDF5 does).
create_repo(repo_id=HDF5_HUB, repo_type="dataset", exist_ok=True)
print("Docs:")
for local, dest, repo, rtype in DOCS:
if not os.path.exists(local):
print(f" skip (not found): {local}")
continue
push(local, dest, repo, rtype)
print(f" {local} -> {repo}:{dest} [{rtype}]")
print("\nScripts:")
for s in SCRIPTS:
if not os.path.exists(s):
print(f" skip (not found): {s}")
continue
push(s, s, KO, "model")
print(f" {s} -> {KO}:{s}")
print("\nDone:")
print(" KO ->", "https://huggingface.co/" + KO)
print(" EN ->", "https://huggingface.co/" + EN)
print(" HDF5 hub ->", "https://huggingface.co/datasets/" + HDF5_HUB)