+ def _list_tests():
+ # Display selected tests with checkboxes:
+ if store_sel:
+ return [
+ {"label": v["id"], "value": v["id"]} for v in store_sel
+ ]
+ else:
+ return list()
+
+ class RetunValue:
+ def __init__(self) -> None:
+ self._output = {
+ "graph-tput-figure": no_update,
+ "graph-lat-figure": no_update,
+ "selected-tests-data": no_update,
+ "cl-selected-options": no_update,
+ "dd-ctrl-phy-value": no_update,
+ "dd-ctrl-area-value": no_update,
+ "dd-ctrl-test-value": no_update,
+ }
+
+ def value(self):
+ return tuple(self._output.values())
+
+ def set_values(self, kwargs: dict) -> None:
+ for key, val in kwargs.items():
+ if key in self._output:
+ self._output[key] = val
+ else:
+ raise KeyError(f"The key {key} is not defined.")
+
+
+ trigger_id = callback_context.triggered[0]["prop_id"].split(".")[0]
+
+ d_start = datetime(int(d_start[0:4]), int(d_start[5:7]),
+ int(d_start[8:10]))
+ d_end = datetime(int(d_end[0:4]), int(d_end[5:7]), int(d_end[8:10]))
+
+ output = RetunValue()
+
+ if trigger_id == "btn-ctrl-add":
+ # Add selected test to the list of tests in store:
+ if phy and area and test and cores and framesizes and testtypes:
+ if store_sel is None:
+ store_sel = list()
+ for core in cores:
+ for framesize in framesizes:
+ for ttype in testtypes:
+ tid = (
+ f"{phy.replace('af_xdp', 'af-xdp')}-"
+ f"{area}-"
+ f"{framesize.lower()}-"
+ f"{core.lower()}-"
+ f"{test}-"
+ f"{ttype.lower()}"
+ )
+ if tid not in [itm["id"] for itm in store_sel]:
+ store_sel.append({
+ "id": tid,
+ "phy": phy,
+ "area": area,
+ "test": test,
+ "framesize": framesize.lower(),
+ "core": core.lower(),
+ "testtype": ttype.lower()
+ })
+ output.set_values({
+ "selected-tests-data": store_sel,
+ "cl-selected-options": _list_tests(),
+ "dd-ctrl-phy-value": None,
+ "dd-ctrl-area-value": None,
+ "dd-ctrl-test-value": None,
+ })
+
+ elif trigger_id in ("btn-sel-display", "dpr-period"):
+ fig_tput, fig_lat = graph_trending(
+ self.data, store_sel, self.layout, d_start, d_end
+ )
+ output.set_values({
+ "graph-tput-figure": \
+ fig_tput if fig_tput else self.NO_GRAPH,
+ "graph-lat-figure": \
+ fig_lat if fig_lat else self.NO_GRAPH,
+ })
+ elif trigger_id == "btn-sel-remove-all":
+ output.set_values({
+ "graph-tput-figure": self.NO_GRAPH,
+ "graph-lat-figure": self.NO_GRAPH,
+ "selected-tests-data": list(),
+ "cl-selected-options": list()
+ })
+ elif trigger_id == "btn-sel-remove":
+ if list_sel:
+ new_store_sel = list()
+ for item in store_sel:
+ if item["id"] not in list_sel:
+ new_store_sel.append(item)
+ store_sel = new_store_sel
+ if store_sel:
+ fig_tput, fig_lat = graph_trending(
+ self.data, store_sel, self.layout, d_start, d_end
+ )
+ output.set_values({
+ "graph-tput-figure": \
+ fig_tput if fig_tput else self.NO_GRAPH,
+ "graph-lat-figure": \
+ fig_lat if fig_lat else self.NO_GRAPH,
+ "selected-tests-data": store_sel,
+ "cl-selected-options": _list_tests()
+ })
+ else:
+ output.set_values({
+ "graph-tput-figure": self.NO_GRAPH,
+ "graph-lat-figure": self.NO_GRAPH,
+ "selected-tests-data": store_sel,
+ "cl-selected-options": _list_tests()
+ })
+
+ return output.value()
+
+ @app.callback(
+ Output("metadata-tput-lat", "children"),
+ Output("metadata-hdrh-graph", "children"),
+ Output("offcanvas-metadata", "is_open"),
+ Input("graph-tput", "clickData"),
+ Input("graph-latency", "clickData")
+ )
+ def _show_tput_metadata(tput_data, lat_data) -> dbc.Card:
+ """
+ """
+ if not (tput_data or lat_data):