#!/usr/bin/env python3 """Create or update a Hugging Face **model** repo with this evaluation codebase. This upload is **code and docs only** (no MiniCPM-o weights). HF allows model repos to host auxiliary artifacts; use ``--private`` if you do not want the scripts public. Prerequisites:: pip install huggingface_hub export HF_TOKEN=hf_... # or: huggingface-cli login Usage:: cd MiniCPM-Evaluation python scripts/upload_to_hf_model.py --repo-id YourUsername/MiniCPM-Evaluation Private repo:: python scripts/upload_to_hf_model.py --repo-id YourUsername/MiniCPM-Evaluation --private """ from __future__ import annotations import argparse import sys from pathlib import Path def main() -> int: p = argparse.ArgumentParser(description=__doc__) p.add_argument( "--repo-id", required=True, help="HF repository id, e.g. username/MiniCPM-Evaluation", ) p.add_argument( "--private", action="store_true", help="Create the repo as private (only for first create; ignored if repo exists).", ) p.add_argument( "--token", default=None, help="HF token (default: HF_TOKEN env or cached huggingface-cli login).", ) args = p.parse_args() root = Path(__file__).resolve().parent.parent if not (root / "README.md").is_file(): print(f"error: unexpected layout; expected README.md under {root}", file=sys.stderr) return 1 try: from huggingface_hub import HfApi, create_repo except ImportError: print("error: install huggingface_hub: pip install huggingface_hub", file=sys.stderr) return 1 api = HfApi(token=args.token) create_repo( repo_id=args.repo_id, repo_type="model", private=args.private, exist_ok=True, ) api.upload_folder( folder_path=str(root), repo_id=args.repo_id, repo_type="model", ignore_patterns=[ ".git/**", ".git", "**/__pycache__/**", "**/*.pyc", "**/.DS_Store", ], ) print(f"Uploaded: {root}") print(f"URL: https://huggingface.co/{args.repo_id}") return 0 if __name__ == "__main__": raise SystemExit(main())