1 # Copyright (c) 2024 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """Plotly Dash HTML layout override.
20 import dash_bootstrap_components as dbc
22 from flask import Flask
25 from dash import callback_context, no_update, ALL
26 from dash import Input, Output, State
27 from dash.exceptions import PreventUpdate
28 from yaml import load, FullLoader, YAMLError
29 from ast import literal_eval
31 from ..utils.constants import Constants as C
32 from ..utils.control_panel import ControlPanel
33 from ..utils.trigger import Trigger
34 from ..utils.utils import show_tooltip, label, sync_checklists, gen_new_url, \
35 generate_options, get_list_group_items, navbar_report, \
36 show_iterative_graph_data
37 from ..utils.url_processing import url_decode
38 from .graphs import graph_iterative, select_iterative_data
41 # Control panel partameters and their default values.
47 "dd-dutver-opt": list(),
48 "dd-dutver-dis": True,
49 "dd-dutver-val": str(),
53 "dd-area-opt": list(),
56 "dd-test-opt": list(),
59 "cl-core-opt": list(),
60 "cl-core-val": list(),
61 "cl-core-all-val": list(),
62 "cl-core-all-opt": C.CL_ALL_DISABLED,
63 "cl-frmsize-opt": list(),
64 "cl-frmsize-val": list(),
65 "cl-frmsize-all-val": list(),
66 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
67 "cl-tsttype-opt": list(),
68 "cl-tsttype-val": list(),
69 "cl-tsttype-all-val": list(),
70 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
72 "cl-normalize-val": list()
77 """The layout of the dash app and the callbacks.
83 data_iterative: pd.DataFrame,
84 html_layout_file: str,
85 graph_layout_file: str,
89 - save the input parameters,
90 - read and pre-process the data,
91 - prepare data for the control panel,
92 - read HTML layout file,
93 - read tooltips from the tooltip file.
95 :param app: Flask application running the dash application.
96 :param html_layout_file: Path and name of the file specifying the HTML
97 layout of the dash application.
98 :param graph_layout_file: Path and name of the file with layout of
100 :param tooltip_file: Path and name of the yaml file specifying the
103 :type html_layout_file: str
104 :type graph_layout_file: str
105 :type tooltip_file: str
110 self._html_layout_file = html_layout_file
111 self._graph_layout_file = graph_layout_file
112 self._tooltip_file = tooltip_file
113 self._data = data_iterative
115 # Get structure of tests:
118 "job", "test_id", "test_type", "dut_version", "tg_type", "release"
120 for _, row in self._data[cols].drop_duplicates().iterrows():
122 lst_job = row["job"].split("-")
124 d_ver = row["dut_version"]
125 tbed = "-".join(lst_job[-2:])
126 lst_test_id = row["test_id"].split(".")
130 area = ".".join(lst_test_id[3:-2])
131 suite = lst_test_id[-2].replace("2n1l-", "").replace("1n1l-", "").\
133 test = lst_test_id[-1]
134 nic = suite.split("-")[0]
135 for drv in C.DRIVERS:
137 driver = drv.replace("-", "_")
138 test = test.replace(f"{drv}-", "")
142 infra = "-".join((tbed, nic, driver))
143 lst_test = test.split("-")
144 framesize = lst_test[0]
145 core = lst_test[1] if lst_test[1] else "8C"
146 test = "-".join(lst_test[2: -1])
148 if tbs.get(rls, None) is None:
150 if tbs[rls].get(dut, None) is None:
151 tbs[rls][dut] = dict()
152 if tbs[rls][dut].get(d_ver, None) is None:
153 tbs[rls][dut][d_ver] = dict()
154 if tbs[rls][dut][d_ver].get(area, None) is None:
155 tbs[rls][dut][d_ver][area] = dict()
156 if tbs[rls][dut][d_ver][area].get(test, None) is None:
157 tbs[rls][dut][d_ver][area][test] = dict()
158 if tbs[rls][dut][d_ver][area][test].get(infra, None) is None:
159 tbs[rls][dut][d_ver][area][test][infra] = {
161 "frame-size": list(),
164 tst_params = tbs[rls][dut][d_ver][area][test][infra]
165 if core.upper() not in tst_params["core"]:
166 tst_params["core"].append(core.upper())
167 if framesize.upper() not in tst_params["frame-size"]:
168 tst_params["frame-size"].append(framesize.upper())
169 if row["test_type"] == "mrr":
170 if "MRR" not in tst_params["test-type"]:
171 tst_params["test-type"].append("MRR")
172 elif row["test_type"] == "ndrpdr":
173 if "NDR" not in tst_params["test-type"]:
174 tst_params["test-type"].extend(("NDR", "PDR", ))
175 elif row["test_type"] == "hoststack" and \
176 row["tg_type"] in ("iperf", "vpp"):
177 if "BPS" not in tst_params["test-type"]:
178 tst_params["test-type"].append("BPS")
179 elif row["test_type"] == "hoststack" and row["tg_type"] == "ab":
180 if "CPS" not in tst_params["test-type"]:
181 tst_params["test-type"].extend(("CPS", "RPS"))
185 self._html_layout = str()
186 self._graph_layout = None
187 self._tooltips = dict()
190 with open(self._html_layout_file, "r") as file_read:
191 self._html_layout = file_read.read()
192 except IOError as err:
194 f"Not possible to open the file {self._html_layout_file}\n{err}"
198 with open(self._graph_layout_file, "r") as file_read:
199 self._graph_layout = load(file_read, Loader=FullLoader)
200 except IOError as err:
202 f"Not possible to open the file {self._graph_layout_file}\n"
205 except YAMLError as err:
207 f"An error occurred while parsing the specification file "
208 f"{self._graph_layout_file}\n{err}"
212 with open(self._tooltip_file, "r") as file_read:
213 self._tooltips = load(file_read, Loader=FullLoader)
214 except IOError as err:
216 f"Not possible to open the file {self._tooltip_file}\n{err}"
218 except YAMLError as err:
220 f"An error occurred while parsing the specification file "
221 f"{self._tooltip_file}\n{err}"
225 if self._app is not None and hasattr(self, "callbacks"):
226 self.callbacks(self._app)
229 def html_layout(self):
230 return self._html_layout
232 def add_content(self):
233 """Top level method which generated the web page.
236 - Store for user input data,
238 - Main area with control panel and ploting area.
240 If no HTML layout is provided, an error message is displayed instead.
242 :returns: The HTML div with the whole page.
246 if self.html_layout and self._spec_tbs:
254 children=[navbar_report((True, False, False, False)), ]
260 dcc.Store(id="store-selected-tests"),
261 dcc.Store(id="store-control-panel"),
262 dcc.Location(id="url", refresh=False),
263 self._add_ctrl_col(),
264 self._add_plotting_col()
270 id="offcanvas-metadata",
271 title="Throughput And Latency",
275 dbc.Row(id="metadata-tput-lat"),
276 dbc.Row(id="metadata-hdrh-graph")
279 delay_show=C.SPINNER_DELAY
283 id="offcanvas-documentation",
284 title="Documentation",
287 children=html.Iframe(
288 src=C.URL_DOC_REL_NOTES,
308 def _add_ctrl_col(self) -> dbc.Col:
309 """Add column with controls. It is placed on the left side.
311 :returns: Column with the control panel.
316 children=self._add_ctrl_panel(),
317 className="sticky-top"
321 def _add_plotting_col(self) -> dbc.Col:
322 """Add column with plots. It is placed on the right side.
324 :returns: Column with plots.
328 id="col-plotting-area",
334 class_name="g-0 p-0",
345 def _add_ctrl_panel(self) -> list:
346 """Add control panel.
348 :returns: Control panel.
353 class_name="g-0 p-1",
358 children=show_tooltip(
365 id={"type": "ctrl-dd", "index": "rls"},
366 placeholder="Select a Release...",
369 {"label": k, "value": k} \
370 for k in self._spec_tbs.keys()
372 key=lambda d: d["label"]
381 class_name="g-0 p-1",
386 children=show_tooltip(
393 id={"type": "ctrl-dd", "index": "dut"},
394 placeholder="Select a Device under Test..."
402 class_name="g-0 p-1",
407 children=show_tooltip(
414 id={"type": "ctrl-dd", "index": "dutver"},
416 "Select a Version of Device under Test..."
424 class_name="g-0 p-1",
429 children=show_tooltip(
436 id={"type": "ctrl-dd", "index": "area"},
437 placeholder="Select an Area..."
445 class_name="g-0 p-1",
450 children=show_tooltip(
457 id={"type": "ctrl-dd", "index": "test"},
458 placeholder="Select a Test..."
466 class_name="g-0 p-1",
471 children=show_tooltip(
478 id={"type": "ctrl-dd", "index": "phy"},
480 "Select a Physical Test Bed Topology..."
488 class_name="g-0 p-1",
493 children=show_tooltip(
504 "index": "frmsize-all"
506 options=C.CL_ALL_DISABLED,
525 style={"align-items": "center"},
531 class_name="g-0 p-1",
536 children=show_tooltip(
549 options=C.CL_ALL_DISABLED,
568 style={"align-items": "center"},
574 class_name="g-0 p-1",
579 children=show_tooltip(
590 "index": "tsttype-all"
592 options=C.CL_ALL_DISABLED,
611 style={"align-items": "center"},
617 class_name="g-0 p-1",
622 children=show_tooltip(
633 "value": "normalize",
635 "Normalize to CPU frequency "
646 style={"align-items": "center"},
652 class_name="g-0 p-1",
655 id={"type": "ctrl-btn", "index": "add-test"},
656 children="Add Selected",
662 id="row-card-sel-tests",
663 class_name="g-0 p-1",
664 style=C.STYLE_DISABLED,
667 class_name="overflow-auto p-0",
670 style={"max-height": "20em"},
676 id="row-btns-sel-tests",
677 class_name="g-0 p-1",
678 style=C.STYLE_DISABLED,
681 dbc.ButtonGroup(children=[
683 id={"type": "ctrl-btn", "index": "rm-test"},
684 children="Remove Selected",
690 id={"type": "ctrl-btn", "index": "rm-test-all"},
691 children="Remove All",
697 dbc.ButtonGroup(children=[
706 id="plot-btn-download",
707 children="Download Data",
717 def _get_plotting_area(
723 """Generate the plotting area with all its content.
725 :param tests: List of tests to be displayed in the graphs.
726 :param normalize: If true, the values in graphs are normalized.
727 :param url: URL to be displayed in the modal window.
729 :type normalize: bool
731 :returns: List of rows with elements to be displayed in the plotting
739 graph_iterative(self._data, tests, self._graph_layout, normalize)
747 id={"type": "graph", "index": "tput"},
759 id={"type": "graph", "index": "bandwidth"},
763 tab_id="tab-bandwidth"
771 id={"type": "graph", "index": "lat"},
784 active_tab="tab-tput",
790 dbc.ModalHeader(dbc.ModalTitle("URL")),
798 dcc.Download(id="download-iterative-data")
801 def callbacks(self, app):
802 """Callbacks for the whole application.
804 :param app: The application.
810 Output("store-control-panel", "data"),
811 Output("store-selected-tests", "data"),
812 Output("plotting-area", "children"),
813 Output("row-card-sel-tests", "style"),
814 Output("row-btns-sel-tests", "style"),
815 Output("lg-selected", "children"),
817 Output({"type": "ctrl-dd", "index": "rls"}, "value"),
818 Output({"type": "ctrl-dd", "index": "dut"}, "options"),
819 Output({"type": "ctrl-dd", "index": "dut"}, "disabled"),
820 Output({"type": "ctrl-dd", "index": "dut"}, "value"),
821 Output({"type": "ctrl-dd", "index": "dutver"}, "options"),
822 Output({"type": "ctrl-dd", "index": "dutver"}, "disabled"),
823 Output({"type": "ctrl-dd", "index": "dutver"}, "value"),
824 Output({"type": "ctrl-dd", "index": "phy"}, "options"),
825 Output({"type": "ctrl-dd", "index": "phy"}, "disabled"),
826 Output({"type": "ctrl-dd", "index": "phy"}, "value"),
827 Output({"type": "ctrl-dd", "index": "area"}, "options"),
828 Output({"type": "ctrl-dd", "index": "area"}, "disabled"),
829 Output({"type": "ctrl-dd", "index": "area"}, "value"),
830 Output({"type": "ctrl-dd", "index": "test"}, "options"),
831 Output({"type": "ctrl-dd", "index": "test"}, "disabled"),
832 Output({"type": "ctrl-dd", "index": "test"}, "value"),
833 Output({"type": "ctrl-cl", "index": "core"}, "options"),
834 Output({"type": "ctrl-cl", "index": "core"}, "value"),
835 Output({"type": "ctrl-cl", "index": "core-all"}, "value"),
836 Output({"type": "ctrl-cl", "index": "core-all"}, "options"),
837 Output({"type": "ctrl-cl", "index": "frmsize"}, "options"),
838 Output({"type": "ctrl-cl", "index": "frmsize"}, "value"),
839 Output({"type": "ctrl-cl", "index": "frmsize-all"}, "value"),
840 Output({"type": "ctrl-cl", "index": "frmsize-all"}, "options"),
841 Output({"type": "ctrl-cl", "index": "tsttype"}, "options"),
842 Output({"type": "ctrl-cl", "index": "tsttype"}, "value"),
843 Output({"type": "ctrl-cl", "index": "tsttype-all"}, "value"),
844 Output({"type": "ctrl-cl", "index": "tsttype-all"}, "options"),
845 Output({"type": "ctrl-btn", "index": "add-test"}, "disabled"),
846 Output("normalize", "value")
849 State("store-control-panel", "data"),
850 State("store-selected-tests", "data"),
851 State({"type": "sel-cl", "index": ALL}, "value")
854 Input("url", "href"),
855 Input("normalize", "value"),
857 Input({"type": "ctrl-dd", "index": ALL}, "value"),
858 Input({"type": "ctrl-cl", "index": ALL}, "value"),
859 Input({"type": "ctrl-btn", "index": ALL}, "n_clicks")
862 def _update_application(
870 """Update the application when the event is detected.
873 ctrl_panel = ControlPanel(CP_PARAMS, control_panel)
877 parsed_url = url_decode(href)
879 url_params = parsed_url["params"]
883 plotting_area = no_update
884 row_card_sel_tests = no_update
885 row_btns_sel_tests = no_update
886 lg_selected = no_update
888 trigger = Trigger(callback_context.triggered)
890 if trigger.type == "url" and url_params:
892 store_sel = literal_eval(url_params["store_sel"][0])
893 normalize = literal_eval(url_params["norm"][0])
894 except (KeyError, IndexError, AttributeError):
897 row_card_sel_tests = C.STYLE_ENABLED
898 row_btns_sel_tests = C.STYLE_ENABLED
899 last_test = store_sel[-1]
900 test = self._spec_tbs[last_test["rls"]][last_test["dut"]]\
901 [last_test["dutver"]][last_test["area"]]\
902 [last_test["test"]][last_test["phy"]]
904 "dd-rls-val": last_test["rls"],
905 "dd-dut-val": last_test["dut"],
906 "dd-dut-opt": generate_options(
907 self._spec_tbs[last_test["rls"]].keys()
910 "dd-dutver-val": last_test["dutver"],
911 "dd-dutver-opt": generate_options(
912 self._spec_tbs[last_test["rls"]]\
913 [last_test["dut"]].keys()
915 "dd-dutver-dis": False,
916 "dd-area-val": last_test["area"],
918 {"label": label(v), "value": v} for v in \
919 sorted(self._spec_tbs[last_test["rls"]]\
921 [last_test["dutver"]].keys())
923 "dd-area-dis": False,
924 "dd-test-val": last_test["test"],
925 "dd-test-opt": generate_options(
926 self._spec_tbs[last_test["rls"]][last_test["dut"]]\
927 [last_test["dutver"]][last_test["area"]].keys()
929 "dd-test-dis": False,
930 "dd-phy-val": last_test["phy"],
931 "dd-phy-opt": generate_options(
932 self._spec_tbs[last_test["rls"]][last_test["dut"]]\
933 [last_test["dutver"]][last_test["area"]]\
934 [last_test["test"]].keys()
937 "cl-core-opt": generate_options(test["core"]),
938 "cl-core-val": [last_test["core"].upper(), ],
939 "cl-core-all-val": list(),
940 "cl-core-all-opt": C.CL_ALL_ENABLED,
941 "cl-frmsize-opt": generate_options(test["frame-size"]),
942 "cl-frmsize-val": [last_test["framesize"].upper(), ],
943 "cl-frmsize-all-val": list(),
944 "cl-frmsize-all-opt": C.CL_ALL_ENABLED,
945 "cl-tsttype-opt": generate_options(test["test-type"]),
946 "cl-tsttype-val": [last_test["testtype"].upper(), ],
947 "cl-tsttype-all-val": list(),
948 "cl-tsttype-all-opt": C.CL_ALL_ENABLED,
949 "cl-normalize-val": normalize,
953 elif trigger.type == "normalize":
954 ctrl_panel.set({"cl-normalize-val": normalize})
956 elif trigger.type == "ctrl-dd":
957 if trigger.idx == "rls":
959 options = generate_options(
960 self._spec_tbs[trigger.value].keys()
967 "dd-rls-val": trigger.value,
969 "dd-dut-opt": options,
970 "dd-dut-dis": disabled,
971 "dd-dutver-val": str(),
972 "dd-dutver-opt": list(),
973 "dd-dutver-dis": True,
975 "dd-phy-opt": list(),
977 "dd-area-val": str(),
978 "dd-area-opt": list(),
980 "dd-test-val": str(),
981 "dd-test-opt": list(),
983 "cl-core-opt": list(),
984 "cl-core-val": list(),
985 "cl-core-all-val": list(),
986 "cl-core-all-opt": C.CL_ALL_DISABLED,
987 "cl-frmsize-opt": list(),
988 "cl-frmsize-val": list(),
989 "cl-frmsize-all-val": list(),
990 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
991 "cl-tsttype-opt": list(),
992 "cl-tsttype-val": list(),
993 "cl-tsttype-all-val": list(),
994 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
997 elif trigger.idx == "dut":
999 rls = ctrl_panel.get("dd-rls-val")
1000 dut = self._spec_tbs[rls][trigger.value]
1001 options = generate_options(dut.keys())
1007 "dd-dut-val": trigger.value,
1008 "dd-dutver-val": str(),
1009 "dd-dutver-opt": options,
1010 "dd-dutver-dis": disabled,
1011 "dd-phy-val": str(),
1012 "dd-phy-opt": list(),
1014 "dd-area-val": str(),
1015 "dd-area-opt": list(),
1016 "dd-area-dis": True,
1017 "dd-test-val": str(),
1018 "dd-test-opt": list(),
1019 "dd-test-dis": True,
1020 "cl-core-opt": list(),
1021 "cl-core-val": list(),
1022 "cl-core-all-val": list(),
1023 "cl-core-all-opt": C.CL_ALL_DISABLED,
1024 "cl-frmsize-opt": list(),
1025 "cl-frmsize-val": list(),
1026 "cl-frmsize-all-val": list(),
1027 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1028 "cl-tsttype-opt": list(),
1029 "cl-tsttype-val": list(),
1030 "cl-tsttype-all-val": list(),
1031 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1034 elif trigger.idx == "dutver":
1036 rls = ctrl_panel.get("dd-rls-val")
1037 dut = ctrl_panel.get("dd-dut-val")
1038 dutver = self._spec_tbs[rls][dut][trigger.value]
1039 options = [{"label": label(v), "value": v} \
1040 for v in sorted(dutver.keys())]
1046 "dd-dutver-val": trigger.value,
1047 "dd-area-val": str(),
1048 "dd-area-opt": options,
1049 "dd-area-dis": disabled,
1050 "dd-test-val": str(),
1051 "dd-test-opt": list(),
1052 "dd-test-dis": True,
1053 "dd-phy-val": str(),
1054 "dd-phy-opt": list(),
1056 "cl-core-opt": list(),
1057 "cl-core-val": list(),
1058 "cl-core-all-val": list(),
1059 "cl-core-all-opt": C.CL_ALL_DISABLED,
1060 "cl-frmsize-opt": list(),
1061 "cl-frmsize-val": list(),
1062 "cl-frmsize-all-val": list(),
1063 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1064 "cl-tsttype-opt": list(),
1065 "cl-tsttype-val": list(),
1066 "cl-tsttype-all-val": list(),
1067 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1070 elif trigger.idx == "area":
1072 rls = ctrl_panel.get("dd-rls-val")
1073 dut = ctrl_panel.get("dd-dut-val")
1074 dutver = ctrl_panel.get("dd-dutver-val")
1075 area = self._spec_tbs[rls][dut][dutver][trigger.value]
1076 options = generate_options(area.keys())
1082 "dd-area-val": trigger.value,
1083 "dd-test-val": str(),
1084 "dd-test-opt": options,
1085 "dd-test-dis": disabled,
1086 "dd-phy-val": str(),
1087 "dd-phy-opt": list(),
1089 "cl-core-opt": list(),
1090 "cl-core-val": list(),
1091 "cl-core-all-val": list(),
1092 "cl-core-all-opt": C.CL_ALL_DISABLED,
1093 "cl-frmsize-opt": list(),
1094 "cl-frmsize-val": list(),
1095 "cl-frmsize-all-val": list(),
1096 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1097 "cl-tsttype-opt": list(),
1098 "cl-tsttype-val": list(),
1099 "cl-tsttype-all-val": list(),
1100 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1103 elif trigger.idx == "test":
1105 rls = ctrl_panel.get("dd-rls-val")
1106 dut = ctrl_panel.get("dd-dut-val")
1107 dutver = ctrl_panel.get("dd-dutver-val")
1108 area = ctrl_panel.get("dd-area-val")
1109 test = self._spec_tbs[rls][dut][dutver][area]\
1111 options = generate_options(test.keys())
1117 "dd-test-val": trigger.value,
1118 "dd-phy-val": str(),
1119 "dd-phy-opt": options,
1120 "dd-phy-dis": disabled,
1121 "cl-core-opt": list(),
1122 "cl-core-val": list(),
1123 "cl-core-all-val": list(),
1124 "cl-core-all-opt": C.CL_ALL_DISABLED,
1125 "cl-frmsize-opt": list(),
1126 "cl-frmsize-val": list(),
1127 "cl-frmsize-all-val": list(),
1128 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1129 "cl-tsttype-opt": list(),
1130 "cl-tsttype-val": list(),
1131 "cl-tsttype-all-val": list(),
1132 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1135 elif trigger.idx == "phy":
1136 rls = ctrl_panel.get("dd-rls-val")
1137 dut = ctrl_panel.get("dd-dut-val")
1138 dutver = ctrl_panel.get("dd-dutver-val")
1139 area = ctrl_panel.get("dd-area-val")
1140 test = ctrl_panel.get("dd-test-val")
1141 if all((rls, dut, dutver, area, test, trigger.value, )):
1142 phy = self._spec_tbs[rls][dut][dutver][area][test]\
1145 "dd-phy-val": trigger.value,
1146 "cl-core-opt": generate_options(phy["core"]),
1147 "cl-core-val": list(),
1148 "cl-core-all-val": list(),
1149 "cl-core-all-opt": C.CL_ALL_ENABLED,
1151 generate_options(phy["frame-size"]),
1152 "cl-frmsize-val": list(),
1153 "cl-frmsize-all-val": list(),
1154 "cl-frmsize-all-opt": C.CL_ALL_ENABLED,
1156 generate_options(phy["test-type"]),
1157 "cl-tsttype-val": list(),
1158 "cl-tsttype-all-val": list(),
1159 "cl-tsttype-all-opt": C.CL_ALL_ENABLED,
1162 elif trigger.type == "ctrl-cl":
1163 param = trigger.idx.split("-")[0]
1164 if "-all" in trigger.idx:
1165 c_sel, c_all, c_id = list(), trigger.value, "all"
1167 c_sel, c_all, c_id = trigger.value, list(), str()
1168 val_sel, val_all = sync_checklists(
1169 options=ctrl_panel.get(f"cl-{param}-opt"),
1175 f"cl-{param}-val": val_sel,
1176 f"cl-{param}-all-val": val_all,
1178 if all((ctrl_panel.get("cl-core-val"),
1179 ctrl_panel.get("cl-frmsize-val"),
1180 ctrl_panel.get("cl-tsttype-val"), )):
1181 ctrl_panel.set({"btn-add-dis": False})
1183 ctrl_panel.set({"btn-add-dis": True})
1184 elif trigger.type == "ctrl-btn":
1186 if trigger.idx == "add-test":
1187 rls = ctrl_panel.get("dd-rls-val")
1188 dut = ctrl_panel.get("dd-dut-val")
1189 dutver = ctrl_panel.get("dd-dutver-val")
1190 phy = ctrl_panel.get("dd-phy-val")
1191 area = ctrl_panel.get("dd-area-val")
1192 test = ctrl_panel.get("dd-test-val")
1193 # Add selected test to the list of tests in store:
1194 if store_sel is None:
1196 for core in ctrl_panel.get("cl-core-val"):
1197 for framesize in ctrl_panel.get("cl-frmsize-val"):
1198 for ttype in ctrl_panel.get("cl-tsttype-val"):
1205 phy.replace("af_xdp", "af-xdp"),
1212 if tid not in [i["id"] for i in store_sel]:
1221 "framesize": framesize.lower(),
1222 "core": core.lower(),
1223 "testtype": ttype.lower()
1225 store_sel = sorted(store_sel, key=lambda d: d["id"])
1226 if C.CLEAR_ALL_INPUTS:
1227 ctrl_panel.set(ctrl_panel.defaults)
1228 elif trigger.idx == "rm-test" and lst_sel:
1229 new_store_sel = list()
1230 for idx, item in enumerate(store_sel):
1231 if not lst_sel[idx]:
1232 new_store_sel.append(item)
1233 store_sel = new_store_sel
1234 elif trigger.idx == "rm-test-all":
1239 lg_selected = get_list_group_items(
1240 store_sel, "sel-cl", add_index=True
1242 plotting_area = self._get_plotting_area(
1247 {"store_sel": store_sel, "norm": normalize}
1250 row_card_sel_tests = C.STYLE_ENABLED
1251 row_btns_sel_tests = C.STYLE_ENABLED
1253 plotting_area = C.PLACEHOLDER
1254 row_card_sel_tests = C.STYLE_DISABLED
1255 row_btns_sel_tests = C.STYLE_DISABLED
1266 ret_val.extend(ctrl_panel.values)
1270 Output("plot-mod-url", "is_open"),
1271 Output("plot-btn-url", "n_clicks"),
1272 Input("plot-btn-url", "n_clicks"),
1273 State("plot-mod-url", "is_open")
1275 def toggle_plot_mod_url(n, is_open):
1276 """Toggle the modal window with url.
1279 return not is_open, 0
1283 Output("download-iterative-data", "data"),
1284 State("store-selected-tests", "data"),
1285 Input("plot-btn-download", "n_clicks"),
1286 prevent_initial_call=True
1288 def _download_iterative_data(store_sel, _):
1289 """Download the data
1291 :param store_sel: List of tests selected by user stored in the
1293 :type store_sel: list
1294 :returns: dict of data frame content (base64 encoded) and meta data
1295 used by the Download component.
1303 for itm in store_sel:
1304 sel_data = select_iterative_data(self._data, itm)
1305 if sel_data is None:
1307 df = pd.concat([df, sel_data], ignore_index=True)
1309 return dcc.send_data_frame(df.to_csv, C.REPORT_DOWNLOAD_FILE_NAME)
1312 Output("metadata-tput-lat", "children"),
1313 Output("metadata-hdrh-graph", "children"),
1314 Output("offcanvas-metadata", "is_open"),
1315 Input({"type": "graph", "index": ALL}, "clickData"),
1316 prevent_initial_call=True
1318 def _show_metadata_from_graphs(graph_data: dict) -> tuple:
1319 """Generates the data for the offcanvas displayed when a particular
1320 point in a graph is clicked on.
1322 :param graph_data: The data from the clicked point in the graph.
1323 :type graph_data: dict
1324 :returns: The data to be displayed on the offcanvas and the
1325 information to show the offcanvas.
1326 :rtype: tuple(list, list, bool)
1329 trigger = Trigger(callback_context.triggered)
1330 if not trigger.value:
1333 return show_iterative_graph_data(
1334 trigger, graph_data, self._graph_layout)
1337 Output("offcanvas-documentation", "is_open"),
1338 Input("btn-documentation", "n_clicks"),
1339 State("offcanvas-documentation", "is_open")
1341 def toggle_offcanvas_documentation(n_clicks, is_open):