X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=resources%2Ftools%2Fdash%2Fapp%2Fpal%2Freport%2Flayout.py;h=e7c8db43ae3a1d126d13ec3799ed1b131a3f0869;hb=06d3f7331f9f10d99baa334b1808dfdc9c6fc8be;hp=26b9a9f4b5fc557d74661dad81c2de5001abb516;hpb=3343fe81729eb4005319ca15b1e6881630d38c5b;p=csit.git diff --git a/resources/tools/dash/app/pal/report/layout.py b/resources/tools/dash/app/pal/report/layout.py index 26b9a9f4b5..e7c8db43ae 100644 --- a/resources/tools/dash/app/pal/report/layout.py +++ b/resources/tools/dash/app/pal/report/layout.py @@ -23,17 +23,13 @@ from dash import dcc from dash import html from dash import callback_context, no_update, ALL from dash import Input, Output, State -from dash.exceptions import PreventUpdate from yaml import load, FullLoader, YAMLError from copy import deepcopy -from json import loads, JSONDecodeError from ast import literal_eval -from pprint import pformat - from ..data.data import Data from ..data.url_processing import url_decode, url_encode -from .graphs import graph_iterative, table_comparison +from .graphs import graph_iterative, table_comparison, get_short_version class Layout: @@ -102,10 +98,10 @@ class Layout: self._data = pd.DataFrame() for rls in releases: data_mrr = Data(self._data_spec_file, True).\ - read_iterative_mrr(release=rls) + read_iterative_mrr(release=rls.replace("csit", "rls")) data_mrr["release"] = rls data_ndrpdr = Data(self._data_spec_file, True).\ - read_iterative_ndrpdr(release=rls) + read_iterative_ndrpdr(release=rls.replace("csit", "rls")) data_ndrpdr["release"] = rls self._data = pd.concat( [self._data, data_mrr, data_ndrpdr], ignore_index=True) @@ -116,9 +112,9 @@ class Layout: for _, row in self._data[cols].drop_duplicates().iterrows(): rls = row["release"] ttype = row["test_type"] - d_ver = row["dut_version"] lst_job = row["job"].split("-") dut = lst_job[1] + d_ver = get_short_version(row["dut_version"], dut) tbed = "-".join(lst_job[-2:]) lst_test_id = row["test_id"].split(".") if dut == "dpdk": @@ -131,10 +127,7 @@ class Layout: nic = suite.split("-")[0] for drv in self.DRIVERS: if drv in test: - if drv == "af-xdp": - driver = "af_xdp" - else: - driver = drv + driver = drv.replace("-", "_") test = test.replace(f"{drv}-", "") break else: @@ -157,20 +150,27 @@ class Layout: tbs[rls][dut][d_ver][infra][area] = dict() if tbs[rls][dut][d_ver][infra][area].get(test, None) is None: tbs[rls][dut][d_ver][infra][area][test] = dict() - tbs_test = tbs[rls][dut][d_ver][infra][area][test] - tbs_test["core"] = list() - tbs_test["frame-size"] = list() - tbs_test["test-type"] = list() - if core.upper() not in tbs_test["core"]: - tbs_test["core"].append(core.upper()) - if framesize.upper() not in tbs_test["frame-size"]: - tbs_test["frame-size"].append(framesize.upper()) + tbs[rls][dut][d_ver][infra][area][test]["core"] = list() + tbs[rls][dut][d_ver][infra][area][test]["frame-size"] = list() + tbs[rls][dut][d_ver][infra][area][test]["test-type"] = list() + if core.upper() not in \ + tbs[rls][dut][d_ver][infra][area][test]["core"]: + tbs[rls][dut][d_ver][infra][area][test]["core"].append( + core.upper()) + if framesize.upper() not in \ + tbs[rls][dut][d_ver][infra][area][test]["frame-size"]: + tbs[rls][dut][d_ver][infra][area][test]["frame-size"].append( + framesize.upper()) if ttype == "mrr": - if "MRR" not in tbs_test["test-type"]: - tbs_test["test-type"].append("MRR") + if "MRR" not in \ + tbs[rls][dut][d_ver][infra][area][test]["test-type"]: + tbs[rls][dut][d_ver][infra][area][test]["test-type"].append( + "MRR") elif ttype == "ndrpdr": - if "NDR" not in tbs_test["test-type"]: - tbs_test["test-type"].extend(("NDR", "PDR", )) + if "NDR" not in \ + tbs[rls][dut][d_ver][infra][area][test]["test-type"]: + tbs[rls][dut][d_ver][infra][area][test]["test-type"].extend( + ("NDR", "PDR", )) self._spec_tbs = tbs # Read from files: @@ -366,8 +366,8 @@ class Layout: width=6 ), dbc.Col( - dbc.Row( # TSA - id="row-graph-tsa", + dbc.Row( # Latency + id="row-graph-lat", class_name="g-0 p-2", children=[ self.PLACEHOLDER @@ -411,7 +411,7 @@ class Layout: [ dbc.InputGroupText( children=self._show_tooltip( - "help-release", "Release") + "help-release", "CSIT Release") ), dbc.Select( id="dd-ctrl-rls", @@ -628,6 +628,34 @@ class Layout: ) ] ), + dbc.Row( + id="row-ctrl-normalize", + class_name="gy-1", + children=[ + dbc.Label( + children=self._show_tooltip( + "help-normalize", "Normalize"), + class_name="p-0" + ), + dbc.Col( + children=[ + dbc.Checklist( + id="cl-ctrl-normalize", + options=[{ + "value": "normalize", + "label": ( + "Normalize results to CPU" + "frequency 2GHz" + ) + }], + value=[], + inline=True, + switch=False + ), + ] + ) + ] + ), dbc.Row( class_name="gy-1 p-0", children=[ @@ -658,7 +686,7 @@ class Layout: id="cl-selected", options=[], inline=False, - style={"max-height": "12em"}, + style={"max-height": "20em"}, ) ], ), @@ -731,6 +759,7 @@ class Layout: "cl-testtype-all-value": list(), "cl-testtype-all-options": CL_ALL_DISABLED, "btn-add-disabled": True, + "cl-normalize-value": list(), "cl-selected-options": list() } @@ -787,10 +816,10 @@ class Layout: """ """ - (fig_tput, fig_tsa) = figs + (fig_tput, fig_lat) = figs row_fig_tput = self.PLACEHOLDER - row_fig_tsa = self.PLACEHOLDER + row_fig_lat = self.PLACEHOLDER row_table = self.PLACEHOLDER row_btn_dwnld = self.PLACEHOLDER @@ -840,11 +869,11 @@ class Layout: ] ) ] - if fig_tsa: - row_fig_tsa = [ + if fig_lat: + row_fig_lat = [ dcc.Graph( id={"type": "graph", "index": "lat"}, - figure=fig_tsa + figure=fig_lat ) ] if not table.empty: @@ -858,13 +887,13 @@ class Layout: ) ] - return row_fig_tput, row_fig_tsa, row_table, row_btn_dwnld + return row_fig_tput, row_fig_lat, row_table, row_btn_dwnld @app.callback( Output("control-panel", "data"), # Store Output("selected-tests", "data"), # Store Output("row-graph-tput", "children"), - Output("row-graph-tsa", "children"), + Output("row-graph-lat", "children"), Output("row-table", "children"), Output("row-btn-download", "children"), Output("row-card-sel-tests", "style"), @@ -898,6 +927,7 @@ class Layout: Output("cl-ctrl-testtype-all", "value"), Output("cl-ctrl-testtype-all", "options"), Output("btn-ctrl-add", "disabled"), + Output("cl-ctrl-normalize", "value"), Output("cl-selected", "options"), # User selection State("control-panel", "data"), # Store State("selected-tests", "data"), # Store @@ -914,6 +944,7 @@ class Layout: Input("cl-ctrl-framesize-all", "value"), Input("cl-ctrl-testtype", "value"), Input("cl-ctrl-testtype-all", "value"), + Input("cl-ctrl-normalize", "value"), Input("btn-ctrl-add", "n_clicks"), Input("btn-sel-remove", "n_clicks"), Input("btn-sel-remove-all", "n_clicks"), @@ -923,8 +954,8 @@ class Layout: dd_rls: str, dd_dut: str, dd_dutver: str, dd_phy: str, dd_area: str, dd_test: str, cl_core: list, cl_core_all: list, cl_framesize: list, cl_framesize_all: list, cl_testtype: list, cl_testtype_all: list, - btn_add: int, btn_remove: int, btn_remove_all: int, - href: str) -> tuple: + cl_normalize: list, btn_add: int, btn_remove: int, + btn_remove_all: int, href: str) -> tuple: """ """ @@ -943,14 +974,13 @@ class Layout: new_url = str() return new_url - ctrl_panel = self.ControlPanel(cp_data) # Parse the url: parsed_url = url_decode(href) row_fig_tput = no_update - row_fig_tsa = no_update + row_fig_lat = no_update row_table = no_update row_btn_dwnld = no_update row_card_sel_tests = no_update @@ -999,7 +1029,7 @@ class Layout: "cl-testtype-all-value": list(), "cl-testtype-all-options": self.CL_ALL_DISABLED }) - if trigger_id == "dd-ctrl-dut": + elif trigger_id == "dd-ctrl-dut": try: rls = ctrl_panel.get("dd-rls-value") dut = self.spec_tbs[rls][dd_dut] @@ -1282,16 +1312,10 @@ class Layout: ctrl_panel.set({ "cl-selected-options": self._list_tests(store_sel) }) - row_fig_tput, row_fig_tsa, row_table, row_btn_dwnld = \ - _generate_plotting_area( - graph_iterative(self.data, store_sel, self.layout), - table_comparison(self.data, store_sel), - _gen_new_url(parsed_url, store_sel) - ) elif trigger_id == "btn-sel-remove-all": _ = btn_remove_all row_fig_tput = self.PLACEHOLDER - row_fig_tsa = self.PLACEHOLDER + row_fig_lat = self.PLACEHOLDER row_table = self.PLACEHOLDER row_btn_dwnld = self.PLACEHOLDER row_card_sel_tests = self.STYLE_DISABLED @@ -1306,11 +1330,28 @@ class Layout: if item["id"] not in list_sel: new_store_sel.append(item) store_sel = new_store_sel + elif trigger_id == "url": + # TODO: Add verification + url_params = parsed_url["params"] + if url_params: + store_sel = literal_eval( + url_params.get("store_sel", list())[0]) + if store_sel: + row_card_sel_tests = self.STYLE_ENABLED + row_btns_sel_tests = self.STYLE_ENABLED + + if trigger_id in ("btn-ctrl-add", "url", "btn-sel-remove", + "cl-ctrl-normalize"): if store_sel: - row_fig_tput, row_fig_tsa, row_table, row_btn_dwnld = \ + row_fig_tput, row_fig_lat, row_table, row_btn_dwnld = \ _generate_plotting_area( - graph_iterative(self.data, store_sel, self.layout), - table_comparison(self.data, store_sel), + graph_iterative( + self.data, store_sel, self.layout, + bool(cl_normalize) + ), + table_comparison( + self.data, store_sel, bool(cl_normalize) + ), _gen_new_url(parsed_url, store_sel) ) ctrl_panel.set({ @@ -1318,41 +1359,13 @@ class Layout: }) else: row_fig_tput = self.PLACEHOLDER - row_fig_tsa = self.PLACEHOLDER + row_fig_lat = self.PLACEHOLDER row_table = self.PLACEHOLDER row_btn_dwnld = self.PLACEHOLDER row_card_sel_tests = self.STYLE_DISABLED row_btns_sel_tests = self.STYLE_DISABLED store_sel = list() ctrl_panel.set({"cl-selected-options": list()}) - elif trigger_id == "url": - # TODO: Add verification - url_params = parsed_url["params"] - if url_params: - store_sel = literal_eval( - url_params.get("store_sel", list())[0]) - if store_sel: - row_fig_tput, row_fig_tsa, row_table, row_btn_dwnld = \ - _generate_plotting_area( - graph_iterative(self.data, store_sel, - self.layout), - table_comparison(self.data, store_sel), - _gen_new_url(parsed_url, store_sel) - ) - row_card_sel_tests = self.STYLE_ENABLED - row_btns_sel_tests = self.STYLE_ENABLED - ctrl_panel.set({ - "cl-selected-options": self._list_tests(store_sel) - }) - else: - row_fig_tput = self.PLACEHOLDER - row_fig_tsa = self.PLACEHOLDER - row_table = self.PLACEHOLDER - row_btn_dwnld = self.PLACEHOLDER - row_card_sel_tests = self.STYLE_DISABLED - row_btns_sel_tests = self.STYLE_DISABLED - store_sel = list() - ctrl_panel.set({"cl-selected-options": list()}) if ctrl_panel.get("cl-core-value") and \ ctrl_panel.get("cl-framesize-value") and \ @@ -1360,87 +1373,19 @@ class Layout: disabled = False else: disabled = True - ctrl_panel.set({"btn-add-disabled": disabled}) + ctrl_panel.set({ + "btn-add-disabled": disabled, + "cl-normalize-value": cl_normalize + }) ret_val = [ ctrl_panel.panel, store_sel, - row_fig_tput, row_fig_tsa, row_table, row_btn_dwnld, + row_fig_tput, row_fig_lat, row_table, row_btn_dwnld, row_card_sel_tests, row_btns_sel_tests ] ret_val.extend(ctrl_panel.values()) return ret_val - # @app.callback( - # Output("metadata-tput-lat", "children"), - # Output("metadata-hdrh-graph", "children"), - # Output("offcanvas-metadata", "is_open"), - # Input({"type": "graph", "index": ALL}, "clickData"), - # prevent_initial_call=True - # ) - # def _show_metadata_from_graphs(graph_data: dict) -> tuple: - # """ - # """ - # try: - # trigger_id = loads( - # callback_context.triggered[0]["prop_id"].split(".")[0] - # )["index"] - # idx = 0 if trigger_id == "tput" else 1 - # graph_data = graph_data[idx]["points"][0] - # except (JSONDecodeError, IndexError, KeyError, ValueError, - # TypeError): - # raise PreventUpdate - - # metadata = no_update - # graph = list() - - # children = [ - # dbc.ListGroupItem( - # [dbc.Badge(x.split(":")[0]), x.split(": ")[1]] - # ) for x in graph_data.get("text", "").split("
") - # ] - # if trigger_id == "tput": - # title = "Throughput" - # elif trigger_id == "lat": - # title = "Latency" - # hdrh_data = graph_data.get("customdata", None) - # if hdrh_data: - # graph = [dbc.Card( - # class_name="gy-2 p-0", - # children=[ - # dbc.CardHeader(hdrh_data.pop("name")), - # dbc.CardBody(children=[ - # dcc.Graph( - # id="hdrh-latency-graph", - # figure=graph_hdrh_latency( - # hdrh_data, self.layout - # ) - # ) - # ]) - # ]) - # ] - # metadata = [ - # dbc.Card( - # class_name="gy-2 p-0", - # children=[ - # dbc.CardHeader(children=[ - # dcc.Clipboard( - # target_id="tput-lat-metadata", - # title="Copy", - # style={"display": "inline-block"} - # ), - # title - # ]), - # dbc.CardBody( - # id="tput-lat-metadata", - # class_name="p-0", - # children=[dbc.ListGroup(children, flush=True), ] - # ) - # ] - # ) - # ] - - # return metadata, graph, True - # @app.callback( # Output("download-data", "data"), # State("selected-tests", "data"),