Skip to content

Commit 85aab47

Browse files
committed
provide version control
1 parent c0f8951 commit 85aab47

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"app-name": "NuXLApp",
3+
"version": "0.0.1",
24
"analytics": {
35
"google-analytics": {
46
"enabled": false,

src/common.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sys
55
import uuid
66
import time
7+
import psutil
78
from typing import Any
89
from pathlib import Path
910
from streamlit.components.v1 import html
@@ -23,11 +24,22 @@
2324
# Detect system platform
2425
OS_PLATFORM = sys.platform
2526

26-
2727
# set these variables according to your project
2828
APP_NAME = "NuXL"
2929
REPOSITORY_NAME = "nuxl-app"
3030

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')}")
3143

3244
def load_params(default: bool = False) -> dict[str, Any]:
3345
"""
@@ -359,8 +371,38 @@ def change_workspace():
359371
**{st.session_state['workspace'].name}**
360372
"""
361373
)
374+
375+
with st.expander("📊 **Resource Utilization**"):
376+
monitor_hardware()
377+
362378
st.image("assets/OpenMS.png", "powered by")
363379
#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+
364406
return params
365407

366408
def v_space(n: int, col=None) -> None:

0 commit comments

Comments
 (0)