sequential-router-v2 / scripts /download_models.py
divy123's picture
Add files using upload-large-folder tool
886afe0 verified
Raw History Blame Contribute Delete
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)