Download code/validation/src/upload_hf.py from lsh9034/ci-net: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/lsh9034/ci-net/resolve/main/code/validation/src/upload_hf.py
- Command line
-
hf download hf://lsh9034/ci-net/code/validation/src/upload_hf.py
-
curl -L -o upload_hf.py https://huggingface.co/lsh9034/ci-net/resolve/main/code/validation/src/upload_hf.py
1.4 kB
| #!/usr/bin/env python3 | |
| """Upload the release using resumable, multi-commit Hugging Face Hub uploads.""" | |
| from __future__ import annotations | |
| import argparse | |
| from pathlib import Path | |
| from huggingface_hub import HfApi | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--root", required=True, type=Path) | |
| parser.add_argument("--repo-id", required=True) | |
| parser.add_argument("--include", action="append", default=None, help="Glob to upload; repeat as needed") | |
| parser.add_argument("--workers", type=int, default=None) | |
| parser.add_argument("--private", action="store_true", help="Create a private repository instead of public") | |
| args = parser.parse_args() | |
| root = args.root.resolve() | |
| if not (root / "MANIFEST.sha256").is_file(): | |
| raise FileNotFoundError( | |
| "MANIFEST.sha256 is missing; run code/validation/run/verify_release.sh first" | |
| ) | |
| api = HfApi() | |
| api.create_repo( | |
| repo_id=args.repo_id, | |
| repo_type="model", | |
| private=bool(args.private), | |
| exist_ok=True, | |
| ) | |
| api.upload_large_folder( | |
| repo_id=args.repo_id, | |
| repo_type="model", | |
| folder_path=root, | |
| allow_patterns=args.include, | |
| ignore_patterns=["**/*.partial", "**/__pycache__/**", ".git/**"], | |
| num_workers=args.workers, | |
| ) | |
| if __name__ == "__main__": | |
| main() | |