Spaces:
Running
Running
devjas1
commited on
Commit
·
4dcddf5
1
Parent(s):
d7065c4
(DEBUG/FIX): Status box resets with file/model changes
Browse files- updated 'reset_results()' to reset 'status_message' and 'status_type' session state keys.
- ensures UI reflects fresh state after model swap.
Resolved 'TypeError: 'str / str' 'Path(...)':
- converted 'SAMPLE_DATA_DIR' to 'Path' object at definition
- prevented path-join operation failure inside 'on_sample_change()' callback
app.py
CHANGED
@@ -53,7 +53,7 @@ st.markdown("""
|
|
53 |
|
54 |
# Constants
|
55 |
TARGET_LEN = 500
|
56 |
-
SAMPLE_DATA_DIR = "sample_data"
|
57 |
# Prefer env var, else 'model_weights' if present; else canonical 'outputs'
|
58 |
MODEL_WEIGHTS_DIR = (
|
59 |
os.getenv("WEIGHTS_DIR")
|
@@ -329,8 +329,6 @@ def on_input_mode_change():
|
|
329 |
st.session_state["sample_select"] = "-- Select Sample --"
|
330 |
# 🔧 Reset when switching modes to prevent stale right-column visuals
|
331 |
reset_results("Switched input mode")
|
332 |
-
# Also clear te previous upload widget value to avoid confusion
|
333 |
-
st.session_state["upload_txt"] = None
|
334 |
|
335 |
|
336 |
def on_model_change():
|
@@ -348,7 +346,7 @@ def reset_results(reason: str = ""):
|
|
348 |
st.session_state["log_messages"] = []
|
349 |
# ||== Always reset the status box ==||
|
350 |
st.session_state["status_message"] = (
|
351 |
-
f"{reason}
|
352 |
if reason else "Ready to analyze polymer spectra 🔬"
|
353 |
)
|
354 |
st.session_state["status_type"] = "info"
|
|
|
53 |
|
54 |
# Constants
|
55 |
TARGET_LEN = 500
|
56 |
+
SAMPLE_DATA_DIR = Path("sample_data")
|
57 |
# Prefer env var, else 'model_weights' if present; else canonical 'outputs'
|
58 |
MODEL_WEIGHTS_DIR = (
|
59 |
os.getenv("WEIGHTS_DIR")
|
|
|
329 |
st.session_state["sample_select"] = "-- Select Sample --"
|
330 |
# 🔧 Reset when switching modes to prevent stale right-column visuals
|
331 |
reset_results("Switched input mode")
|
|
|
|
|
332 |
|
333 |
|
334 |
def on_model_change():
|
|
|
346 |
st.session_state["log_messages"] = []
|
347 |
# ||== Always reset the status box ==||
|
348 |
st.session_state["status_message"] = (
|
349 |
+
f"ℹ️ {reason}"
|
350 |
if reason else "Ready to analyze polymer spectra 🔬"
|
351 |
)
|
352 |
st.session_state["status_type"] = "info"
|