anurag-raapid's picture
Upload app, Docker, staging parquet only (no venv)
4b988e0 verified
|
Raw
History Blame Contribute Delete
4.04 kB
metadata
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.

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

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)

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

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.

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)

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

# 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