1 # Copyright (c) 2022 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.
19 import dash_bootstrap_components as dbc
21 from flask import Flask
24 from dash import callback_context, no_update, ALL
25 from dash import Input, Output, State
26 from dash.exceptions import PreventUpdate
27 from yaml import load, FullLoader, YAMLError
28 from ast import literal_eval
30 from ..utils.constants import Constants as C
31 from ..utils.control_panel import ControlPanel
32 from ..utils.trigger import Trigger
33 from ..utils.utils import show_tooltip, label, sync_checklists, gen_new_url, \
34 generate_options, get_list_group_items
35 from ..utils.url_processing import url_decode
36 from ..data.data import Data
37 from .graphs import graph_iterative, select_iterative_data
40 # Control panel partameters and their default values.
46 "dd-dutver-opt": list(),
47 "dd-dutver-dis": True,
48 "dd-dutver-val": str(),
52 "dd-area-opt": list(),
55 "dd-test-opt": list(),
58 "cl-core-opt": list(),
59 "cl-core-val": list(),
60 "cl-core-all-val": list(),
61 "cl-core-all-opt": C.CL_ALL_DISABLED,
62 "cl-frmsize-opt": list(),
63 "cl-frmsize-val": list(),
64 "cl-frmsize-all-val": list(),
65 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
66 "cl-tsttype-opt": list(),
67 "cl-tsttype-val": list(),
68 "cl-tsttype-all-val": list(),
69 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
71 "cl-normalize-val": list()
76 """The layout of the dash app and the callbacks.
79 def __init__(self, app: Flask, releases: list, html_layout_file: str,
80 graph_layout_file: str, data_spec_file: str, tooltip_file: str) -> None:
82 - save the input parameters,
83 - read and pre-process the data,
84 - prepare data for the control panel,
85 - read HTML layout file,
86 - read tooltips from the tooltip file.
88 :param app: Flask application running the dash application.
89 :param releases: Lis of releases to be displayed.
90 :param html_layout_file: Path and name of the file specifying the HTML
91 layout of the dash application.
92 :param graph_layout_file: Path and name of the file with layout of
94 :param data_spec_file: Path and name of the file specifying the data to
95 be read from parquets for this application.
96 :param tooltip_file: Path and name of the yaml file specifying the
100 :type html_layout_file: str
101 :type graph_layout_file: str
102 :type data_spec_file: str
103 :type tooltip_file: str
108 self.releases = releases
109 self._html_layout_file = html_layout_file
110 self._graph_layout_file = graph_layout_file
111 self._data_spec_file = data_spec_file
112 self._tooltip_file = tooltip_file
115 self._data = pd.DataFrame()
117 data_mrr = Data(self._data_spec_file, True).\
118 read_iterative_mrr(release=rls)
119 data_mrr["release"] = rls
120 data_ndrpdr = Data(self._data_spec_file, True).\
121 read_iterative_ndrpdr(release=rls)
122 data_ndrpdr["release"] = rls
123 self._data = pd.concat(
124 [self._data, data_mrr, data_ndrpdr],
128 # Get structure of tests:
130 cols = ["job", "test_id", "test_type", "dut_version", "release"]
131 for _, row in self._data[cols].drop_duplicates().iterrows():
133 ttype = row["test_type"]
134 lst_job = row["job"].split("-")
136 d_ver = row["dut_version"]
137 tbed = "-".join(lst_job[-2:])
138 lst_test_id = row["test_id"].split(".")
142 area = "-".join(lst_test_id[3:-2])
143 suite = lst_test_id[-2].replace("2n1l-", "").replace("1n1l-", "").\
145 test = lst_test_id[-1]
146 nic = suite.split("-")[0]
147 for drv in C.DRIVERS:
149 driver = drv.replace("-", "_")
150 test = test.replace(f"{drv}-", "")
154 infra = "-".join((tbed, nic, driver))
155 lst_test = test.split("-")
156 framesize = lst_test[0]
157 core = lst_test[1] if lst_test[1] else "8C"
158 test = "-".join(lst_test[2: -1])
160 if tbs.get(rls, None) is None:
162 if tbs[rls].get(dut, None) is None:
163 tbs[rls][dut] = dict()
164 if tbs[rls][dut].get(d_ver, None) is None:
165 tbs[rls][dut][d_ver] = dict()
166 if tbs[rls][dut][d_ver].get(infra, None) is None:
167 tbs[rls][dut][d_ver][infra] = dict()
168 if tbs[rls][dut][d_ver][infra].get(area, None) is None:
169 tbs[rls][dut][d_ver][infra][area] = dict()
170 if tbs[rls][dut][d_ver][infra][area].get(test, None) is None:
171 tbs[rls][dut][d_ver][infra][area][test] = dict()
172 tbs[rls][dut][d_ver][infra][area][test]["core"] = list()
173 tbs[rls][dut][d_ver][infra][area][test]["frame-size"] = list()
174 tbs[rls][dut][d_ver][infra][area][test]["test-type"] = list()
175 if core.upper() not in \
176 tbs[rls][dut][d_ver][infra][area][test]["core"]:
177 tbs[rls][dut][d_ver][infra][area][test]["core"].append(
180 if framesize.upper() not in \
181 tbs[rls][dut][d_ver][infra][area][test]["frame-size"]:
182 tbs[rls][dut][d_ver][infra][area][test]["frame-size"].append(
187 tbs[rls][dut][d_ver][infra][area][test]["test-type"]:
188 tbs[rls][dut][d_ver][infra][area][test]["test-type"].append(
191 elif ttype == "ndrpdr":
193 tbs[rls][dut][d_ver][infra][area][test]["test-type"]:
194 tbs[rls][dut][d_ver][infra][area][test]["test-type"].extend(
200 self._html_layout = str()
201 self._graph_layout = None
202 self._tooltips = dict()
205 with open(self._html_layout_file, "r") as file_read:
206 self._html_layout = file_read.read()
207 except IOError as err:
209 f"Not possible to open the file {self._html_layout_file}\n{err}"
213 with open(self._graph_layout_file, "r") as file_read:
214 self._graph_layout = load(file_read, Loader=FullLoader)
215 except IOError as err:
217 f"Not possible to open the file {self._graph_layout_file}\n"
220 except YAMLError as err:
222 f"An error occurred while parsing the specification file "
223 f"{self._graph_layout_file}\n{err}"
227 with open(self._tooltip_file, "r") as file_read:
228 self._tooltips = load(file_read, Loader=FullLoader)
229 except IOError as err:
231 f"Not possible to open the file {self._tooltip_file}\n{err}"
233 except YAMLError as err:
235 f"An error occurred while parsing the specification file "
236 f"{self._tooltip_file}\n{err}"
240 if self._app is not None and hasattr(self, "callbacks"):
241 self.callbacks(self._app)
244 def html_layout(self):
245 return self._html_layout
247 def add_content(self):
248 """Top level method which generated the web page.
251 - Store for user input data,
253 - Main area with control panel and ploting area.
255 If no HTML layout is provided, an error message is displayed instead.
257 :returns: The HTML div with the whole page.
261 if self.html_layout and self._spec_tbs:
277 dcc.Store(id="store-selected-tests"),
278 dcc.Store(id="store-control-panel"),
279 dcc.Location(id="url", refresh=False),
280 self._add_ctrl_col(),
281 self._add_plotting_col()
299 def _add_navbar(self):
300 """Add nav element with navigation panel. It is placed on the top.
302 :returns: Navigation bar.
303 :rtype: dbc.NavbarSimple
305 return dbc.NavbarSimple(
306 id="navbarsimple-main",
319 brand_external_link=True,
324 def _add_ctrl_col(self) -> dbc.Col:
325 """Add column with controls. It is placed on the left side.
327 :returns: Column with the control panel.
332 children=self._add_ctrl_panel(),
333 className="sticky-top"
337 def _add_plotting_col(self) -> dbc.Col:
338 """Add column with plots. It is placed on the right side.
340 :returns: Column with plots.
344 id="col-plotting-area",
350 class_name="g-0 p-0",
361 def _add_ctrl_panel(self) -> list:
362 """Add control panel.
364 :returns: Control panel.
369 class_name="g-0 p-1",
374 children=show_tooltip(
381 id={"type": "ctrl-dd", "index": "rls"},
382 placeholder="Select a Release...",
385 {"label": k, "value": k} \
386 for k in self._spec_tbs.keys()
388 key=lambda d: d["label"]
397 class_name="g-0 p-1",
402 children=show_tooltip(
409 id={"type": "ctrl-dd", "index": "dut"},
410 placeholder="Select a Device under Test..."
418 class_name="g-0 p-1",
423 children=show_tooltip(
430 id={"type": "ctrl-dd", "index": "dutver"},
432 "Select a Version of Device under Test..."
440 class_name="g-0 p-1",
445 children=show_tooltip(
452 id={"type": "ctrl-dd", "index": "phy"},
454 "Select a Physical Test Bed Topology..."
462 class_name="g-0 p-1",
467 children=show_tooltip(
474 id={"type": "ctrl-dd", "index": "area"},
475 placeholder="Select an Area..."
483 class_name="g-0 p-1",
488 children=show_tooltip(
495 id={"type": "ctrl-dd", "index": "test"},
496 placeholder="Select a Test..."
504 class_name="g-0 p-1",
509 children=show_tooltip(
520 "index": "frmsize-all"
522 options=C.CL_ALL_DISABLED,
541 style={"align-items": "center"},
547 class_name="g-0 p-1",
552 children=show_tooltip(
565 options=C.CL_ALL_DISABLED,
584 style={"align-items": "center"},
590 class_name="g-0 p-1",
595 children=show_tooltip(
606 "index": "tsttype-all"
608 options=C.CL_ALL_DISABLED,
627 style={"align-items": "center"},
633 class_name="g-0 p-1",
638 children=show_tooltip(
649 "value": "normalize",
651 "Normalize to CPU frequency "
662 style={"align-items": "center"},
668 class_name="g-0 p-1",
671 id={"type": "ctrl-btn", "index": "add-test"},
672 children="Add Selected",
678 id="row-card-sel-tests",
679 class_name="g-0 p-1",
680 style=C.STYLE_DISABLED,
683 class_name="overflow-auto p-0",
686 style={"max-height": "14em"},
692 id="row-btns-sel-tests",
693 class_name="g-0 p-1",
694 style=C.STYLE_DISABLED,
699 id={"type": "ctrl-btn", "index": "rm-test"},
700 children="Remove Selected",
706 id={"type": "ctrl-btn", "index": "rm-test-all"},
707 children="Remove All",
718 def _get_plotting_area(
724 """Generate the plotting area with all its content.
726 :param tests: List of tests to be displayed in the graphs.
727 :param normalize: If true, the values in graphs are normalized.
728 :param url: URL to be displayed in the modal window.
730 :type normalize: bool
732 :returns: List of rows with elements to be displayed in the plotting
739 figs = graph_iterative(self._data, tests, self._graph_layout, normalize)
747 id={"type": "graph", "index": "tput"},
750 class_name="g-0 p-1",
759 id={"type": "graph", "index": "lat"},
762 class_name="g-0 p-1",
770 class_name="g-0 p-0",
782 "text-transform": "none",
783 "padding": "0rem 1rem"
788 dbc.ModalHeader(dbc.ModalTitle("URL")),
797 id="plot-btn-download",
798 children="Download Data",
802 "text-transform": "none",
803 "padding": "0rem 1rem"
806 dcc.Download(id="download-iterative-data")
809 "d-grid gap-0 d-md-flex justify-content-md-end"
816 def callbacks(self, app):
817 """Callbacks for the whole application.
819 :param app: The application.
825 Output("store-control-panel", "data"),
826 Output("store-selected-tests", "data"),
827 Output("plotting-area", "children"),
828 Output("row-card-sel-tests", "style"),
829 Output("row-btns-sel-tests", "style"),
830 Output("lg-selected", "children"),
832 Output({"type": "ctrl-dd", "index": "rls"}, "value"),
833 Output({"type": "ctrl-dd", "index": "dut"}, "options"),
834 Output({"type": "ctrl-dd", "index": "dut"}, "disabled"),
835 Output({"type": "ctrl-dd", "index": "dut"}, "value"),
836 Output({"type": "ctrl-dd", "index": "dutver"}, "options"),
837 Output({"type": "ctrl-dd", "index": "dutver"}, "disabled"),
838 Output({"type": "ctrl-dd", "index": "dutver"}, "value"),
839 Output({"type": "ctrl-dd", "index": "phy"}, "options"),
840 Output({"type": "ctrl-dd", "index": "phy"}, "disabled"),
841 Output({"type": "ctrl-dd", "index": "phy"}, "value"),
842 Output({"type": "ctrl-dd", "index": "area"}, "options"),
843 Output({"type": "ctrl-dd", "index": "area"}, "disabled"),
844 Output({"type": "ctrl-dd", "index": "area"}, "value"),
845 Output({"type": "ctrl-dd", "index": "test"}, "options"),
846 Output({"type": "ctrl-dd", "index": "test"}, "disabled"),
847 Output({"type": "ctrl-dd", "index": "test"}, "value"),
848 Output({"type": "ctrl-cl", "index": "core"}, "options"),
849 Output({"type": "ctrl-cl", "index": "core"}, "value"),
850 Output({"type": "ctrl-cl", "index": "core-all"}, "value"),
851 Output({"type": "ctrl-cl", "index": "core-all"}, "options"),
852 Output({"type": "ctrl-cl", "index": "frmsize"}, "options"),
853 Output({"type": "ctrl-cl", "index": "frmsize"}, "value"),
854 Output({"type": "ctrl-cl", "index": "frmsize-all"}, "value"),
855 Output({"type": "ctrl-cl", "index": "frmsize-all"}, "options"),
856 Output({"type": "ctrl-cl", "index": "tsttype"}, "options"),
857 Output({"type": "ctrl-cl", "index": "tsttype"}, "value"),
858 Output({"type": "ctrl-cl", "index": "tsttype-all"}, "value"),
859 Output({"type": "ctrl-cl", "index": "tsttype-all"}, "options"),
860 Output({"type": "ctrl-btn", "index": "add-test"}, "disabled"),
861 Output("normalize", "value")
864 State("store-control-panel", "data"),
865 State("store-selected-tests", "data"),
866 State({"type": "sel-cl", "index": ALL}, "value")
869 Input("url", "href"),
870 Input("normalize", "value"),
872 Input({"type": "ctrl-dd", "index": ALL}, "value"),
873 Input({"type": "ctrl-cl", "index": ALL}, "value"),
874 Input({"type": "ctrl-btn", "index": ALL}, "n_clicks")
877 def _update_application(
885 """Update the application when the event is detected.
888 ctrl_panel = ControlPanel(CP_PARAMS, control_panel)
892 parsed_url = url_decode(href)
894 url_params = parsed_url["params"]
898 plotting_area = no_update
899 row_card_sel_tests = no_update
900 row_btns_sel_tests = no_update
901 lg_selected = no_update
903 trigger = Trigger(callback_context.triggered)
905 if trigger.type == "url" and url_params:
907 store_sel = literal_eval(url_params["store_sel"][0])
908 normalize = literal_eval(url_params["norm"][0])
909 except (KeyError, IndexError):
912 row_card_sel_tests = C.STYLE_ENABLED
913 row_btns_sel_tests = C.STYLE_ENABLED
914 last_test = store_sel[-1]
915 test = self._spec_tbs[last_test["rls"]][last_test["dut"]]\
916 [last_test["dutver"]][last_test["phy"]]\
917 [last_test["area"]][last_test["test"]]
919 "dd-rls-val": last_test["rls"],
920 "dd-dut-val": last_test["dut"],
921 "dd-dut-opt": generate_options(
922 self._spec_tbs[last_test["rls"]].keys()
925 "dd-dutver-val": last_test["dutver"],
926 "dd-dutver-opt": generate_options(
927 self._spec_tbs[last_test["rls"]]\
928 [last_test["dut"]].keys()
930 "dd-dutver-dis": False,
931 "dd-phy-val": last_test["phy"],
932 "dd-phy-opt": generate_options(
933 self._spec_tbs[last_test["rls"]][last_test["dut"]]\
934 [last_test["dutver"]].keys()
937 "dd-area-val": last_test["area"],
939 {"label": label(v), "value": v} for v in \
940 sorted(self._spec_tbs[last_test["rls"]]\
941 [last_test["dut"]][last_test["dutver"]]\
942 [last_test["phy"]].keys())
944 "dd-area-dis": False,
945 "dd-test-val": last_test["test"],
946 "dd-test-opt": generate_options(
947 self._spec_tbs[last_test["rls"]][last_test["dut"]]\
948 [last_test["dutver"]][last_test["phy"]]\
949 [last_test["area"]].keys()
951 "dd-test-dis": False,
952 "cl-core-opt": generate_options(test["core"]),
953 "cl-core-val": [last_test["core"].upper(), ],
954 "cl-core-all-val": list(),
955 "cl-core-all-opt": C.CL_ALL_ENABLED,
956 "cl-frmsize-opt": generate_options(test["frame-size"]),
957 "cl-frmsize-val": [last_test["framesize"].upper(), ],
958 "cl-frmsize-all-val": list(),
959 "cl-frmsize-all-opt": C.CL_ALL_ENABLED,
960 "cl-tsttype-opt": generate_options(test["test-type"]),
961 "cl-tsttype-val": [last_test["testtype"].upper(), ],
962 "cl-tsttype-all-val": list(),
963 "cl-tsttype-all-opt": C.CL_ALL_ENABLED,
964 "cl-normalize-val": normalize,
968 elif trigger.type == "normalize":
969 ctrl_panel.set({"cl-normalize-val": normalize})
971 elif trigger.type == "ctrl-dd":
972 if trigger.idx == "rls":
974 options = generate_options(
975 self._spec_tbs[trigger.value].keys()
982 "dd-rls-val": trigger.value,
984 "dd-dut-opt": options,
985 "dd-dut-dis": disabled,
986 "dd-dutver-val": str(),
987 "dd-dutver-opt": list(),
988 "dd-dutver-dis": True,
990 "dd-phy-opt": list(),
992 "dd-area-val": str(),
993 "dd-area-opt": list(),
995 "dd-test-val": str(),
996 "dd-test-opt": list(),
998 "cl-core-opt": list(),
999 "cl-core-val": list(),
1000 "cl-core-all-val": list(),
1001 "cl-core-all-opt": C.CL_ALL_DISABLED,
1002 "cl-frmsize-opt": list(),
1003 "cl-frmsize-val": list(),
1004 "cl-frmsize-all-val": list(),
1005 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1006 "cl-tsttype-opt": list(),
1007 "cl-tsttype-val": list(),
1008 "cl-tsttype-all-val": list(),
1009 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1012 elif trigger.idx == "dut":
1014 rls = ctrl_panel.get("dd-rls-val")
1015 dut = self._spec_tbs[rls][trigger.value]
1016 options = generate_options(dut.keys())
1022 "dd-dut-val": trigger.value,
1023 "dd-dutver-val": str(),
1024 "dd-dutver-opt": options,
1025 "dd-dutver-dis": disabled,
1026 "dd-phy-val": str(),
1027 "dd-phy-opt": list(),
1029 "dd-area-val": str(),
1030 "dd-area-opt": list(),
1031 "dd-area-dis": True,
1032 "dd-test-val": str(),
1033 "dd-test-opt": list(),
1034 "dd-test-dis": True,
1035 "cl-core-opt": list(),
1036 "cl-core-val": list(),
1037 "cl-core-all-val": list(),
1038 "cl-core-all-opt": C.CL_ALL_DISABLED,
1039 "cl-frmsize-opt": list(),
1040 "cl-frmsize-val": list(),
1041 "cl-frmsize-all-val": list(),
1042 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1043 "cl-tsttype-opt": list(),
1044 "cl-tsttype-val": list(),
1045 "cl-tsttype-all-val": list(),
1046 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1049 elif trigger.idx == "dutver":
1051 rls = ctrl_panel.get("dd-rls-val")
1052 dut = ctrl_panel.get("dd-dut-val")
1053 dutver = self._spec_tbs[rls][dut][trigger.value]
1054 options = generate_options(dutver.keys())
1060 "dd-dutver-val": trigger.value,
1061 "dd-phy-val": str(),
1062 "dd-phy-opt": options,
1063 "dd-phy-dis": disabled,
1064 "dd-area-val": str(),
1065 "dd-area-opt": list(),
1066 "dd-area-dis": True,
1067 "dd-test-val": str(),
1068 "dd-test-opt": list(),
1069 "dd-test-dis": True,
1070 "cl-core-opt": list(),
1071 "cl-core-val": list(),
1072 "cl-core-all-val": list(),
1073 "cl-core-all-opt": C.CL_ALL_DISABLED,
1074 "cl-frmsize-opt": list(),
1075 "cl-frmsize-val": list(),
1076 "cl-frmsize-all-val": list(),
1077 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1078 "cl-tsttype-opt": list(),
1079 "cl-tsttype-val": list(),
1080 "cl-tsttype-all-val": list(),
1081 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1084 elif trigger.idx == "phy":
1086 rls = ctrl_panel.get("dd-rls-val")
1087 dut = ctrl_panel.get("dd-dut-val")
1088 dutver = ctrl_panel.get("dd-dutver-val")
1089 phy = self._spec_tbs[rls][dut][dutver][trigger.value]
1090 options = [{"label": label(v), "value": v} \
1091 for v in sorted(phy.keys())]
1097 "dd-phy-val": trigger.value,
1098 "dd-area-val": str(),
1099 "dd-area-opt": options,
1100 "dd-area-dis": disabled,
1101 "dd-test-val": str(),
1102 "dd-test-opt": list(),
1103 "dd-test-dis": True,
1104 "cl-core-opt": list(),
1105 "cl-core-val": list(),
1106 "cl-core-all-val": list(),
1107 "cl-core-all-opt": C.CL_ALL_DISABLED,
1108 "cl-frmsize-opt": list(),
1109 "cl-frmsize-val": list(),
1110 "cl-frmsize-all-val": list(),
1111 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1112 "cl-tsttype-opt": list(),
1113 "cl-tsttype-val": list(),
1114 "cl-tsttype-all-val": list(),
1115 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1118 elif trigger.idx == "area":
1120 rls = ctrl_panel.get("dd-rls-val")
1121 dut = ctrl_panel.get("dd-dut-val")
1122 dutver = ctrl_panel.get("dd-dutver-val")
1123 phy = ctrl_panel.get("dd-phy-val")
1125 self._spec_tbs[rls][dut][dutver][phy][trigger.value]
1126 options = generate_options(area.keys())
1132 "dd-area-val": trigger.value,
1133 "dd-test-val": str(),
1134 "dd-test-opt": options,
1135 "dd-test-dis": disabled,
1136 "cl-core-opt": list(),
1137 "cl-core-val": list(),
1138 "cl-core-all-val": list(),
1139 "cl-core-all-opt": C.CL_ALL_DISABLED,
1140 "cl-frmsize-opt": list(),
1141 "cl-frmsize-val": list(),
1142 "cl-frmsize-all-val": list(),
1143 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1144 "cl-tsttype-opt": list(),
1145 "cl-tsttype-val": list(),
1146 "cl-tsttype-all-val": list(),
1147 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1150 elif trigger.idx == "test":
1151 rls = ctrl_panel.get("dd-rls-val")
1152 dut = ctrl_panel.get("dd-dut-val")
1153 dutver = ctrl_panel.get("dd-dutver-val")
1154 phy = ctrl_panel.get("dd-phy-val")
1155 area = ctrl_panel.get("dd-area-val")
1156 if all((rls, dut, dutver, phy, area, trigger.value, )):
1157 test = self._spec_tbs[rls][dut][dutver][phy][area]\
1160 "dd-test-val": trigger.value,
1161 "cl-core-opt": generate_options(test["core"]),
1162 "cl-core-val": list(),
1163 "cl-core-all-val": list(),
1164 "cl-core-all-opt": C.CL_ALL_ENABLED,
1166 generate_options(test["frame-size"]),
1167 "cl-frmsize-val": list(),
1168 "cl-frmsize-all-val": list(),
1169 "cl-frmsize-all-opt": C.CL_ALL_ENABLED,
1171 generate_options(test["test-type"]),
1172 "cl-tsttype-val": list(),
1173 "cl-tsttype-all-val": list(),
1174 "cl-tsttype-all-opt": C.CL_ALL_ENABLED,
1177 elif trigger.type == "ctrl-cl":
1178 param = trigger.idx.split("-")[0]
1179 if "-all" in trigger.idx:
1180 c_sel, c_all, c_id = list(), trigger.value, "all"
1182 c_sel, c_all, c_id = trigger.value, list(), str()
1183 val_sel, val_all = sync_checklists(
1184 options=ctrl_panel.get(f"cl-{param}-opt"),
1190 f"cl-{param}-val": val_sel,
1191 f"cl-{param}-all-val": val_all,
1193 if all((ctrl_panel.get("cl-core-val"),
1194 ctrl_panel.get("cl-frmsize-val"),
1195 ctrl_panel.get("cl-tsttype-val"), )):
1196 ctrl_panel.set({"btn-add-dis": False})
1198 ctrl_panel.set({"btn-add-dis": True})
1199 elif trigger.type == "ctrl-btn":
1201 if trigger.idx == "add-test":
1202 rls = ctrl_panel.get("dd-rls-val")
1203 dut = ctrl_panel.get("dd-dut-val")
1204 dutver = ctrl_panel.get("dd-dutver-val")
1205 phy = ctrl_panel.get("dd-phy-val")
1206 area = ctrl_panel.get("dd-area-val")
1207 test = ctrl_panel.get("dd-test-val")
1208 # Add selected test to the list of tests in store:
1209 if store_sel is None:
1211 for core in ctrl_panel.get("cl-core-val"):
1212 for framesize in ctrl_panel.get("cl-frmsize-val"):
1213 for ttype in ctrl_panel.get("cl-tsttype-val"):
1220 phy.replace("af_xdp", "af-xdp"),
1227 if tid not in [i["id"] for i in store_sel]:
1236 "framesize": framesize.lower(),
1237 "core": core.lower(),
1238 "testtype": ttype.lower()
1240 store_sel = sorted(store_sel, key=lambda d: d["id"])
1241 if C.CLEAR_ALL_INPUTS:
1242 ctrl_panel.set(ctrl_panel.defaults)
1243 elif trigger.idx == "rm-test" and lst_sel:
1244 new_store_sel = list()
1245 for idx, item in enumerate(store_sel):
1246 if not lst_sel[idx]:
1247 new_store_sel.append(item)
1248 store_sel = new_store_sel
1249 elif trigger.idx == "rm-test-all":
1254 lg_selected = get_list_group_items(store_sel)
1255 plotting_area = self._get_plotting_area(
1260 {"store_sel": store_sel, "norm": normalize}
1263 row_card_sel_tests = C.STYLE_ENABLED
1264 row_btns_sel_tests = C.STYLE_ENABLED
1266 plotting_area = C.PLACEHOLDER
1267 row_card_sel_tests = C.STYLE_DISABLED
1268 row_btns_sel_tests = C.STYLE_DISABLED
1279 ret_val.extend(ctrl_panel.values)
1283 Output("plot-mod-url", "is_open"),
1284 [Input("plot-btn-url", "n_clicks")],
1285 [State("plot-mod-url", "is_open")],
1287 def toggle_plot_mod_url(n, is_open):
1288 """Toggle the modal window with url.
1295 Output("download-iterative-data", "data"),
1296 State("store-selected-tests", "data"),
1297 Input("plot-btn-download", "n_clicks"),
1298 prevent_initial_call=True
1300 def _download_trending_data(store_sel, _):
1301 """Download the data
1303 :param store_sel: List of tests selected by user stored in the
1305 :type store_sel: list
1306 :returns: dict of data frame content (base64 encoded) and meta data
1307 used by the Download component.
1315 for itm in store_sel:
1316 sel_data = select_iterative_data(self._data, itm)
1317 if sel_data is None:
1319 df = pd.concat([df, sel_data], ignore_index=True)
1321 return dcc.send_data_frame(df.to_csv, C.REPORT_DOWNLOAD_FILE_NAME)