"""Fetch a pinned public QEV MLX q8 snapshot; review qev_mlx.py before running it."""
from pathlib import Path
import subprocess
ROOT = Path(__file__).resolve().parent
REVISION = "799c195002ff81181e124c6ecda0ab18558da97d"
BASE = "https://huggingface.co/labqoat/qev-0.8b-MLX/resolve/" + REVISION + "/"
FILES = ["q8/chat_template.jinja", "q8/config.json", "q8/model.safetensors", "q8/model.safetensors.index.json", "q8/qev_config.json", "q8/tokenizer.json", "q8/tokenizer_config.json", "qev_mlx.py"]
(ROOT / "model-q8").mkdir(exist_ok=True)
for name in FILES:
    target = ROOT / "model-q8" / name.split("/")[-1] if name.startswith("q8/") else ROOT / name
    temporary = target.with_suffix(target.suffix + ".partial")
    subprocess.run(["curl", "--fail", "--location", "--show-error", "--max-time", "600", BASE + name, "-o", str(temporary)], check=True)
    temporary.replace(target)
    print(name, target.stat().st_size)
print("Downloaded pinned public files. Review qev_mlx.py before inference.")
