File size: 1,463 Bytes
4a28d4d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #!/usr/bin/env python
"""Upload this release folder to a Hugging Face model repository."""
from __future__ import annotations
import argparse
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("repo_id", help="Example: your-name/acdir-llada-math500")
parser.add_argument("--private", action="store_true", help="Create/update as a private repo.")
parser.add_argument("--revision", default=None)
return parser.parse_args()
def main() -> None:
args = parse_args()
from huggingface_hub import HfApi
api = HfApi()
api.create_repo(
repo_id=args.repo_id,
repo_type="model",
private=bool(args.private),
exist_ok=True,
)
api.upload_folder(
folder_path=str(ROOT),
repo_id=args.repo_id,
repo_type="model",
revision=args.revision,
ignore_patterns=[
".git/*",
".cache/*",
".tmp/*",
"outputs/*",
"logs/*",
"tmp/*",
"lmdeploy_direct_backup_*",
"*.out",
"*.err",
"*.log",
"__pycache__/*",
"**/__pycache__/*",
"*.pyc",
"*.pyo",
],
)
print(f"Uploaded {ROOT} to https://huggingface.co/{args.repo_id}")
if __name__ == "__main__":
main()
|