Datasets:
File size: 1,165 Bytes
f01cda9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | """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)
|