Spaces:
Running on Zero
Running on Zero
Download diagnostics/2026-10-30-lab-hyperparameter-grid/scripts/build_workspaces.py from bozdaglab/BioLM-NET-Workbench: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/bozdaglab/BioLM-NET-Workbench/resolve/refs%2Fpr%2F3/diagnostics/2026-10-30-lab-hyperparameter-grid/scripts/build_workspaces.py
- Command line
-
hf download hf://spaces/bozdaglab/BioLM-NET-Workbench@refs/pr/3/diagnostics/2026-10-30-lab-hyperparameter-grid/scripts/build_workspaces.py
-
curl -L -o build_workspaces.py https://huggingface.co/spaces/bozdaglab/BioLM-NET-Workbench/resolve/refs%2Fpr%2F3/diagnostics/2026-10-30-lab-hyperparameter-grid/scripts/build_workspaces.py
1.2 kB
| """Build and cache the BRCA workspace with both GenePT files, using the app's own prepare step. | |
| Usage: build_workspaces.py <cache_dir>""" | |
| import pickle | |
| import sys | |
| from pathlib import Path | |
| import numpy as np | |
| import app | |
| CACHE = Path(sys.argv[1]) | |
| CACHE.mkdir(parents=True, exist_ok=True) | |
| OPTIONS = { | |
| "bulk": "Bulk · large-3 context", | |
| "singlecell": "Single-cell · cell type, tissue, drug & pathway", | |
| } | |
| for key, option in OPTIONS.items(): | |
| result = app.prepare_workspace( | |
| "BioLM-NET examples", "BRCA", "", None, None, None, None, None, None, None, | |
| True, option, progress=lambda *a, **k: None, | |
| ) | |
| workspace = result[0] | |
| if workspace is None: | |
| sys.exit(f"{key}: {result[1]}") | |
| (CACHE / f"workspace_BRCA_{key}.pkl").write_bytes(pickle.dumps(workspace)) | |
| for name, branch in (("gene", workspace.gene_branch), ("dna", workspace.dna_branch)): | |
| m = branch.biological_mask | |
| print(f"{key:10s} {name}: inputs={m.shape[0]} hidden genes={m.shape[1]} edges={(m > 0).sum()} " | |
| f"median in-degree={np.median((m > 0).sum(0)):.0f} pathways={len(branch.pathways)} " | |
| f"GenePT dim={branch.embeddings.shape[1]}", flush=True) | |