nape-repro-results / repro_scripts /publish_bundle.py
MSGEncrypted's picture
Upload folder using huggingface_hub
4db68fa verified
Raw
History Blame Contribute Delete
1.98 kB
"""Package a lightweight reproduction bundle and upload it to a HF dataset repo.
Keeps: run-level summaries (batch_summary.csv, experiment_summary.json,
run_config.yaml), top-level aggregates/figures, scripts, and configs.
Drops: per-trajectory predictions/, timeline.jsonl, target_state.json,
final_trajectory.jsonl (large, regenerable by rerunning the configs), and
run.log files >1MB (verbose HTTP debug traces).
"""
import shutil
from pathlib import Path
SRC = Path(__file__).resolve().parent.parent
BUNDLE = SRC / "bundle"
REPO_ID = "MSGEncrypted/nape-repro-results"
if BUNDLE.exists():
shutil.rmtree(BUNDLE)
BUNDLE.mkdir()
# top-level aggregates + figures
out_dst = BUNDLE / "repro_outputs"
out_dst.mkdir()
for pat in ("*.json", "*.csv", "*.html"):
for f in (SRC / "repro_outputs").glob(pat):
shutil.copy2(f, out_dst / f.name)
# per-run summaries only
for run_dir in sorted((SRC / "repro_outputs").iterdir()):
if not run_dir.is_dir() or run_dir.name == "caches":
continue
dst = out_dst / run_dir.name
dst.mkdir(exist_ok=True)
for fname in ("batch_summary.csv", "experiment_summary.json", "run_config.yaml"):
f = run_dir / fname
if f.exists():
shutil.copy2(f, dst / fname)
log = run_dir / "run.log"
if log.exists() and log.stat().st_size <= 1_000_000:
shutil.copy2(log, dst / "run.log")
# scripts + configs + roadmap
shutil.copytree(SRC / "repro_scripts", BUNDLE / "repro_scripts")
shutil.copytree(SRC / "repro_configs", BUNDLE / "repro_configs")
shutil.copy2(SRC / "TODO.md", BUNDLE / "TODO.md")
size_mb = sum(f.stat().st_size for f in BUNDLE.rglob("*") if f.is_file()) / 1e6
print(f"Bundle staged at {BUNDLE} ({size_mb:.1f} MB)")
from huggingface_hub import HfApi
api = HfApi()
api.create_repo(REPO_ID, repo_type="dataset", exist_ok=True)
api.upload_folder(folder_path=str(BUNDLE), repo_id=REPO_ID, repo_type="dataset")
print(f"Uploaded to https://huggingface.co/datasets/{REPO_ID}")