"""Fetch only the pinned public base model; one file transfer at a time.""" import json import os import time from pathlib import Path os.environ["HF_HUB_DISABLE_XET"] = "1" from huggingface_hub import snapshot_download MODEL_ID = "Qwen/Qwen2.5-0.5B" REVISION = "060db6499f32faf8b98477b0a26969ef7d8b9987" destination = Path.home() / "ai/models/opensysone" / f"Qwen2.5-0.5B-{REVISION[:8]}" for attempt in range(3): try: snapshot_download( MODEL_ID, revision=REVISION, local_dir=destination, max_workers=1, allow_patterns=["*.json", "*.safetensors", "*.txt", "LICENSE", "README.md"], ) break except Exception as exc: if attempt == 2: raise print(f"Download interrupted ({type(exc).__name__}); resuming attempt {attempt + 2}", flush=True) time.sleep(5) (destination / "opensysone-provenance.json").write_text(json.dumps({ "model_id": MODEL_ID, "revision": REVISION, }, indent=2) + "\n") print(destination, flush=True)