#!/usr/bin/env python3 """Create and upload the standalone passive-single dataset repository.""" from __future__ import annotations import argparse from pathlib import Path from huggingface_hub import HfApi DEFAULT_REPO_ROOT = Path(__file__).resolve().parents[1] def validate(repo_root: Path) -> None: required = [ repo_root / "README.md", repo_root / "data/metadata.jsonl", ] missing = [str(path) for path in required if not path.is_file()] if missing: raise SystemExit("Missing required files:\n" + "\n".join(missing)) metadata_rows = sum(1 for line in (repo_root / "data/metadata.jsonl").open(encoding="utf-8") if line.strip()) image_count = sum(1 for path in (repo_root / "data").rglob("*.png") if path.is_file()) if metadata_rows != 3423 or image_count != 3423: raise SystemExit(f"Expected 3423 metadata rows and images, got {metadata_rows} and {image_count}") if (repo_root / "reports").exists(): raise SystemExit("reports/ must not be included") def main() -> int: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--repo-id", default="ESI-Bench/esi-bench-passive-single") parser.add_argument("--repo-root", type=Path, default=DEFAULT_REPO_ROOT) parser.add_argument("--private", action="store_true") parser.add_argument("--revision", default=None) parser.add_argument("--commit-message", default="Upload standalone passive-single dataset") args = parser.parse_args() repo_root = args.repo_root.resolve() validate(repo_root) api = HfApi() api.create_repo( repo_id=args.repo_id, repo_type="dataset", private=args.private, exist_ok=True, ) api.upload_folder( repo_id=args.repo_id, repo_type="dataset", folder_path=repo_root, revision=args.revision, commit_message=args.commit_message, delete_patterns=[ "data/**", "reports/**", ], ignore_patterns=[ ".cache/**", "**/__pycache__/**", "**/*.pyc", ".git/**", ], ) print(f"Uploaded to https://huggingface.co/datasets/{args.repo_id}") return 0 if __name__ == "__main__": raise SystemExit(main())