Code Review
/
csit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
C-Dash: Fix comparison tables
[csit.git]
/
csit.infra.dash
/
app
/
cdash
/
comparisons
/
layout.py
diff --git
a/csit.infra.dash/app/cdash/comparisons/layout.py
b/csit.infra.dash/app/cdash/comparisons/layout.py
index
bb4c6dd
..
a16277c
100644
(file)
--- a/
csit.infra.dash/app/cdash/comparisons/layout.py
+++ b/
csit.infra.dash/app/cdash/comparisons/layout.py
@@
-29,7
+29,7
@@
from ..utils.control_panel import ControlPanel
from ..utils.trigger import Trigger
from ..utils.url_processing import url_decode
from ..utils.utils import generate_options, gen_new_url
from ..utils.trigger import Trigger
from ..utils.url_processing import url_decode
from ..utils.utils import generate_options, gen_new_url
-from .tables import comparison_table
+from .tables import comparison_table
, filter_table_data
# Control panel partameters and their default values.
# Control panel partameters and their default values.
@@
-62,7
+62,7
@@
CMP_PARAMS = {
"infra": "Infrastructure",
"frmsize": "Frame Size",
"core": "Number of Cores",
"infra": "Infrastructure",
"frmsize": "Frame Size",
"core": "Number of Cores",
- "ttype": "
Test Type
"
+ "ttype": "
Measurement
"
}
}
@@
-142,7
+142,9
@@
class Layout:
tbs[dut][dver][infra]["ttype"].append("MRR")
elif row["test_type"] == "ndrpdr":
if "NDR" not in tbs[dut][dver][infra]["ttype"]:
tbs[dut][dver][infra]["ttype"].append("MRR")
elif row["test_type"] == "ndrpdr":
if "NDR" not in tbs[dut][dver][infra]["ttype"]:
- tbs[dut][dver][infra]["ttype"].extend(("NDR", "PDR", ))
+ tbs[dut][dver][infra]["ttype"].extend(
+ ("NDR", "PDR", "Latency")
+ )
elif row["test_type"] == "hoststack" and \
row["tg_type"] in ("iperf", "vpp"):
if "BPS" not in tbs[dut][dver][infra]["ttype"]:
elif row["test_type"] == "hoststack" and \
row["tg_type"] in ("iperf", "vpp"):
if "BPS" not in tbs[dut][dver][infra]["ttype"]:
@@
-202,6
+204,8
@@
class Layout:
children=[
dcc.Store(id="store-control-panel"),
dcc.Store(id="store-selected"),
children=[
dcc.Store(id="store-control-panel"),
dcc.Store(id="store-selected"),
+ dcc.Store(id="store-table-data"),
+ dcc.Store(id="store-filtered-table-data"),
dcc.Location(id="url", refresh=False),
self._add_ctrl_col(),
self._add_plotting_col()
dcc.Location(id="url", refresh=False),
self._add_ctrl_col(),
self._add_plotting_col()
@@
-383,7
+387,7
@@
class Layout:
children=[
dbc.InputGroup(
[
children=[
dbc.InputGroup(
[
- dbc.InputGroupText("
Test Type
"),
+ dbc.InputGroupText("
Measurement
"),
dbc.Checklist(
id={"type": "ctrl-cl", "index": "ttype"},
inline=True,
dbc.Checklist(
id={"type": "ctrl-cl", "index": "ttype"},
inline=True,
@@
-503,28
+507,26
@@
class Layout:
)
]
)
]
+ @staticmethod
def _get_plotting_area(
def _get_plotting_area(
- self,
- selected: dict,
- url: str,
- normalize: bool
+ title: str,
+ table: pd.DataFrame,
+ url: str
) -> list:
"""Generate the plotting area with all its content.
) -> list:
"""Generate the plotting area with all its content.
- :param
selected: Selected parameters of tests
.
- :param
normalize: If true, the values in tables are normaliz
ed.
+ :param
title: The title of the comparison table.
.
+ :param
table: Comparison table to be display
ed.
:param url: URL to be displayed in the modal window.
:param url: URL to be displayed in the modal window.
- :type
selected: dict
- :type
normalize: bool
+ :type
title: str
+ :type
table: pandas.DataFrame
:type url: str
:returns: List of rows with elements to be displayed in the plotting
area.
:rtype: list
"""
:type url: str
:returns: List of rows with elements to be displayed in the plotting
area.
:rtype: list
"""
- title, df = comparison_table(self._data, selected, normalize)
-
- if df.empty:
+ if table.empty:
return dbc.Row(
dbc.Col(
children=dbc.Alert(
return dbc.Row(
dbc.Col(
children=dbc.Alert(
@@
-537,7
+539,7
@@
class Layout:
)
cols = list()
)
cols = list()
- for idx, col in enumerate(
df
.columns):
+ for idx, col in enumerate(
table
.columns):
if idx == 0:
cols.append({
"name": ["", col],
if idx == 0:
cols.append({
"name": ["", col],
@@
-566,11
+568,13
@@
class Layout:
children=[
dbc.Col(
children=dash_table.DataTable(
children=[
dbc.Col(
children=dash_table.DataTable(
+ id={"type": "table", "index": "comparison"},
columns=cols,
columns=cols,
- data=
df
.to_dict("records"),
+ data=
table
.to_dict("records"),
merge_duplicate_headers=True,
merge_duplicate_headers=True,
- editable=True,
- filter_action="native",
+ editable=False,
+ filter_action="custom",
+ filter_query="",
sort_action="native",
sort_mode="multi",
selected_columns=[],
sort_action="native",
sort_mode="multi",
selected_columns=[],
@@
-646,7
+650,10
@@
class Layout:
[
Output("store-control-panel", "data"),
Output("store-selected", "data"),
[
Output("store-control-panel", "data"),
Output("store-selected", "data"),
+ Output("store-table-data", "data"),
+ Output("store-filtered-table-data", "data"),
Output("plotting-area", "children"),
Output("plotting-area", "children"),
+ Output({"type": "table", "index": ALL}, "data"),
Output({"type": "ctrl-dd", "index": "dut"}, "value"),
Output({"type": "ctrl-dd", "index": "dutver"}, "options"),
Output({"type": "ctrl-dd", "index": "dutver"}, "disabled"),
Output({"type": "ctrl-dd", "index": "dut"}, "value"),
Output({"type": "ctrl-dd", "index": "dutver"}, "options"),
Output({"type": "ctrl-dd", "index": "dutver"}, "disabled"),
@@
-670,11
+677,15
@@
class Layout:
],
[
State("store-control-panel", "data"),
],
[
State("store-control-panel", "data"),
- State("store-selected", "data")
+ State("store-selected", "data"),
+ State("store-table-data", "data"),
+ State("store-filtered-table-data", "data"),
+ State({"type": "table", "index": ALL}, "data")
],
[
Input("url", "href"),
Input("normalize", "value"),
],
[
Input("url", "href"),
Input("normalize", "value"),
+ Input({"type": "table", "index": ALL}, "filter_query"),
Input({"type": "ctrl-dd", "index": ALL}, "value"),
Input({"type": "ctrl-cl", "index": ALL}, "value"),
Input({"type": "ctrl-btn", "index": ALL}, "n_clicks")
Input({"type": "ctrl-dd", "index": ALL}, "value"),
Input({"type": "ctrl-cl", "index": ALL}, "value"),
Input({"type": "ctrl-btn", "index": ALL}, "n_clicks")
@@
-683,8
+694,12
@@
class Layout:
def _update_application(
control_panel: dict,
selected: dict,
def _update_application(
control_panel: dict,
selected: dict,
+ store_table_data: list,
+ filtered_data: list,
+ table_data: list,
href: str,
normalize: list,
href: str,
normalize: list,
+ table_filter: str,
*_
) -> tuple:
"""Update the application when the event is detected.
*_
) -> tuple:
"""Update the application when the event is detected.
@@
-724,7
+739,7
@@
class Layout:
(selected["reference"]["set"] == True) and
(c_sel["set"] == True)
)
(selected["reference"]["set"] == True) and
(c_sel["set"] == True)
)
- except (KeyError, IndexError):
+ except (KeyError, IndexError
, AttributeError
):
pass
if process_url:
ctrl_panel.set({
pass
if process_url:
ctrl_panel.set({
@@
-865,6
+880,8
@@
class Layout:
for itm in ctrl_panel.get(f"{value}-opt"):
set_val = ctrl_panel.get(f"{value}-val")
if isinstance(set_val, list):
for itm in ctrl_panel.get(f"{value}-opt"):
set_val = ctrl_panel.get(f"{value}-val")
if isinstance(set_val, list):
+ if itm["value"] == "Latency":
+ continue
if itm["value"] not in set_val:
opts.append(itm)
else:
if itm["value"] not in set_val:
opts.append(itm)
else:
@@
-900,8
+917,13
@@
class Layout:
if all((ctrl_panel.get("core-val"),
ctrl_panel.get("frmsize-val"),
ctrl_panel.get("ttype-val"), )):
if all((ctrl_panel.get("core-val"),
ctrl_panel.get("frmsize-val"),
ctrl_panel.get("ttype-val"), )):
+ if "Latency" in ctrl_panel.get("ttype-val"):
+ ctrl_panel.set({"ttype-val": ["Latency", ]})
opts = list()
for itm, label in CMP_PARAMS.items():
opts = list()
for itm, label in CMP_PARAMS.items():
+ if "Latency" in ctrl_panel.get("ttype-val") and \
+ itm == "ttype":
+ continue
if len(ctrl_panel.get(f"{itm}-opt")) > 1:
if isinstance(ctrl_panel.get(f"{itm}-val"), list):
if len(ctrl_panel.get(f"{itm}-opt")) == \
if len(ctrl_panel.get(f"{itm}-opt")) > 1:
if isinstance(ctrl_panel.get(f"{itm}-val"), list):
if len(ctrl_panel.get(f"{itm}-opt")) == \
@@
-925,19
+947,37
@@
class Layout:
"cmp-val-dis": True,
"cmp-val-val": str()
})
"cmp-val-dis": True,
"cmp-val-val": str()
})
+ elif trigger.type == "table" and trigger.idx == "comparison":
+ filtered_data = filter_table_data(
+ store_table_data,
+ table_filter[0]
+ )
+ table_data = [filtered_data, ]
if all((on_draw, selected["reference"]["set"],
selected["compare"]["set"], )):
if all((on_draw, selected["reference"]["set"],
selected["compare"]["set"], )):
+ title, table = comparison_table(self._data, selected, normalize)
plotting_area = self._get_plotting_area(
plotting_area = self._get_plotting_area(
-
selected=selected
,
-
normalize=bool(normalize)
,
+
title=title
,
+
table=table
,
url=gen_new_url(
parsed_url,
params={"selected": selected, "norm": normalize}
)
)
url=gen_new_url(
parsed_url,
params={"selected": selected, "norm": normalize}
)
)
+ store_table_data = table.to_dict("records")
+ filtered_data = store_table_data
+ if table_data:
+ table_data = [store_table_data, ]
- ret_val = [ctrl_panel.panel, selected, plotting_area]
+ ret_val = [
+ ctrl_panel.panel,
+ selected,
+ store_table_data,
+ filtered_data,
+ plotting_area,
+ table_data
+ ]
ret_val.extend(ctrl_panel.values)
return ret_val
ret_val.extend(ctrl_panel.values)
return ret_val
@@
-955,28
+995,33
@@
class Layout:
@app.callback(
Output("download-iterative-data", "data"),
@app.callback(
Output("download-iterative-data", "data"),
- State("store-
selected
", "data"),
- State("
normalize", "value
"),
+ State("store-
table-data
", "data"),
+ State("
store-filtered-table-data", "data
"),
Input("plot-btn-download", "n_clicks"),
prevent_initial_call=True
)
Input("plot-btn-download", "n_clicks"),
prevent_initial_call=True
)
- def _download_trending_data(selected: dict, normalize: list, _: int):
+ def _download_comparison_data(
+ table_data: list,
+ filtered_table_data: list,
+ _: int
+ ) -> dict:
"""Download the data.
"""Download the data.
- :param selected: List of tests selected by user stored in the
- browser.
- :param normalize: If set, the data is normalized to 2GHz CPU
- frequency.
- :type selected: list
- :type normalize: list
+ :param table_data: Original unfiltered table data.
+ :param filtered_table_data: Filtered table data.
+ :type table_data: list
+ :type filtered_table_data: list
:returns: dict of data frame content (base64 encoded) and meta data
used by the Download component.
:rtype: dict
"""
:returns: dict of data frame content (base64 encoded) and meta data
used by the Download component.
:rtype: dict
"""
- if not
selected
:
+ if not
table_data
:
raise PreventUpdate
raise PreventUpdate
-
- _, table = comparison_table(self._data, selected, normalize, "csv")
+
+ if filtered_table_data:
+ table = pd.DataFrame.from_records(filtered_table_data)
+ else:
+ table = pd.DataFrame.from_records(table_data)
return dcc.send_data_frame(table.to_csv, C.COMP_DOWNLOAD_FILE_NAME)
return dcc.send_data_frame(table.to_csv, C.COMP_DOWNLOAD_FILE_NAME)