Skip to content

Commit ddbf660

Browse files
committed
Pin Python 3.11 + loosen torch; gracefully handle missing plotly
1 parent f55fb18 commit ddbf660

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

app/_common.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,20 @@
1010

1111
import networkx as nx
1212
import numpy as np
13-
import plotly.graph_objects as go
1413
import streamlit as st
1514

1615
import qqa
1716

17+
try:
18+
import plotly.graph_objects as go
19+
except ModuleNotFoundError as exc: # pragma: no cover - surface a friendlier error
20+
st.error(
21+
"The `plotly` package is required for the dashboard. "
22+
"Add it to `requirements.txt` (or run `pip install plotly`)."
23+
)
24+
st.stop()
25+
raise SystemExit from exc
26+
1827
# Default snippet shown in the Custom-problem editor. It implements a simple
1928
# Sherrington–Kirkpatrick-style spin glass that the user can adapt freely.
2029
DEFAULT_CUSTOM_SNIPPET = '''import torch

requirements.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@
1111
# only consumed by pip-based deploy targets (Streamlit Community Cloud,
1212
# Hugging Face Spaces, Render, etc.).
1313

14+
# CPU-only PyTorch wheel (avoids the 900MB CUDA build that would blow
15+
# through the 1GB Streamlit Community Cloud image budget).
1416
--extra-index-url https://download.pytorch.org/whl/cpu
15-
torch==2.4.1+cpu
17+
torch>=2.2,<2.8
1618

17-
numpy>=1.24
19+
numpy>=1.24,<3
1820
networkx>=3.1
1921
scipy>=1.11
2022
matplotlib>=3.8
2123
tqdm>=4.66
2224

23-
# Interactive plots + GUI
25+
# Interactive plots + GUI (REQUIRED by app/_common.py at import time).
2426
plotly>=5.17
2527
pandas>=2.0
2628
streamlit>=1.30
2729

28-
# Install this repository (reads pyproject.toml)
30+
# Install this repository so ``import qqa`` works inside the app.
2931
.

runtime.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-3.11

0 commit comments

Comments
 (0)