Datasets:
Download scripts/download_models.py from divy123/sequential-router-v2: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/datasets/divy123/sequential-router-v2/resolve/main/scripts/download_models.py
- Command line
-
hf download hf://datasets/divy123/sequential-router-v2/scripts/download_models.py
-
curl -L -o download_models.py https://huggingface.co/datasets/divy123/sequential-router-v2/resolve/main/scripts/download_models.py
1.17 kB
| """Sequential, resumable, pinned model downloads into /mnt/localssd/models (one at a time: no tokenizer/download races).""" | |
| import json, os, sys | |
| os.environ["HF_HOME"] = "/mnt/localssd/hf_cache" | |
| from huggingface_hub import HfApi, snapshot_download | |
| spec = json.load(open("/mnt/localssd/seqroute1m/scripts/models_requested.json")) | |
| only = set(sys.argv[1:]) | |
| api = HfApi() | |
| for m in spec: | |
| if only and m["id"] not in only: | |
| continue | |
| dest = f"/mnt/localssd/models/{m['id']}" | |
| if os.path.exists(dest + "/.download_complete"): | |
| continue | |
| repo = m["repo"] | |
| try: | |
| sha = api.model_info(repo).sha | |
| snapshot_download(repo, revision=sha, local_dir=dest, max_workers=8, | |
| allow_patterns=["*.json", "*.safetensors", "*.model", "*.txt", "tokenizer*", "*.jinja", "*.py", "tekken*"], | |
| ignore_patterns=["consolidated*", "original/*", "metal/*", "*.gguf", "*.pth", "*.bin"]) | |
| open(dest + "/.download_complete", "w").write(f"{repo}@{sha}\n") | |
| print("done", m["id"], repo, sha, flush=True) | |
| except Exception as e: | |
| print("FAILED", m["id"], repo, repr(e)[:200], flush=True) | |