Download scripts/push_to_hf.py from continuum-oss/ccrb: direct link, hf CLI and curl.
- Browser
- Download file 1.86 kB
-
https://huggingface.co/datasets/continuum-oss/ccrb/resolve/main/scripts/push_to_hf.py
- Command line
-
hf download hf://datasets/continuum-oss/ccrb/scripts/push_to_hf.py
-
curl -L -o push_to_hf.py https://huggingface.co/datasets/continuum-oss/ccrb/resolve/main/scripts/push_to_hf.py
1.86 kB
| """Upload the exported `hf_dist/` CCRB benchmark directory to Hugging Face Hub.""" | |
| from __future__ import annotations | |
| import argparse | |
| import os | |
| import sys | |
| from pathlib import Path | |
| def main(argv: list[str] | None = None) -> int: | |
| parser = argparse.ArgumentParser(description="Push CCRB hf_dist/ to Hugging Face Hub.") | |
| parser.add_argument("--folder", type=Path, default=Path("hf_dist")) | |
| parser.add_argument("--repo-id", type=str, default="continuum-oss/ccrb") | |
| parser.add_argument("--private", action="store_true", help="Create repo as private if new.") | |
| parser.add_argument( | |
| "--commit-message", | |
| type=str, | |
| default="Upload CCRB v0.2-dev cybersecurity retrieval benchmark", | |
| ) | |
| args = parser.parse_args(argv) | |
| if not args.folder.exists(): | |
| print( | |
| f"Export folder {args.folder} not found. Run `python scripts/export_huggingface.py` first.", | |
| file=sys.stderr, | |
| ) | |
| return 1 | |
| try: | |
| from huggingface_hub import HfApi # type: ignore[import-not-found] | |
| except ImportError: | |
| print( | |
| "Missing `huggingface_hub`. Install it with:\n pip install huggingface_hub", | |
| file=sys.stderr, | |
| ) | |
| return 1 | |
| token = os.environ.get("HF_TOKEN") or None | |
| api = HfApi(token=token) | |
| api.create_repo( | |
| repo_id=args.repo_id, | |
| repo_type="dataset", | |
| private=args.private, | |
| exist_ok=True, | |
| ) | |
| print(f"[hf] Uploading {args.folder} -> https://huggingface.co/datasets/{args.repo_id}") | |
| api.upload_folder( | |
| folder_path=str(args.folder), | |
| repo_id=args.repo_id, | |
| repo_type="dataset", | |
| commit_message=args.commit_message, | |
| ) | |
| print(f"[done] Published to https://huggingface.co/datasets/{args.repo_id}") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |