From fc16664c5e05010f5e7314c098cd9ede87a05ce6 Mon Sep 17 00:00:00 2001 From: Sven Geboers Date: Sun, 29 Mar 2026 21:10:33 +0200 Subject: [PATCH] fix: open DuckDB read_only in trajectory helpers to avoid lock conflict with Streamlit Both _load_window_ids and _load_mp_vectors_for_window only read from the DB. Opening without read_only=True caused an IOException when Streamlit already held a read-only lock, silently returning an empty scree plot. --- analysis/trajectory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/analysis/trajectory.py b/analysis/trajectory.py index a54c623..c2dae34 100644 --- a/analysis/trajectory.py +++ b/analysis/trajectory.py @@ -109,7 +109,7 @@ def _procrustes_align_windows( def _load_window_ids(db_path: str) -> List[str]: """Return all distinct window IDs from svd_vectors, in lexicographic order.""" - conn = duckdb.connect(db_path) + conn = duckdb.connect(db_path, read_only=True) rows = conn.execute( "SELECT DISTINCT window_id FROM svd_vectors WHERE entity_type = 'mp' ORDER BY window_id" ).fetchall() @@ -118,7 +118,7 @@ def _load_window_ids(db_path: str) -> List[str]: def _load_mp_vectors_for_window(db_path: str, window_id: str) -> Dict[str, np.ndarray]: - conn = duckdb.connect(db_path) + conn = duckdb.connect(db_path, read_only=True) rows = conn.execute( "SELECT entity_id, vector FROM svd_vectors WHERE window_id = ? AND entity_type = 'mp'", (window_id,),