1 # Copyright (c) 2023 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.
15 """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
36 from ..utils.url_processing import url_decode
37 from ..data.data import Data
38 from .graphs import graph_trending, graph_hdrh_latency, select_trending_data
41 # Control panel partameters and their default values.
47 "dd-area-opt": list(),
50 "dd-test-opt": list(),
53 "cl-core-opt": list(),
54 "cl-core-val": list(),
55 "cl-core-all-val": list(),
56 "cl-core-all-opt": C.CL_ALL_DISABLED,
57 "cl-frmsize-opt": list(),
58 "cl-frmsize-val": list(),
59 "cl-frmsize-all-val": list(),
60 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
61 "cl-tsttype-opt": list(),
62 "cl-tsttype-val": list(),
63 "cl-tsttype-all-val": list(),
64 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
66 "cl-normalize-val": list()
71 """The layout of the dash app and the callbacks.
74 def __init__(self, app: Flask, html_layout_file: str,
75 graph_layout_file: str, data_spec_file: str, tooltip_file: str,
76 time_period: str=None) -> None:
78 - save the input parameters,
79 - read and pre-process the data,
80 - prepare data for the control panel,
81 - read HTML layout file,
82 - read tooltips from the tooltip file.
84 :param app: Flask application running the dash application.
85 :param html_layout_file: Path and name of the file specifying the HTML
86 layout of the dash application.
87 :param graph_layout_file: Path and name of the file with layout of
89 :param data_spec_file: Path and name of the file specifying the data to
90 be read from parquets for this application.
91 :param tooltip_file: Path and name of the yaml file specifying the
93 :param time_period: It defines the time period for data read from the
94 parquets in days from now back to the past.
96 :type html_layout_file: str
97 :type graph_layout_file: str
98 :type data_spec_file: str
99 :type tooltip_file: str
100 :type time_period: int
105 self._html_layout_file = html_layout_file
106 self._graph_layout_file = graph_layout_file
107 self._data_spec_file = data_spec_file
108 self._tooltip_file = tooltip_file
109 self._time_period = time_period
113 data_spec_file=self._data_spec_file,
115 ).read_trending_mrr(days=self._time_period)
118 data_spec_file=self._data_spec_file,
120 ).read_trending_ndrpdr(days=self._time_period)
122 self._data = pd.concat([data_mrr, data_ndrpdr], ignore_index=True)
124 # Get structure of tests:
126 for _, row in self._data[["job", "test_id"]].drop_duplicates().\
128 lst_job = row["job"].split("-")
131 tbed = "-".join(lst_job[-2:])
132 lst_test = row["test_id"].split(".")
136 area = "-".join(lst_test[3:-2])
137 suite = lst_test[-2].replace("2n1l-", "").replace("1n1l-", "").\
140 nic = suite.split("-")[0]
141 for drv in C.DRIVERS:
147 test = test.replace(f"{drv}-", "")
151 infra = "-".join((tbed, nic, driver))
152 lst_test = test.split("-")
153 framesize = lst_test[0]
154 core = lst_test[1] if lst_test[1] else "8C"
155 test = "-".join(lst_test[2: -1])
157 if tbs.get(dut, None) is None:
159 if tbs[dut].get(infra, None) is None:
160 tbs[dut][infra] = dict()
161 if tbs[dut][infra].get(area, None) is None:
162 tbs[dut][infra][area] = dict()
163 if tbs[dut][infra][area].get(test, None) is None:
164 tbs[dut][infra][area][test] = dict()
165 tbs[dut][infra][area][test]["core"] = list()
166 tbs[dut][infra][area][test]["frame-size"] = list()
167 tbs[dut][infra][area][test]["test-type"] = list()
168 if core.upper() not in tbs[dut][infra][area][test]["core"]:
169 tbs[dut][infra][area][test]["core"].append(core.upper())
170 if framesize.upper() not in \
171 tbs[dut][infra][area][test]["frame-size"]:
172 tbs[dut][infra][area][test]["frame-size"].append(
176 if "MRR" not in tbs[dut][infra][area][test]["test-type"]:
177 tbs[dut][infra][area][test]["test-type"].append("MRR")
178 elif ttype == "ndrpdr":
179 if "NDR" not in tbs[dut][infra][area][test]["test-type"]:
180 tbs[dut][infra][area][test]["test-type"].extend(
186 self._html_layout = str()
187 self._graph_layout = None
188 self._tooltips = dict()
191 with open(self._html_layout_file, "r") as file_read:
192 self._html_layout = file_read.read()
193 except IOError as err:
195 f"Not possible to open the file {self._html_layout_file}\n{err}"
199 with open(self._graph_layout_file, "r") as file_read:
200 self._graph_layout = load(file_read, Loader=FullLoader)
201 except IOError as err:
203 f"Not possible to open the file {self._graph_layout_file}\n"
206 except YAMLError as err:
208 f"An error occurred while parsing the specification file "
209 f"{self._graph_layout_file}\n{err}"
213 with open(self._tooltip_file, "r") as file_read:
214 self._tooltips = load(file_read, Loader=FullLoader)
215 except IOError as err:
217 f"Not possible to open the file {self._tooltip_file}\n{err}"
219 except YAMLError as err:
221 f"An error occurred while parsing the specification file "
222 f"{self._tooltip_file}\n{err}"
226 if self._app is not None and hasattr(self, "callbacks"):
227 self.callbacks(self._app)
230 def html_layout(self):
231 return self._html_layout
233 def add_content(self):
234 """Top level method which generated the web page.
237 - Store for user input data,
239 - Main area with control panel and ploting area.
241 If no HTML layout is provided, an error message is displayed instead.
243 :returns: The HTML div with the whole page.
247 if self.html_layout and self._spec_tbs:
262 id="offcanvas-metadata",
263 title="Throughput And Latency",
267 dbc.Row(id="metadata-tput-lat"),
268 dbc.Row(id="metadata-hdrh-graph")
276 dcc.Store(id="store-selected-tests"),
277 dcc.Store(id="store-control-panel"),
278 dcc.Location(id="url", refresh=False),
279 self._add_ctrl_col(),
280 self._add_plotting_col()
298 def _add_navbar(self):
299 """Add nav element with navigation panel. It is placed on the top.
301 :returns: Navigation bar.
302 :rtype: dbc.NavbarSimple
304 return dbc.NavbarSimple(
305 id="navbarsimple-main",
318 brand_external_link=True,
323 def _add_ctrl_col(self) -> dbc.Col:
324 """Add column with controls. It is placed on the left side.
326 :returns: Column with the control panel.
331 children=self._add_ctrl_panel(),
332 className="sticky-top"
336 def _add_plotting_col(self) -> dbc.Col:
337 """Add column with plots and tables. It is placed on the right side.
339 :returns: Column with tables.
343 id="col-plotting-area",
349 class_name="g-0 p-0",
360 def _add_ctrl_panel(self) -> list:
361 """Add control panel.
363 :returns: Control panel.
368 class_name="g-0 p-1",
373 children=show_tooltip(
380 id={"type": "ctrl-dd", "index": "dut"},
381 placeholder="Select a Device under Test...",
384 {"label": k, "value": k} \
385 for k in self._spec_tbs.keys()
387 key=lambda d: d["label"]
396 class_name="g-0 p-1",
401 children=show_tooltip(
408 id={"type": "ctrl-dd", "index": "phy"},
410 "Select a Physical Test Bed Topology..."
418 class_name="g-0 p-1",
423 children=show_tooltip(
430 id={"type": "ctrl-dd", "index": "area"},
431 placeholder="Select an Area..."
439 class_name="g-0 p-1",
444 children=show_tooltip(
451 id={"type": "ctrl-dd", "index": "test"},
452 placeholder="Select a Test..."
460 class_name="g-0 p-1",
465 children=show_tooltip(
476 "index": "frmsize-all"
478 options=C.CL_ALL_DISABLED,
497 style={"align-items": "center"},
503 class_name="g-0 p-1",
508 children=show_tooltip(
521 options=C.CL_ALL_DISABLED,
540 style={"align-items": "center"},
546 class_name="g-0 p-1",
551 children=show_tooltip(
562 "index": "tsttype-all"
564 options=C.CL_ALL_DISABLED,
583 style={"align-items": "center"},
589 class_name="g-0 p-1",
594 children=show_tooltip(
605 "value": "normalize",
607 "Normalize to CPU frequency "
618 style={"align-items": "center"},
624 class_name="g-0 p-1",
627 id={"type": "ctrl-btn", "index": "add-test"},
628 children="Add Selected",
634 id="row-card-sel-tests",
635 class_name="g-0 p-1",
636 style=C.STYLE_DISABLED,
639 class_name="overflow-auto p-0",
642 style={"max-height": "14em"},
648 id="row-btns-sel-tests",
649 class_name="g-0 p-1",
650 style=C.STYLE_DISABLED,
655 id={"type": "ctrl-btn", "index": "rm-test"},
656 children="Remove Selected",
662 id={"type": "ctrl-btn", "index": "rm-test-all"},
663 children="Remove All",
674 def _get_plotting_area(
680 """Generate the plotting area with all its content.
685 figs = graph_trending(self._data, tests, self._graph_layout, normalize)
693 id={"type": "graph", "index": "tput"},
705 id={"type": "graph", "index": "lat"},
718 active_tab="tab-tput",
731 "text-transform": "none",
732 "padding": "0rem 1rem"
737 dbc.ModalHeader(dbc.ModalTitle("URL")),
746 id="plot-btn-download",
747 children="Download Data",
751 "text-transform": "none",
752 "padding": "0rem 1rem"
755 dcc.Download(id="download-trending-data")
758 "d-grid gap-0 d-md-flex justify-content-md-end"
777 class_name="g-0 p-1",
778 start_collapsed=False,
780 active_item=[f"item-{i}" for i in range(len(acc_items))]
782 class_name="g-0 p-0",
788 # id="btn-add-telemetry",
789 # children="Add Panel with Telemetry",
793 # "text-transform": "none",
794 # "padding": "0rem 1rem"
799 # "d-grid gap-0 d-md-flex justify-content-md-end"
801 # class_name="g-0 p-0"
806 def callbacks(self, app):
807 """Callbacks for the whole application.
809 :param app: The application.
815 Output("store-control-panel", "data"),
816 Output("store-selected-tests", "data"),
817 Output("plotting-area", "children"),
818 Output("row-card-sel-tests", "style"),
819 Output("row-btns-sel-tests", "style"),
820 Output("lg-selected", "children"),
822 Output({"type": "ctrl-dd", "index": "dut"}, "value"),
823 Output({"type": "ctrl-dd", "index": "phy"}, "options"),
824 Output({"type": "ctrl-dd", "index": "phy"}, "disabled"),
825 Output({"type": "ctrl-dd", "index": "phy"}, "value"),
826 Output({"type": "ctrl-dd", "index": "area"}, "options"),
827 Output({"type": "ctrl-dd", "index": "area"}, "disabled"),
828 Output({"type": "ctrl-dd", "index": "area"}, "value"),
829 Output({"type": "ctrl-dd", "index": "test"}, "options"),
830 Output({"type": "ctrl-dd", "index": "test"}, "disabled"),
831 Output({"type": "ctrl-dd", "index": "test"}, "value"),
832 Output({"type": "ctrl-cl", "index": "core"}, "options"),
833 Output({"type": "ctrl-cl", "index": "core"}, "value"),
834 Output({"type": "ctrl-cl", "index": "core-all"}, "value"),
835 Output({"type": "ctrl-cl", "index": "core-all"}, "options"),
836 Output({"type": "ctrl-cl", "index": "frmsize"}, "options"),
837 Output({"type": "ctrl-cl", "index": "frmsize"}, "value"),
838 Output({"type": "ctrl-cl", "index": "frmsize-all"}, "value"),
839 Output({"type": "ctrl-cl", "index": "frmsize-all"}, "options"),
840 Output({"type": "ctrl-cl", "index": "tsttype"}, "options"),
841 Output({"type": "ctrl-cl", "index": "tsttype"}, "value"),
842 Output({"type": "ctrl-cl", "index": "tsttype-all"}, "value"),
843 Output({"type": "ctrl-cl", "index": "tsttype-all"}, "options"),
844 Output({"type": "ctrl-btn", "index": "add-test"}, "disabled"),
845 Output("normalize", "value")
848 State("store-control-panel", "data"),
849 State("store-selected-tests", "data"),
850 State({"type": "sel-cl", "index": ALL}, "value")
853 Input("url", "href"),
854 Input("normalize", "value"),
856 Input({"type": "ctrl-dd", "index": ALL}, "value"),
857 Input({"type": "ctrl-cl", "index": ALL}, "value"),
858 Input({"type": "ctrl-btn", "index": ALL}, "n_clicks")
861 def _update_application(
869 """Update the application when the event is detected.
872 ctrl_panel = ControlPanel(CP_PARAMS, control_panel)
876 parsed_url = url_decode(href)
878 url_params = parsed_url["params"]
882 plotting_area = no_update
883 row_card_sel_tests = no_update
884 row_btns_sel_tests = no_update
885 lg_selected = no_update
887 trigger = Trigger(callback_context.triggered)
889 if trigger.type == "url" and url_params:
891 store_sel = literal_eval(url_params["store_sel"][0])
892 normalize = literal_eval(url_params["norm"][0])
893 except (KeyError, IndexError):
896 last_test = store_sel[-1]
897 test = self._spec_tbs[last_test["dut"]][last_test["phy"]]\
898 [last_test["area"]][last_test["test"]]
900 "dd-dut-val": last_test["dut"],
901 "dd-phy-val": last_test["phy"],
902 "dd-phy-opt": generate_options(
903 self._spec_tbs[last_test["dut"]].keys()
906 "dd-area-val": last_test["area"],
908 {"label": label(v), "value": v} for v in sorted(
909 self._spec_tbs[last_test["dut"]]\
910 [last_test["phy"]].keys()
913 "dd-area-dis": False,
914 "dd-test-val": last_test["test"],
915 "dd-test-opt": generate_options(
916 self._spec_tbs[last_test["dut"]][last_test["phy"]]\
917 [last_test["area"]].keys()
919 "dd-test-dis": False,
920 "cl-core-opt": generate_options(test["core"]),
921 "cl-core-val": [last_test["core"].upper(), ],
922 "cl-core-all-val": list(),
923 "cl-core-all-opt": C.CL_ALL_ENABLED,
924 "cl-frmsize-opt": generate_options(test["frame-size"]),
925 "cl-frmsize-val": [last_test["framesize"].upper(), ],
926 "cl-frmsize-all-val": list(),
927 "cl-frmsize-all-opt": C.CL_ALL_ENABLED,
928 "cl-tsttype-opt": generate_options(test["test-type"]),
929 "cl-tsttype-val": [last_test["testtype"].upper(), ],
930 "cl-tsttype-all-val": list(),
931 "cl-tsttype-all-opt": C.CL_ALL_ENABLED,
932 "cl-normalize-val": normalize,
936 elif trigger.type == "normalize":
937 ctrl_panel.set({"cl-normalize-val": normalize})
939 elif trigger.type == "ctrl-dd":
940 if trigger.idx == "dut":
942 options = generate_options(
943 self._spec_tbs[trigger.value].keys()
950 "dd-dut-val": trigger.value,
952 "dd-phy-opt": options,
953 "dd-phy-dis": disabled,
954 "dd-area-val": str(),
955 "dd-area-opt": list(),
957 "dd-test-val": str(),
958 "dd-test-opt": list(),
960 "cl-core-opt": list(),
961 "cl-core-val": list(),
962 "cl-core-all-val": list(),
963 "cl-core-all-opt": C.CL_ALL_DISABLED,
964 "cl-frmsize-opt": list(),
965 "cl-frmsize-val": list(),
966 "cl-frmsize-all-val": list(),
967 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
968 "cl-tsttype-opt": list(),
969 "cl-tsttype-val": list(),
970 "cl-tsttype-all-val": list(),
971 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
974 elif trigger.idx == "phy":
976 dut = ctrl_panel.get("dd-dut-val")
977 phy = self._spec_tbs[dut][trigger.value]
978 options = [{"label": label(v), "value": v} \
979 for v in sorted(phy.keys())]
985 "dd-phy-val": trigger.value,
986 "dd-area-val": str(),
987 "dd-area-opt": options,
988 "dd-area-dis": disabled,
989 "dd-test-val": str(),
990 "dd-test-opt": list(),
992 "cl-core-opt": list(),
993 "cl-core-val": list(),
994 "cl-core-all-val": list(),
995 "cl-core-all-opt": C.CL_ALL_DISABLED,
996 "cl-frmsize-opt": list(),
997 "cl-frmsize-val": list(),
998 "cl-frmsize-all-val": list(),
999 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1000 "cl-tsttype-opt": list(),
1001 "cl-tsttype-val": list(),
1002 "cl-tsttype-all-val": list(),
1003 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1006 elif trigger.idx == "area":
1008 dut = ctrl_panel.get("dd-dut-val")
1009 phy = ctrl_panel.get("dd-phy-val")
1010 area = self._spec_tbs[dut][phy][trigger.value]
1011 options = generate_options(area.keys())
1017 "dd-area-val": trigger.value,
1018 "dd-test-val": str(),
1019 "dd-test-opt": options,
1020 "dd-test-dis": disabled,
1021 "cl-core-opt": list(),
1022 "cl-core-val": list(),
1023 "cl-core-all-val": list(),
1024 "cl-core-all-opt": C.CL_ALL_DISABLED,
1025 "cl-frmsize-opt": list(),
1026 "cl-frmsize-val": list(),
1027 "cl-frmsize-all-val": list(),
1028 "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1029 "cl-tsttype-opt": list(),
1030 "cl-tsttype-val": list(),
1031 "cl-tsttype-all-val": list(),
1032 "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1035 elif trigger.idx == "test":
1036 dut = ctrl_panel.get("dd-dut-val")
1037 phy = ctrl_panel.get("dd-phy-val")
1038 area = ctrl_panel.get("dd-area-val")
1039 if all((dut, phy, area, trigger.value, )):
1040 test = self._spec_tbs[dut][phy][area][trigger.value]
1042 "dd-test-val": trigger.value,
1043 "cl-core-opt": generate_options(test["core"]),
1044 "cl-core-val": list(),
1045 "cl-core-all-val": list(),
1046 "cl-core-all-opt": C.CL_ALL_ENABLED,
1048 generate_options(test["frame-size"]),
1049 "cl-frmsize-val": list(),
1050 "cl-frmsize-all-val": list(),
1051 "cl-frmsize-all-opt": C.CL_ALL_ENABLED,
1053 generate_options(test["test-type"]),
1054 "cl-tsttype-val": list(),
1055 "cl-tsttype-all-val": list(),
1056 "cl-tsttype-all-opt": C.CL_ALL_ENABLED,
1059 elif trigger.type == "ctrl-cl":
1060 param = trigger.idx.split("-")[0]
1061 if "-all" in trigger.idx:
1062 c_sel, c_all, c_id = list(), trigger.value, "all"
1064 c_sel, c_all, c_id = trigger.value, list(), str()
1065 val_sel, val_all = sync_checklists(
1066 options=ctrl_panel.get(f"cl-{param}-opt"),
1072 f"cl-{param}-val": val_sel,
1073 f"cl-{param}-all-val": val_all,
1075 if all((ctrl_panel.get("cl-core-val"),
1076 ctrl_panel.get("cl-frmsize-val"),
1077 ctrl_panel.get("cl-tsttype-val"), )):
1078 ctrl_panel.set({"btn-add-dis": False})
1080 ctrl_panel.set({"btn-add-dis": True})
1081 elif trigger.type == "ctrl-btn":
1083 if trigger.idx == "add-test":
1084 dut = ctrl_panel.get("dd-dut-val")
1085 phy = ctrl_panel.get("dd-phy-val")
1086 area = ctrl_panel.get("dd-area-val")
1087 test = ctrl_panel.get("dd-test-val")
1088 # Add selected test(s) to the list of tests in store:
1089 if store_sel is None:
1091 for core in ctrl_panel.get("cl-core-val"):
1092 for framesize in ctrl_panel.get("cl-frmsize-val"):
1093 for ttype in ctrl_panel.get("cl-tsttype-val"):
1098 phy.replace('af_xdp', 'af-xdp'),
1105 if tid not in [i["id"] for i in store_sel]:
1112 "framesize": framesize.lower(),
1113 "core": core.lower(),
1114 "testtype": ttype.lower()
1116 store_sel = sorted(store_sel, key=lambda d: d["id"])
1117 if C.CLEAR_ALL_INPUTS:
1118 ctrl_panel.set(ctrl_panel.defaults)
1119 elif trigger.idx == "rm-test" and lst_sel:
1120 new_store_sel = list()
1121 for idx, item in enumerate(store_sel):
1122 if not lst_sel[idx]:
1123 new_store_sel.append(item)
1124 store_sel = new_store_sel
1125 elif trigger.idx == "rm-test-all":
1130 lg_selected = get_list_group_items(store_sel)
1131 plotting_area = self._get_plotting_area(
1136 {"store_sel": store_sel, "norm": normalize}
1139 row_card_sel_tests = C.STYLE_ENABLED
1140 row_btns_sel_tests = C.STYLE_ENABLED
1142 plotting_area = C.PLACEHOLDER
1143 row_card_sel_tests = C.STYLE_DISABLED
1144 row_btns_sel_tests = C.STYLE_DISABLED
1155 ret_val.extend(ctrl_panel.values)
1159 Output("plot-mod-url", "is_open"),
1160 [Input("plot-btn-url", "n_clicks")],
1161 [State("plot-mod-url", "is_open")],
1163 def toggle_plot_mod_url(n, is_open):
1164 """Toggle the modal window with url.
1171 Output("metadata-tput-lat", "children"),
1172 Output("metadata-hdrh-graph", "children"),
1173 Output("offcanvas-metadata", "is_open"),
1174 Input({"type": "graph", "index": ALL}, "clickData"),
1175 prevent_initial_call=True
1177 def _show_metadata_from_graphs(graph_data: dict) -> tuple:
1178 """Generates the data for the offcanvas displayed when a particular
1179 point in a graph is clicked on.
1181 :param graph_data: The data from the clicked point in the graph.
1182 :type graph_data: dict
1183 :returns: The data to be displayed on the offcanvas and the
1184 information to show the offcanvas.
1185 :rtype: tuple(list, list, bool)
1188 trigger = Trigger(callback_context.triggered)
1191 idx = 0 if trigger.idx == "tput" else 1
1192 graph_data = graph_data[idx]["points"][0]
1193 except (IndexError, KeyError, ValueError, TypeError):
1196 metadata = no_update
1201 [dbc.Badge(x.split(":")[0]), x.split(": ")[1]]
1202 ) for x in graph_data.get("text", "").split("<br>")
1204 if trigger.idx == "tput":
1205 title = "Throughput"
1206 elif trigger.idx == "lat":
1208 hdrh_data = graph_data.get("customdata", None)
1211 class_name="gy-2 p-0",
1213 dbc.CardHeader(hdrh_data.pop("name")),
1214 dbc.CardBody(children=[
1216 id="hdrh-latency-graph",
1217 figure=graph_hdrh_latency(
1218 hdrh_data, self._graph_layout
1229 class_name="gy-2 p-0",
1231 dbc.CardHeader(children=[
1233 target_id="tput-lat-metadata",
1235 style={"display": "inline-block"}
1240 id="tput-lat-metadata",
1242 children=[dbc.ListGroup(children, flush=True), ]
1248 return metadata, graph, True
1251 Output("download-trending-data", "data"),
1252 State("store-selected-tests", "data"),
1253 Input("plot-btn-download", "n_clicks"),
1254 prevent_initial_call=True
1256 def _download_trending_data(store_sel, _):
1257 """Download the data
1259 :param store_sel: List of tests selected by user stored in the
1261 :type store_sel: list
1262 :returns: dict of data frame content (base64 encoded) and meta data
1263 used by the Download component.
1271 for itm in store_sel:
1272 sel_data = select_trending_data(self._data, itm)
1273 if sel_data is None:
1275 df = pd.concat([df, sel_data], ignore_index=True)
1277 return dcc.send_data_frame(df.to_csv, C.TREND_DOWNLOAD_FILE_NAME)