|
4 | 4 | import sys |
5 | 5 | import uuid |
6 | 6 | import time |
| 7 | +import psutil |
7 | 8 | from typing import Any |
8 | 9 | from pathlib import Path |
9 | 10 | from streamlit.components.v1 import html |
|
23 | 24 | # Detect system platform |
24 | 25 | OS_PLATFORM = sys.platform |
25 | 26 |
|
26 | | - |
27 | 27 | # set these variables according to your project |
28 | 28 | APP_NAME = "NuXL" |
29 | 29 | REPOSITORY_NAME = "nuxl-app" |
30 | 30 |
|
| 31 | +@st.fragment(run_every=5) |
| 32 | +def monitor_hardware(): |
| 33 | + cpu_progress = psutil.cpu_percent(interval=None) / 100 |
| 34 | + ram_progress = 1 - psutil.virtual_memory().available / psutil.virtual_memory().total |
| 35 | + |
| 36 | + st.text(f"Ram ({ram_progress * 100:.2f}%)") |
| 37 | + st.progress(ram_progress) |
| 38 | + |
| 39 | + st.text(f"CPU ({cpu_progress * 100:.2f}%)") |
| 40 | + st.progress(cpu_progress) |
| 41 | + |
| 42 | + st.caption(f"Last fetched at: {time.strftime('%H:%M:%S')}") |
31 | 43 |
|
32 | 44 | def load_params(default: bool = False) -> dict[str, Any]: |
33 | 45 | """ |
@@ -359,8 +371,38 @@ def change_workspace(): |
359 | 371 | **{st.session_state['workspace'].name}** |
360 | 372 | """ |
361 | 373 | ) |
| 374 | + |
| 375 | + with st.expander("📊 **Resource Utilization**"): |
| 376 | + monitor_hardware() |
| 377 | + |
362 | 378 | st.image("assets/OpenMS.png", "powered by") |
363 | 379 | #st.logo() |
| 380 | + |
| 381 | + # Display OpenMS WebApp Template Version from settings.json |
| 382 | + with st.container(): |
| 383 | + st.markdown( |
| 384 | + """ |
| 385 | + <style> |
| 386 | + .version-box { |
| 387 | + border: 1px solid #a4a5ad; |
| 388 | + padding: 10px; |
| 389 | + border-radius: 0.5rem; |
| 390 | + text-align: center; |
| 391 | + display: flex; |
| 392 | + justify-content: center; |
| 393 | + align-items: center; |
| 394 | + } |
| 395 | + </style> |
| 396 | + """, |
| 397 | + unsafe_allow_html=True, |
| 398 | + ) |
| 399 | + version_info = st.session_state.settings["version"] |
| 400 | + app_name = st.session_state.settings["app-name"] |
| 401 | + st.markdown( |
| 402 | + f'<div class="version-box">{app_name}<br>Version: {version_info}</div>', |
| 403 | + unsafe_allow_html=True, |
| 404 | + ) |
| 405 | + |
364 | 406 | return params |
365 | 407 |
|
366 | 408 | def v_space(n: int, col=None) -> None: |
|
0 commit comments