Skip to content

Commit

Permalink
add option to hide system stats in the UI #72
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-schick committed Sep 19, 2022
1 parent b248fae commit 366a7ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
5 changes: 5 additions & 0 deletions mara_pipelines/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def allow_run_from_web_ui() -> bool:
return True


def display_system_statistics() -> bool:
"""If the system statistics shall be visible in the web UI."""
return True


def base_url() -> str:
"""External url of flask app, for linking nodes in slack messages"""
return 'http://127.0.0.1:5000/pipelines'
Expand Down
19 changes: 13 additions & 6 deletions mara_pipelines/ui/last_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@
import mara_db.postgresql
from mara_page import bootstrap, html, acl, _
from . import views
from .. import pipelines
from .. import config, pipelines


def card(node: pipelines.Node) -> str:
"""A card that shows the system stats, the time line and output for the last runs or a node"""
statistic_content = []
if config.display_system_statistics():
statistic_content.append(
html.asynchronous_content(url=flask.url_for('mara_pipelines.system_stats', path=node.url_path(), run_id=None),
div_id='system-stats'))

return bootstrap.card(
id='last-runs-card',
header_left=[
'Last runs ',
_.div(style='display:inline-block;margin-left:20px;')[html.asynchronous_content(
flask.url_for('mara_pipelines.last_runs_selector', path=node.url_path()))]],
body=[html.spinner_js_function(),
html.asynchronous_content(
url=flask.url_for('mara_pipelines.system_stats', path=node.url_path(), run_id=None),
div_id='system-stats'),
html.asynchronous_content(
body=[html.spinner_js_function()] \
+ statistic_content + \
[html.asynchronous_content(
url=flask.url_for('mara_pipelines.timeline_chart', path=node.url_path(), run_id=None),
div_id='timeline-chart'),
html.asynchronous_content(
Expand Down Expand Up @@ -123,6 +127,9 @@ def run_output(path: str, run_id: int, limit: bool):
@views.blueprint.route('/system-stats/<int:run_id>', defaults={'path': ''})
@acl.require_permission(views.acl_resource, do_abort=False)
def system_stats(path: str, run_id: int):
if not config.display_system_statistics():
return ''

node, __ = pipelines.find_node(path.split('/'))

run_id = run_id or _latest_run_id(node.path())
Expand Down

0 comments on commit 366a7ef

Please sign in to comment.