Spaces:
Paused
Paused
Your Name
Claude
commited on
Commit
·
ac14d6f
1
Parent(s):
45cf63e
Fix: Add HF_TOKEN authentication to dataset downloads
Browse filesThe download_from_dataset() function now passes the HF_TOKEN
to hf_hub_download() for authentication when accessing private datasets.
This fixes the "Embeddings not loaded!" error on the HuggingFace Space.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- foundation_engine.py +7 -1
foundation_engine.py
CHANGED
|
@@ -234,6 +234,7 @@ def download_from_dataset(filename):
|
|
| 234 |
"""Download file from HF Dataset if not present locally"""
|
| 235 |
from huggingface_hub import hf_hub_download
|
| 236 |
import tempfile
|
|
|
|
| 237 |
|
| 238 |
# Use /tmp for downloads (has write permissions in Docker)
|
| 239 |
download_dir = Path("/tmp/foundation_data")
|
|
@@ -247,12 +248,17 @@ def download_from_dataset(filename):
|
|
| 247 |
|
| 248 |
try:
|
| 249 |
logger.info(f"Downloading {filename} from {DATASET_REPO}...")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
downloaded_file = hf_hub_download(
|
| 251 |
repo_id=DATASET_REPO,
|
| 252 |
filename=filename,
|
| 253 |
repo_type="dataset",
|
| 254 |
local_dir=download_dir,
|
| 255 |
-
local_dir_use_symlinks=False
|
|
|
|
| 256 |
)
|
| 257 |
logger.info(f"Downloaded {filename}")
|
| 258 |
return Path(downloaded_file)
|
|
|
|
| 234 |
"""Download file from HF Dataset if not present locally"""
|
| 235 |
from huggingface_hub import hf_hub_download
|
| 236 |
import tempfile
|
| 237 |
+
import os
|
| 238 |
|
| 239 |
# Use /tmp for downloads (has write permissions in Docker)
|
| 240 |
download_dir = Path("/tmp/foundation_data")
|
|
|
|
| 248 |
|
| 249 |
try:
|
| 250 |
logger.info(f"Downloading {filename} from {DATASET_REPO}...")
|
| 251 |
+
|
| 252 |
+
# Get HF_TOKEN from environment or global hf_token variable
|
| 253 |
+
token = os.environ.get('HF_TOKEN') or hf_token
|
| 254 |
+
|
| 255 |
downloaded_file = hf_hub_download(
|
| 256 |
repo_id=DATASET_REPO,
|
| 257 |
filename=filename,
|
| 258 |
repo_type="dataset",
|
| 259 |
local_dir=download_dir,
|
| 260 |
+
local_dir_use_symlinks=False,
|
| 261 |
+
token=token # Pass authentication token
|
| 262 |
)
|
| 263 |
logger.info(f"Downloaded {filename}")
|
| 264 |
return Path(downloaded_file)
|