James McCool
commited on
Commit
·
1ced724
1
Parent(s):
c91c33c
Enhance session state management in Streamlit app by clearing non-maintained keys and adding debug output for cleared keys. This improves data handling and provides visibility into session state changes.
Browse files- src/streamlit_app.py +10 -1
src/streamlit_app.py
CHANGED
|
@@ -8,9 +8,18 @@ print(f"Streamlit version: {st.__version__}")
|
|
| 8 |
|
| 9 |
maintained_keys = ['tab_selector', 'site_selectbox', 'view_selectbox']
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
if key not in maintained_keys:
|
| 13 |
del st.session_state[key]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
st.set_page_config(layout="wide")
|
| 16 |
|
|
|
|
| 8 |
|
| 9 |
maintained_keys = ['tab_selector', 'site_selectbox', 'view_selectbox']
|
| 10 |
|
| 11 |
+
# Get all current keys and clear them (except maintained ones)
|
| 12 |
+
all_keys = list(st.session_state.keys())
|
| 13 |
+
cleared_keys = []
|
| 14 |
+
|
| 15 |
+
for key in all_keys:
|
| 16 |
if key not in maintained_keys:
|
| 17 |
del st.session_state[key]
|
| 18 |
+
cleared_keys.append(key)
|
| 19 |
+
|
| 20 |
+
# Debug: Print what was cleared (you can remove this later)
|
| 21 |
+
if cleared_keys:
|
| 22 |
+
print(f"Cleared keys: {cleared_keys}")
|
| 23 |
|
| 24 |
st.set_page_config(layout="wide")
|
| 25 |
|