Quazim0t0 commited on
Commit
92b7758
·
verified ·
1 Parent(s): 5c7223f

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -28,14 +28,13 @@ MODEL_REPO = os.environ.get("DAISYCHAIN_REPO", "DaisyChainAI/daisychain-genomics
28
  DEVICE = os.environ.get("DAISYCHAIN_DEVICE", "cpu")
29
 
30
  # code + tokenizer + router are bundled here; pull the big specialist weights from the
31
- # model repo on first launch (keeps the Space repo light).
 
32
  if not os.path.exists(os.path.join(HERE, "eukaryote", "model.safetensors")):
33
- try:
34
- from huggingface_hub import snapshot_download
35
- snapshot_download(MODEL_REPO, local_dir=HERE,
36
- allow_patterns=["*/model.safetensors", "tokenizer.json", "router2.pt"])
37
- except Exception:
38
- pass
39
 
40
  _DC = {"m": None} # lazy-loaded so CUDA is never touched at import
41
  _WARMED = {"done": False} # so the "loading" notice only shows on the first run
 
28
  DEVICE = os.environ.get("DAISYCHAIN_DEVICE", "cpu")
29
 
30
  # code + tokenizer + router are bundled here; pull the big specialist weights from the
31
+ # (gated) model repo on first launch using the HF_TOKEN Space secret. No silent
32
+ # swallow — if the download fails we want a visible error, not a broken-but-running app.
33
  if not os.path.exists(os.path.join(HERE, "eukaryote", "model.safetensors")):
34
+ from huggingface_hub import snapshot_download
35
+ snapshot_download(MODEL_REPO, local_dir=HERE,
36
+ token=os.environ.get("HF_TOKEN"),
37
+ allow_patterns=["*/model.safetensors", "tokenizer.json", "router2.pt"])
 
 
38
 
39
  _DC = {"m": None} # lazy-loaded so CUDA is never touched at import
40
  _WARMED = {"done": False} # so the "loading" notice only shows on the first run