Spaces:
Sleeping
Sleeping
Use HF_TOKEN env var for gated model access
Browse files
scan.py
CHANGED
|
@@ -7,7 +7,7 @@ ModelAtlas reference database. No weight download needed — uses config.json on
|
|
| 7 |
This is the heart of the modeldna 'test before you download' feature.
|
| 8 |
"""
|
| 9 |
from __future__ import annotations
|
| 10 |
-
import json, hashlib, re, time
|
| 11 |
from datetime import datetime, timezone
|
| 12 |
from pathlib import Path
|
| 13 |
from typing import Optional
|
|
@@ -255,7 +255,11 @@ def fetch_config(model_id: str) -> Optional[dict]:
|
|
| 255 |
"""Fetch config.json from HuggingFace. Returns None on failure."""
|
| 256 |
url = f"{HF_API}/{model_id}/resolve/main/config.json"
|
| 257 |
try:
|
| 258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
r.raise_for_status()
|
| 260 |
return r.json()
|
| 261 |
except Exception as e:
|
|
|
|
| 7 |
This is the heart of the modeldna 'test before you download' feature.
|
| 8 |
"""
|
| 9 |
from __future__ import annotations
|
| 10 |
+
import json, hashlib, os, re, time
|
| 11 |
from datetime import datetime, timezone
|
| 12 |
from pathlib import Path
|
| 13 |
from typing import Optional
|
|
|
|
| 255 |
"""Fetch config.json from HuggingFace. Returns None on failure."""
|
| 256 |
url = f"{HF_API}/{model_id}/resolve/main/config.json"
|
| 257 |
try:
|
| 258 |
+
headers = {}
|
| 259 |
+
token = os.environ.get("HF_TOKEN", "")
|
| 260 |
+
if token:
|
| 261 |
+
headers["Authorization"] = f"Bearer {token}"
|
| 262 |
+
r = requests.get(url, headers=headers, timeout=20)
|
| 263 |
r.raise_for_status()
|
| 264 |
return r.json()
|
| 265 |
except Exception as e:
|