Skip to content

Commit 366a7ef

Browse files
committed
add option to hide system stats in the UI #72
1 parent b248fae commit 366a7ef

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

mara_pipelines/config.py

+5
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ def allow_run_from_web_ui() -> bool:
6868
return True
6969

7070

71+
def display_system_statistics() -> bool:
72+
"""If the system statistics shall be visible in the web UI."""
73+
return True
74+
75+
7176
def base_url() -> str:
7277
"""External url of flask app, for linking nodes in slack messages"""
7378
return 'http://127.0.0.1:5000/pipelines'

mara_pipelines/ui/last_runs.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,26 @@
99
import mara_db.postgresql
1010
from mara_page import bootstrap, html, acl, _
1111
from . import views
12-
from .. import pipelines
12+
from .. import config, pipelines
1313

1414

1515
def card(node: pipelines.Node) -> str:
1616
"""A card that shows the system stats, the time line and output for the last runs or a node"""
17+
statistic_content = []
18+
if config.display_system_statistics():
19+
statistic_content.append(
20+
html.asynchronous_content(url=flask.url_for('mara_pipelines.system_stats', path=node.url_path(), run_id=None),
21+
div_id='system-stats'))
22+
1723
return bootstrap.card(
1824
id='last-runs-card',
1925
header_left=[
2026
'Last runs ',
2127
_.div(style='display:inline-block;margin-left:20px;')[html.asynchronous_content(
2228
flask.url_for('mara_pipelines.last_runs_selector', path=node.url_path()))]],
23-
body=[html.spinner_js_function(),
24-
html.asynchronous_content(
25-
url=flask.url_for('mara_pipelines.system_stats', path=node.url_path(), run_id=None),
26-
div_id='system-stats'),
27-
html.asynchronous_content(
29+
body=[html.spinner_js_function()] \
30+
+ statistic_content + \
31+
[html.asynchronous_content(
2832
url=flask.url_for('mara_pipelines.timeline_chart', path=node.url_path(), run_id=None),
2933
div_id='timeline-chart'),
3034
html.asynchronous_content(
@@ -123,6 +127,9 @@ def run_output(path: str, run_id: int, limit: bool):
123127
@views.blueprint.route('/system-stats/<int:run_id>', defaults={'path': ''})
124128
@acl.require_permission(views.acl_resource, do_abort=False)
125129
def system_stats(path: str, run_id: int):
130+
if not config.display_system_statistics():
131+
return ''
132+
126133
node, __ = pipelines.find_node(path.split('/'))
127134

128135
run_id = run_id or _latest_run_id(node.path())

0 commit comments

Comments
 (0)