forked from JoohanBengtsson/GDM-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.py
113 lines (102 loc) · 3.22 KB
/
dashboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Run this app with `python dashboard.py` and
# visit http://127.0.0.1:8050/ in your web browser.
from dash import Dash, html, dcc
from visualization import data, graphs, layouts
from dash.dependencies import Input, Output
app = Dash(
__name__,
meta_tags=[
{"name": "GDM-testing", "content": "width=device-width, initial-scale=1"}
],
)
app.title = "GDM-testing"
server = app.server
app.config["suppress_callback_exceptions"] = False
available_ids = data.get_available_experiment_ids()
if len(available_ids) == 0:
raise Exception("No experiments available")
@app.callback(
[Output("app-content", "children")],
[Input("app-tabs", "value")],
[Input("id-select-dropdown", "value")],
)
def render_content(tab_switch: str, experiment_id: str) -> tuple:
"""Render the content of the page
Args:
tab_switch (str): Chosen tab
experiment_id (str): ID of experiment chosen in dropdown
Returns:
tuple: Children of the subpage
"""
if tab_switch == "tab1":
configs = data.get_configs(experiment_id)
return (
html.Div(
id="status-container",
children=[
html.Div(
id="settings-container",
children=[
layouts.generate_section_banner("Run-configurations:"),
data.format_configs(configs),
],
),
],
),
)
else:
experiment_data = data.get_data(experiment_id)
return (
html.Div(
id="graphs-container",
children=[
html.Div(
id="graph-container-1",
children=graphs.create_graphs(experiment_data),
),
],
),
)
# We initialize a layout that has to contain the components used for callbacks
app.layout = html.Div(
id="big-app-container",
children=[
html.Div(
id="banner",
className="banner",
children=[
html.Div(
id="id-select-menu",
children=[
html.H4("Select Experiment ID:"),
dcc.Dropdown(
id="id-select-dropdown",
options=list(
{"label": param, "value": param}
for param in available_ids
),
value=available_ids[0],
),
],
),
html.Div(
id="banner-text",
children=[
html.H5("GDM-testing"),
html.H6(f"Framework for testing GDMs based on four metrics"),
],
),
],
),
layouts.build_tabs(),
html.Div(
id="app-container",
children=[
html.Div(id="app-content"),
],
),
],
)
# Running the server
if __name__ == "__main__":
app.run_server(debug=True, port=8050)