Spaces:
Sleeping
Sleeping
File size: 4,035 Bytes
e16610f 4b988e0 e16610f 4b988e0 e16610f 4b988e0 e16610f 4b988e0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | ---
title: New Graph Visualization
emoji: πΈοΈ
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
startup_duration_timeout: 1h
pinned: false
---
# New Graph Visualization
Interactive clinical graph explorer (Dash + Cytoscape). **FalkorDB** and the Dash app run in one Docker container β same pattern as [UMLS Graph Explorer](https://huggingface.co/spaces/Raapid/umls-graph-explorer-falkordb).
On each cold start the container loads **1.28M nodes** and **7.6M edges** from staging parquet via GRAPH.BULK (~2β5 min), then serves the UI on port **7860**.
**Live Space:** [Raapid/new-graph-visualization](https://huggingface.co/spaces/Raapid/new-graph-visualization)
Default seed: `A27828238` Β· Default hop depth: **2**
## Features
- Explore by AUI or CUI with hop depth 1β15 (HIER_ISA + MRREL)
- Toggle MRHIER, semantic (MRREL), AUIβCUI, same-CUI edges
- Path finder between two AUIs
- SAB / TUI / TTY / **category** filters (category from `graph_nodes.parquet`)
- Layout controls (cose-bilkent recommended)
## Hugging Face Space (Docker)
| Variable | Default | Description |
|----------|---------|-------------|
| `PORT` | `7860` | Dash listen port |
| `FALKORDB_GRAPH` | `clinical_graph` | Graph name |
| `REBUILD_GRAPH` | `1` | Reload graph on container start |
| `SKIP_GRAPH_BUILD` | `0` | Set `1` to skip load (debug) |
| `STAGING_DIR` | `/home/user/app/falkor_staging` | Staging parquet directory |
| `REDIS_ARGS` | `--maxmemory 9gb β¦` | Embedded redis-server memory |
Set Space hardware to **CPU basic** (16 GB RAM) or higher.
### One-time data upload (not in git β ~235 MB total)
```bash
SPACE=Raapid/new-graph-visualization
BASE="/media/anurag/Hard Disk/Graph New"
hf upload $SPACE \
"$BASE/falkor_staging/concepts.parquet" falkor_staging/concepts.parquet \
"$BASE/falkor_staging/mrrel_edges.parquet" falkor_staging/mrrel_edges.parquet \
"$BASE/falkor_staging/hier_edges.parquet" falkor_staging/hier_edges.parquet \
"$BASE/graph_nodes.parquet" graph_nodes.parquet \
--repo-type space \
--commit-message "Add graph staging parquets"
```
## Local Docker
```bash
cd "/media/anurag/Hard Disk/Graph New"
docker build -t new-graph-viz .
docker run --rm --memory=16g -p 7860:7860 new-graph-viz
```
Open [http://localhost:7860](http://localhost:7860).
Requires `falkor_staging/*.parquet` and `graph_nodes.parquet` in the build context (included if present; `bulk_csv/` is excluded via `.dockerignore`).
## Local dev (FalkorDB in separate container)
```bash
docker run -d --name clinical-falkordb -p 6380:6379 --memory 10g falkordb/falkordb:latest
export FALKORDB_PORT=6380 FALKORDB_GRAPH=clinical_graph
python3 build_falkor_graph.py --skip-prepare --rebuild --falkor-port 6380
export PORT=8050
python3 app.py
```
## Data
| File | Role |
|------|------|
| `falkor_staging/concepts.parquet` | FalkorDB Concept nodes |
| `falkor_staging/mrrel_edges.parquet` | MRREL semantic edges |
| `falkor_staging/hier_edges.parquet` | HIER_ISA (from MRHIER) |
| `graph_nodes.parquet` | Category metadata for sidebar filter |
FalkorDB node count (**1,278,278**) matches edge-connected nodes in parquet (orphan nodes excluded at load time).
## Project layout
```
Graph New/
βββ app.py
βββ graph_backend.py
βββ Dockerfile
βββ scripts/entrypoint.sh
βββ falkor_load/ # GRAPH.BULK loader (container startup)
βββ falkor_staging/ # staging parquet (upload to HF separately)
βββ prepare_falkor_staging.py
βββ build_falkor_graph.py # local load helper
βββ graph_nodes.parquet
βββ assets/
βββ requirements.txt
```
## Commands
```bash
# Setup
uv venv .venv && source .venv/bin/activate
uv pip install -r requirements.txt
# Rebuild staging from raw parquet
python3 prepare_falkor_staging.py --connected-only
# Load FalkorDB locally
FALKORDB_BULK_SOCKET_TIMEOUT_S=0 python3 build_falkor_graph.py --skip-prepare --rebuild --falkor-port 6380
# Run app
FALKORDB_PORT=6380 FALKORDB_GRAPH=clinical_graph python3 app.py
```
|