Download scripts/push_hf.py from tchbcb/qwenjev: direct link, hf CLI and curl.
- Browser
- Download file 2.3 kB
-
https://huggingface.co/tchbcb/qwenjev/resolve/main/scripts/push_hf.py
- Command line
-
hf download hf://tchbcb/qwenjev/scripts/push_hf.py
-
curl -L -o push_hf.py https://huggingface.co/tchbcb/qwenjev/resolve/main/scripts/push_hf.py
2.3 kB
| """Push this repository to a public HuggingFace model repo. | |
| Usage: | |
| HF_TOKEN=hf_xxx python scripts/push_hf.py [--repo tchbcb/qwenjev] | |
| Notes: | |
| * the token is read from the environment or ~/.secrets - never committed; | |
| * the repo is created public (repo_type='model'); | |
| * README.md is intentionally left EMPTY per the project owner's request. | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import os | |
| import sys | |
| from pathlib import Path | |
| REPO_ROOT = Path(__file__).resolve().parents[1] | |
| DEFAULT_REPO = "tchbcb/qwenjev" | |
| def resolve_token() -> str: | |
| token = os.environ.get("HF_TOKEN", "").strip() | |
| if token: | |
| return token | |
| for p in (Path.home() / ".secrets" / "hf_token", | |
| Path("/home/z/my-project/.secrets/hf_token")): | |
| if p.exists(): | |
| return p.read_text().strip() | |
| raise SystemExit("no HF_TOKEN found (env var or ~/.secrets/hf_token)") | |
| def main() -> None: | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--repo", default=DEFAULT_REPO) | |
| args = ap.parse_args() | |
| from huggingface_hub import HfApi | |
| api = HfApi(token=resolve_token()) | |
| me = api.whoami() | |
| print(f"authenticated as: {me.get('name')} (role={me.get('auth', {}).get('accessToken', {}).get('role')})") | |
| # never upload regenerable artifacts or secrets to the hub | |
| ignore_patterns = [ | |
| ".git*", ".secrets/*", ".env", "*.token", | |
| "checkpoints/*", "data/traces/*", "data/dataset/*", | |
| "environment_files/*", "build/*", "kaggle_kernel/*", | |
| "__pycache__/*", "*.pyc", ".venv/*", ".pytest_cache/*", | |
| "*.pt", "*.parquet", "eval_report.json", ".ruff_cache/*", | |
| ] | |
| api.create_repo(repo_id=args.repo, repo_type="model", private=True, | |
| exist_ok=True) # create private first, flip to public after upload | |
| api.upload_folder( | |
| repo_id=args.repo, | |
| repo_type="model", | |
| folder_path=str(REPO_ROOT), | |
| ignore_patterns=ignore_patterns, | |
| commit_message="QwenJev v0.4.3: 25-public-games eval in-repo (run_eval incremental report, fetch_games, CPU feasibility verified)", | |
| ) | |
| api.update_repo_settings(repo_id=args.repo, repo_type="model", private=False) | |
| print(f"public repo ready -> https://huggingface.co/{args.repo}") | |
| if __name__ == "__main__": | |
| main() | |