Skip to content

Commit 3d30d5f

Browse files
committed
Migrate deprecated use_container_width=True to width='stretch'
Streamlit 1.56 flags use_container_width for removal after 2025-12-31; our Community Cloud logs were flooded with "Please replace use_container_width with width." warnings on every rerun. Switch the Plotly / DataFrame calls in the app package to the new keyword-only `width='stretch'` form. Behaviour is identical; logs stay clean and the app is future-proof against the upcoming removal. Made-with: Cursor
1 parent baf3bbb commit 3d30d5f

4 files changed

Lines changed: 17 additions & 17 deletions

File tree

app/_common.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def _graph_preview(g: nx.Graph, title: str) -> None:
584584
yaxis={"visible": False},
585585
height=380,
586586
)
587-
st.plotly_chart(fig, use_container_width=True)
587+
st.plotly_chart(fig, width='stretch')
588588

589589

590590
def _coupling_preview(J: np.ndarray, title: str) -> None:
@@ -595,7 +595,7 @@ def _coupling_preview(J: np.ndarray, title: str) -> None:
595595
plot_bgcolor="rgba(0,0,0,0)",
596596
height=400,
597597
)
598-
st.plotly_chart(fig, use_container_width=True)
598+
st.plotly_chart(fig, width='stretch')
599599

600600

601601
def preview_problem(problem: Any, cfg: dict) -> None:
@@ -619,7 +619,7 @@ def preview_problem(problem: Any, cfg: dict) -> None:
619619
plot_bgcolor="rgba(0,0,0,0)",
620620
height=400,
621621
)
622-
st.plotly_chart(fig, use_container_width=True)
622+
st.plotly_chart(fig, width='stretch')
623623
return
624624
if kind == "custom":
625625
import torch

app/pages/1_Solve.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def on_epoch_end(self, state: CallbackState) -> None:
148148
legend={"x": 0.01, "y": 0.02, "bgcolor": "rgba(255,255,255,0.6)"},
149149
)
150150
)
151-
self.chart_holder.plotly_chart(fig, use_container_width=True)
151+
self.chart_holder.plotly_chart(fig, width='stretch')
152152

153153
# --- Population heatmap: replicas sorted by best-so-far --------
154154
pop = np.stack(self.pop, axis=1) # (sol_size, T)
@@ -192,7 +192,7 @@ def on_epoch_end(self, state: CallbackState) -> None:
192192
legend={"x": 0.01, "y": 0.99, "bgcolor": "rgba(255,255,255,0.6)"},
193193
)
194194
)
195-
self.pop_holder.plotly_chart(pop_fig, use_container_width=True)
195+
self.pop_holder.plotly_chart(pop_fig, width='stretch')
196196

197197
# --- Diversity curve: std across replicas vs epoch --------------
198198
div_fig = go.Figure()
@@ -216,7 +216,7 @@ def on_epoch_end(self, state: CallbackState) -> None:
216216
showlegend=False,
217217
)
218218
)
219-
self.diversity_holder.plotly_chart(div_fig, use_container_width=True)
219+
self.diversity_holder.plotly_chart(div_fig, width='stretch')
220220

221221

222222
run = st.button("▶ Run QQA", type="primary")

app/pages/2_Visualize.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ def _retheme(fig):
6969

7070
with tab_hist:
7171
fig = viz.plot_history(result, backend="plotly", show=False)
72-
st.plotly_chart(_retheme(fig), use_container_width=True)
72+
st.plotly_chart(_retheme(fig), width='stretch')
7373

7474
with tab_best:
7575
fig = viz.plot_best_trajectory(result, backend="plotly", show=False)
76-
st.plotly_chart(_retheme(fig), use_container_width=True)
76+
st.plotly_chart(_retheme(fig), width='stretch')
7777

7878
with tab_sched:
7979
if result.history and "bg" in result.history:
@@ -97,12 +97,12 @@ def _retheme(fig):
9797
height=400,
9898
)
9999
)
100-
st.plotly_chart(fig, use_container_width=True)
100+
st.plotly_chart(fig, width='stretch')
101101

102102
with tab_sol:
103103
try:
104104
fig = viz.plot_solution_heatmap(result, problem=problem, backend="plotly", show=False)
105-
st.plotly_chart(_retheme(fig), use_container_width=True)
105+
st.plotly_chart(_retheme(fig), width='stretch')
106106
except Exception as e:
107107
st.info(f"No solution heatmap available: {e}")
108108

@@ -111,7 +111,7 @@ def _retheme(fig):
111111
st.info("No population snapshots recorded for this run.")
112112
else:
113113
fig = viz.plot_population_evolution(pop_tracker, backend="plotly", show=False)
114-
st.plotly_chart(_retheme(fig), use_container_width=True)
114+
st.plotly_chart(_retheme(fig), width='stretch')
115115
st.caption(
116116
"Each row is one of the `sol_size` replicas (sorted by final loss). "
117117
"Colour encodes per-replica loss."
@@ -123,7 +123,7 @@ def _retheme(fig):
123123
else:
124124
try:
125125
fig = viz.plot_population_embedding(pop_tracker, backend="plotly", show=False)
126-
st.plotly_chart(_retheme(fig), use_container_width=True)
126+
st.plotly_chart(_retheme(fig), width='stretch')
127127
st.caption(
128128
"2D PCA projection of the entire continuous-variable population over time. "
129129
"Each faint grey line is one replica's trajectory; markers are coloured by epoch."
@@ -177,7 +177,7 @@ def _retheme(fig):
177177
"gridcolor": palette()["grid"], "linecolor": palette()["border"]},
178178
)
179179
)
180-
st.plotly_chart(fig, use_container_width=True)
180+
st.plotly_chart(fig, width='stretch')
181181
st.caption("Stacked loss distributions. Early rows (top) → late rows (bottom).")
182182

183183
with tab_fate:
@@ -216,7 +216,7 @@ def _retheme(fig):
216216
height=460,
217217
)
218218
)
219-
st.plotly_chart(fig, use_container_width=True)
219+
st.plotly_chart(fig, width='stretch')
220220
st.caption(
221221
"Top-ranked replicas are drawn in the primary accent, lower-ranked "
222222
"ones fade toward the secondary accent."

app/pages/3_Compare.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,18 @@ def _retheme(fig):
8787

8888
st.success("Sweep complete.")
8989
st.subheader("Results table")
90-
st.dataframe(rows, use_container_width=True)
90+
st.dataframe(rows, width='stretch')
9191

9292
try:
9393
import pandas as pd
9494

9595
df = pd.DataFrame(rows)
9696
fig = viz.plot_parallel_coordinates(df, objective="best_obj", backend="plotly", show=False)
9797
st.subheader("Parallel coordinates")
98-
st.plotly_chart(_retheme(fig), use_container_width=True)
98+
st.plotly_chart(_retheme(fig), width='stretch')
9999
except Exception as e:
100100
st.info(f"Parallel-coordinates unavailable: {e}")
101101

102102
st.subheader("Run comparison")
103103
fig2 = viz.plot_run_comparison(results, labels=labels, backend="plotly", show=False)
104-
st.plotly_chart(_retheme(fig2), use_container_width=True)
104+
st.plotly_chart(_retheme(fig2), width='stretch')

0 commit comments

Comments
 (0)