stevekor commited on
Commit
095f16a
·
1 Parent(s): 7f30925

Default demo repo_types to model; clarify errors

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -29,6 +29,9 @@ HUB_REPO_ID = os.getenv("LWM_SPECTRO_DEMO_REPO_ID", "wi-lab/lwm-spectro")
29
  HUB_REVISION = os.getenv("LWM_SPECTRO_DEMO_REVISION") # optional git sha / tag / branch
30
  HUB_DEMO_DATA_FILENAME = os.getenv("LWM_SPECTRO_DEMO_DATA_FILENAME", "demo_data.pt")
31
  HUB_MOE_DATA_FILENAME = os.getenv("LWM_SPECTRO_MOE_DATA_FILENAME", "demo_data_moe.pt")
 
 
 
32
 
33
 
34
  def _get_hf_token() -> str | None:
@@ -207,9 +210,9 @@ def _ensure_local_file(local_path: Path, hub_filename: str) -> Optional[Path]:
207
  # even when HF_TOKEN env var is not explicitly set).
208
  token = HF_TOKEN or True
209
 
210
- # Try multiple repo types because the artifact may live under a model or dataset repo.
211
  last_exc: Exception | None = None
212
- for repo_type in ("model", "dataset"):
213
  try:
214
  cached = hf_hub_download(
215
  repo_id=HUB_REPO_ID,
@@ -243,7 +246,8 @@ def _ensure_local_file(local_path: Path, hub_filename: str) -> Optional[Path]:
243
  err = err[:240] + "..."
244
  LAST_DEMO_DOWNLOAD_ERROR = err
245
  print(
246
- f"[WARN] Could not download {hub_filename} from Hub ({last_exc}) or Space repo ({exc}); continuing without it."
 
247
  )
248
  return None
249
 
@@ -921,7 +925,7 @@ DATASET_STATUS = (
921
  f"MoE embeddings: {'yes' if has_moe_embeddings else 'no'} | "
922
  f"HF token detected: {'yes' if HF_TOKEN else 'no'} | "
923
  f"Synthetic fallback: {'yes' if USING_SYNTHETIC_DATA else 'no'} | "
924
- f"Demo repo: {HUB_REPO_ID}@{HUB_REVISION or 'main'}"
925
  )
926
 
927
  if LAST_DEMO_DOWNLOAD_ERROR:
 
29
  HUB_REVISION = os.getenv("LWM_SPECTRO_DEMO_REVISION") # optional git sha / tag / branch
30
  HUB_DEMO_DATA_FILENAME = os.getenv("LWM_SPECTRO_DEMO_DATA_FILENAME", "demo_data.pt")
31
  HUB_MOE_DATA_FILENAME = os.getenv("LWM_SPECTRO_MOE_DATA_FILENAME", "demo_data_moe.pt")
32
+ HUB_REPO_TYPES = tuple(
33
+ t.strip() for t in os.getenv("LWM_SPECTRO_DEMO_REPO_TYPES", "model").split(",") if t.strip()
34
+ )
35
 
36
 
37
  def _get_hf_token() -> str | None:
 
210
  # even when HF_TOKEN env var is not explicitly set).
211
  token = HF_TOKEN or True
212
 
213
+ # Try configured repo types (default: model). This Space historically used a model repo.
214
  last_exc: Exception | None = None
215
+ for repo_type in HUB_REPO_TYPES:
216
  try:
217
  cached = hf_hub_download(
218
  repo_id=HUB_REPO_ID,
 
246
  err = err[:240] + "..."
247
  LAST_DEMO_DOWNLOAD_ERROR = err
248
  print(
249
+ f"[WARN] Could not download {hub_filename} from Hub (repo_id={HUB_REPO_ID}, repo_types={HUB_REPO_TYPES}, revision={HUB_REVISION or 'main'}: {last_exc}) "
250
+ f"or Space repo ({exc}); continuing without it."
251
  )
252
  return None
253
 
 
925
  f"MoE embeddings: {'yes' if has_moe_embeddings else 'no'} | "
926
  f"HF token detected: {'yes' if HF_TOKEN else 'no'} | "
927
  f"Synthetic fallback: {'yes' if USING_SYNTHETIC_DATA else 'no'} | "
928
+ f"Demo repo: {HUB_REPO_ID}@{HUB_REVISION or 'main'} ({','.join(HUB_REPO_TYPES)})"
929
  )
930
 
931
  if LAST_DEMO_DOWNLOAD_ERROR: