Spaces:
Sleeping
Sleeping
devjas1
commited on
Commit
·
65e5904
1
Parent(s):
21823a6
FIX(core): Refine results management and UI for dashboard integration
Browse filesThis commit includes necessary updates to existing modules to support and
integrate with the new multi-page architecture and dashboard.
- `utils/results_manager.py`:
- Enhanced `add_results()` to store raw and resampled spectrum data,
enabling the interactive spectrum viewer on the dashboard.
- Added `get_spectrum_data_for_file()` for efficient data retrieval.
- Implemented a robust `clear_all_results()` callback.
- `static/style.css`:
- Added minor style adjustments to ensure visual consistency
across the new multi-page layout and dashboard components.
- static/style.css +42 -2
- utils/results_manager.py +53 -28
static/style.css
CHANGED
|
@@ -140,9 +140,49 @@ div[data-testid="stMetricLabel"] {
|
|
| 140 |
/* ====== Interactivity & Accessibility ====== */
|
| 141 |
:focus-visible {
|
| 142 |
/* The focus outline now uses the theme's primary color */
|
| 143 |
-
outline:
|
| 144 |
outline-offset: 2px;
|
| 145 |
border-radius: 8px;
|
| 146 |
}
|
| 147 |
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
/* ====== Interactivity & Accessibility ====== */
|
| 141 |
:focus-visible {
|
| 142 |
/* The focus outline now uses the theme's primary color */
|
| 143 |
+
outline: 20px solid var(--primary);
|
| 144 |
outline-offset: 2px;
|
| 145 |
border-radius: 8px;
|
| 146 |
}
|
| 147 |
|
| 148 |
+
.st-key-csv-button,
|
| 149 |
+
.st-key-json-button,
|
| 150 |
+
.st-key-clearall-button {
|
| 151 |
+
display: block;
|
| 152 |
+
border: 1px double #1a1a1a2d;
|
| 153 |
+
max-width: 100%;
|
| 154 |
+
border-radius: 8px;
|
| 155 |
+
background-color: #F0F0ED;
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
.st-key-page-link-container {
|
| 161 |
+
padding: 5px;
|
| 162 |
+
display: inline-block;
|
| 163 |
+
justify-items: center;
|
| 164 |
+
align-self: center;
|
| 165 |
+
align-content: center;
|
| 166 |
+
border: 1px double #1a1a1a2d;
|
| 167 |
+
border-radius: 8px;
|
| 168 |
+
background-color: #F0F0ED;
|
| 169 |
+
max-width: 100%;
|
| 170 |
+
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.st-key-buttons-container {
|
| 174 |
+
display: flex;
|
| 175 |
+
max-width: 100%;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
/* .st-key-csv-button:hover,
|
| 181 |
+
.st-key-json-button:hover,
|
| 182 |
+
.st-key-clearall-button:hover {
|
| 183 |
+
padding: .25px;
|
| 184 |
+
}
|
| 185 |
+
.st-key-page-link {
|
| 186 |
+
color: var(--text-color);
|
| 187 |
+
text-decoration: none;
|
| 188 |
+
}*/
|
utils/results_manager.py
CHANGED
|
@@ -10,6 +10,11 @@ from pathlib import Path
|
|
| 10 |
import io
|
| 11 |
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
class ResultsManager:
|
| 14 |
"""Manages session-wide results for multi-file inference"""
|
| 15 |
|
|
@@ -231,6 +236,7 @@ class ResultsManager:
|
|
| 231 |
)
|
| 232 |
return
|
| 233 |
|
|
|
|
| 234 |
st.subheader(f"Inference Results ({len(df)} files)")
|
| 235 |
|
| 236 |
# ==Summary stats==
|
|
@@ -254,33 +260,52 @@ class ResultsManager:
|
|
| 254 |
|
| 255 |
# ==Results Table==
|
| 256 |
st.dataframe(df, use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
|
| 258 |
# ==Export Button==
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
import io
|
| 11 |
|
| 12 |
|
| 13 |
+
def local_css(file_name):
|
| 14 |
+
with open(file_name, encoding="utf-8") as f:
|
| 15 |
+
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
class ResultsManager:
|
| 19 |
"""Manages session-wide results for multi-file inference"""
|
| 20 |
|
|
|
|
| 236 |
)
|
| 237 |
return
|
| 238 |
|
| 239 |
+
local_css("static/style.css")
|
| 240 |
st.subheader(f"Inference Results ({len(df)} files)")
|
| 241 |
|
| 242 |
# ==Summary stats==
|
|
|
|
| 260 |
|
| 261 |
# ==Results Table==
|
| 262 |
st.dataframe(df, use_container_width=True)
|
| 263 |
+
with st.container(border=None, key="page-link-container"):
|
| 264 |
+
st.page_link(
|
| 265 |
+
"pages/2_📊_dashboard.py",
|
| 266 |
+
label="Inference Analysis Dashboard",
|
| 267 |
+
help="Dive deeper into your batch results.",
|
| 268 |
+
use_container_width=False,
|
| 269 |
+
)
|
| 270 |
|
| 271 |
# ==Export Button==
|
| 272 |
+
with st.container(border=None, key="buttons-container"):
|
| 273 |
+
col1, col2, col3 = st.columns([1, 1, 1])
|
| 274 |
+
|
| 275 |
+
with col1:
|
| 276 |
+
csv_data = ResultsManager.export_to_csv()
|
| 277 |
+
if csv_data:
|
| 278 |
+
with st.container(border=None, key="csv-button"):
|
| 279 |
+
st.download_button(
|
| 280 |
+
label="Download CSV",
|
| 281 |
+
data=csv_data,
|
| 282 |
+
file_name=f"polymer_results_{datetime.now().strftime('%Y%m%d_%H%M%S')}.csv",
|
| 283 |
+
mime="text/csv",
|
| 284 |
+
help="Export Results to CSV",
|
| 285 |
+
use_container_width=True,
|
| 286 |
+
type="tertiary",
|
| 287 |
+
)
|
| 288 |
+
|
| 289 |
+
with col2:
|
| 290 |
+
json_data = ResultsManager.export_to_json()
|
| 291 |
+
if json_data:
|
| 292 |
+
with st.container(border=None, key="json-button"):
|
| 293 |
+
st.download_button(
|
| 294 |
+
label="Download JSON",
|
| 295 |
+
data=json_data,
|
| 296 |
+
file_name=f"polymer_results_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json",
|
| 297 |
+
mime="application/json",
|
| 298 |
+
help="Export Results to JSON",
|
| 299 |
+
type="tertiary",
|
| 300 |
+
use_container_width=True,
|
| 301 |
+
)
|
| 302 |
+
|
| 303 |
+
with col3:
|
| 304 |
+
with st.container(border=None, key="clearall-button"):
|
| 305 |
+
st.button(
|
| 306 |
+
label="Clear All Results",
|
| 307 |
+
help="Clear all stored results",
|
| 308 |
+
on_click=ResultsManager.reset_ephemeral_state,
|
| 309 |
+
use_container_width=True,
|
| 310 |
+
type="tertiary",
|
| 311 |
+
)
|