Skip to content

Commit 6096e44

Browse files
authored
Merge branch 'main' into rescore
2 parents 804ba79 + a7df0d1 commit 6096e44

File tree

2 files changed

+48
-7
lines changed

2 files changed

+48
-7
lines changed

settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2+
"app-name": "NuXLApp",
3+
"version": "0.0.1",
4+
"repository-name": "nuxl-app",
5+
"openms-version": "3.2.0",
26
"analytics": {
37
"google-analytics": {
48
"enabled": false,

src/common.py

Lines changed: 44 additions & 7 deletions
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,18 @@
2324
# Detect system platform
2425
OS_PLATFORM = sys.platform
2526

27+
@st.fragment(run_every=5)
28+
def monitor_hardware():
29+
cpu_progress = psutil.cpu_percent(interval=None) / 100
30+
ram_progress = 1 - psutil.virtual_memory().available / psutil.virtual_memory().total
2631

27-
# set these variables according to your project
28-
APP_NAME = "NuXL"
29-
REPOSITORY_NAME = "nuxl-app"
32+
st.text(f"Ram ({ram_progress * 100:.2f}%)")
33+
st.progress(ram_progress)
3034

35+
st.text(f"CPU ({cpu_progress * 100:.2f}%)")
36+
st.progress(cpu_progress)
37+
38+
st.caption(f"Last fetched at: {time.strftime('%H:%M:%S')}")
3139

3240
def load_params(default: bool = False) -> dict[str, Any]:
3341
"""
@@ -110,7 +118,7 @@ def page_setup(page: str = "") -> dict[str, Any]:
110118

111119
# Set Streamlit page configurations
112120
st.set_page_config(
113-
page_title=APP_NAME,
121+
page_title=st.session_state.settings["app-name"],
114122
page_icon="assets/openms_transparent_bg_logo.svg",
115123
layout="wide",
116124
initial_sidebar_state="auto",
@@ -202,7 +210,7 @@ def page_setup(page: str = "") -> dict[str, Any]:
202210
if "windows" in sys.argv:
203211
os.chdir("../nuxl-app-main")
204212
# Define the directory where all workspaces will be stored
205-
workspaces_dir = Path("..", "workspaces-" + REPOSITORY_NAME)
213+
workspaces_dir = Path("..", "workspaces-" + st.session_state.settings["repository-name"])
206214
if "workspace" in st.query_params:
207215
st.session_state.workspace = Path(workspaces_dir, st.query_params.workspace)
208216
elif st.session_state.location == "online":
@@ -277,7 +285,7 @@ def render_sidebar(page: str = "") -> None:
277285
if page == "main":
278286
st.markdown("🖥️ **Workspaces**")
279287
# Define workspaces directory outside of repository
280-
workspaces_dir = Path("..", "workspaces-"+REPOSITORY_NAME)
288+
workspaces_dir = Path("..", "workspaces-"+st.session_state.settings["repository-name"])
281289
# Online: show current workspace name in info text and option to change to other existing workspace
282290
if st.session_state.location == "online":
283291
# Change workspace...
@@ -365,8 +373,37 @@ def change_workspace():
365373
**{st.session_state['workspace'].name}**
366374
"""
367375
)
376+
with st.expander("📊 **Resource Utilization**"):
377+
monitor_hardware()
378+
368379
st.image("assets/OpenMS_new.png", "powered by")
369-
#st.logo()
380+
381+
382+
# Display OpenMS WebApp Template Version from settings.json
383+
with st.container():
384+
st.markdown(
385+
"""
386+
<style>
387+
.version-box {
388+
border: 1px solid #a4a5ad;
389+
padding: 10px;
390+
border-radius: 0.5rem;
391+
text-align: center;
392+
display: flex;
393+
justify-content: center;
394+
align-items: center;
395+
}
396+
</style>
397+
""",
398+
unsafe_allow_html=True,
399+
)
400+
version_info = st.session_state.settings["version"]
401+
app_name = st.session_state.settings["app-name"]
402+
st.markdown(
403+
f'<div class="version-box">{app_name}<br>Version: {version_info}</div>',
404+
unsafe_allow_html=True,
405+
)
406+
370407
return params
371408

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

0 commit comments

Comments
 (0)