X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=resources%2Ftools%2Fdash%2Fapp%2Fpal%2Fstats%2Flayout.py;h=a0920a4ec0c36120d7523f57032e37b468c8eca6;hb=aa9f6d2b4d417b439e2953a9c82c31b0d561f632;hp=cbb8cc77816d4ecc94aadc72b0fbc2a136a3fd3e;hpb=c3ce5119c09eb40607a4b82f242c10ff2c56284a;p=csit.git
diff --git a/resources/tools/dash/app/pal/stats/layout.py b/resources/tools/dash/app/pal/stats/layout.py
index cbb8cc7781..a0920a4ec0 100644
--- a/resources/tools/dash/app/pal/stats/layout.py
+++ b/resources/tools/dash/app/pal/stats/layout.py
@@ -28,8 +28,10 @@ from yaml import load, FullLoader, YAMLError
from datetime import datetime, timedelta
from copy import deepcopy
+from ..utils.constants import Constants as C
+from ..utils.utils import show_tooltip, gen_new_url
+from ..utils.url_processing import url_decode
from ..data.data import Data
-from ..data.url_processing import url_decode, url_encode
from .graphs import graph_statistics, select_data
@@ -37,15 +39,7 @@ class Layout:
"""
"""
- DEFAULT_JOB = "csit-vpp-perf-mrr-daily-master-2n-icx"
-
- URL_STYLE = {
- "background-color": "#d2ebf5",
- "border-color": "#bce1f1",
- "color": "#135d7c"
- }
-
- def __init__(self, app: Flask, html_layout_file: str, spec_file: str,
+ def __init__(self, app: Flask, html_layout_file: str,
graph_layout_file: str, data_spec_file: str, tooltip_file: str,
time_period: int=None) -> None:
"""
@@ -54,7 +48,6 @@ class Layout:
# Inputs
self._app = app
self._html_layout_file = html_layout_file
- self._spec_file = spec_file
self._graph_layout_file = graph_layout_file
self._data_spec_file = data_spec_file
self._tooltip_file = tooltip_file
@@ -96,7 +89,7 @@ class Layout:
job_info["tbed"].append("-".join(lst_job[-2:]))
self.df_job_info = pd.DataFrame.from_dict(job_info)
- self._default = self._set_job_params(self.DEFAULT_JOB)
+ self._default = self._set_job_params(C.STATS_DEFAULT_JOB)
tst_info = {
"job": list(),
@@ -105,10 +98,10 @@ class Layout:
"dut_version": list(),
"hosts": list(),
"passed": list(),
- "failed": list()
+ "failed": list(),
+ "lst_failed": list()
}
for job in jobs:
- # TODO: Add list of failed tests for each build
df_job = df_tst_info.loc[(df_tst_info["job"] == job)]
builds = df_job["build"].unique()
for build in builds:
@@ -119,15 +112,25 @@ class Layout:
tst_info["dut_version"].append(df_build["dut_version"].iloc[-1])
tst_info["hosts"].append(df_build["hosts"].iloc[-1])
try:
- passed = df_build.value_counts(subset='passed')[True]
+ passed = df_build.value_counts(subset="passed")[True]
except KeyError:
passed = 0
try:
- failed = df_build.value_counts(subset='passed')[False]
+ failed = df_build.value_counts(subset="passed")[False]
+ failed_tests = df_build.loc[(df_build["passed"] == False)]\
+ ["test_id"].to_list()
+ l_failed = list()
+ for tst in failed_tests:
+ lst_tst = tst.split(".")
+ suite = lst_tst[-2].replace("2n1l-", "").\
+ replace("1n1l-", "").replace("2n-", "")
+ l_failed.append(f"{suite.split('-')[0]}-{lst_tst[-1]}")
except KeyError:
failed = 0
+ l_failed = list()
tst_info["passed"].append(passed)
tst_info["failed"].append(failed)
+ tst_info["lst_failed"].append(sorted(l_failed))
self._data = data_stats.merge(pd.DataFrame.from_dict(tst_info))
@@ -259,29 +262,6 @@ class Layout:
lst_job[1], lst_job[3], lst_job[4]))
}
- def _show_tooltip(self, id: str, title: str,
- clipboard_id: str=None) -> list:
- """
- """
- return [
- dcc.Clipboard(target_id=clipboard_id, title="Copy URL") \
- if clipboard_id else str(),
- f"{title} ",
- dbc.Badge(
- id=id,
- children="?",
- pill=True,
- color="white",
- text_color="info",
- class_name="border ms-1",
- ),
- dbc.Tooltip(
- children=self._tooltips.get(id, str()),
- target=id,
- placement="auto"
- )
- ]
-
def add_content(self):
"""
"""
@@ -300,7 +280,7 @@ class Layout:
),
dcc.Loading(
dbc.Offcanvas(
- class_name="w-25",
+ class_name="w-50",
id="offcanvas-metadata",
title="Detailed Information",
placement="end",
@@ -406,7 +386,7 @@ class Layout:
dcc.Loading(children=[
dbc.Button(
id="btn-download-data",
- children=self._show_tooltip(
+ children=show_tooltip(self._tooltips,
"help-download", "Download Data"),
class_name="me-1",
color="info"
@@ -422,15 +402,18 @@ class Layout:
class_name="me-1",
children=[
dbc.InputGroupText(
- style=self.URL_STYLE,
- children=self._show_tooltip(
- "help-url", "URL", "input-url")
+ style=C.URL_STYLE,
+ children=show_tooltip(
+ self._tooltips,
+ "help-url", "URL",
+ "input-url"
+ )
),
dbc.Input(
id="input-url",
readonly=True,
type="url",
- style=self.URL_STYLE,
+ style=C.URL_STYLE,
value=""
)
]
@@ -458,7 +441,7 @@ class Layout:
children=[
dbc.Label(
class_name="p-0",
- children=self._show_tooltip(
+ children=show_tooltip(self._tooltips,
"help-dut", "Device under Test")
),
dbc.Row(
@@ -476,7 +459,7 @@ class Layout:
children=[
dbc.Label(
class_name="p-0",
- children=self._show_tooltip(
+ children=show_tooltip(self._tooltips,
"help-ttype", "Test Type"),
),
dbc.RadioItems(
@@ -492,7 +475,7 @@ class Layout:
children=[
dbc.Label(
class_name="p-0",
- children=self._show_tooltip(
+ children=show_tooltip(self._tooltips,
"help-cadence", "Cadence"),
),
dbc.RadioItems(
@@ -508,7 +491,7 @@ class Layout:
children=[
dbc.Label(
class_name="p-0",
- children=self._show_tooltip(
+ children=show_tooltip(self._tooltips,
"help-tbed", "Test Bed"),
),
dbc.Select(
@@ -534,7 +517,7 @@ class Layout:
children=[
dbc.Label(
class_name="gy-1",
- children=self._show_tooltip(
+ children=show_tooltip(self._tooltips,
"help-time-period", "Time Period"),
),
dcc.DatePickerRange(
@@ -727,25 +710,18 @@ class Layout:
fig_passed, fig_duration = graph_statistics(self.data, job,
self.layout, start, end)
- if parsed_url:
- new_url = url_encode({
- "scheme": parsed_url["scheme"],
- "netloc": parsed_url["netloc"],
- "path": parsed_url["path"],
- "params": {
- "job": job,
- "start": start,
- "end": end
- }
- })
- else:
- new_url = str()
-
ret_val = [
ctrl_panel.panel,
fig_passed,
fig_duration,
- new_url
+ gen_new_url(
+ parsed_url,
+ {
+ "job": job,
+ "start": start,
+ "end": end
+ }
+ )
]
ret_val.extend(ctrl_panel.values())
return ret_val
@@ -804,6 +780,26 @@ class Layout:
elif trigger_id == "graph-duration":
graph_data = duration_data["points"][0].get("text", "")
if graph_data:
+ lst_graph_data = graph_data.split("
")
+
+ # Prepare list of failed tests:
+ job = str()
+ build = str()
+ for itm in lst_graph_data:
+ if "csit-ref:" in itm:
+ job, build = itm.split(" ")[-1].split("/")
+ break
+ if job and build:
+ fail_tests = self.data.loc[
+ (self.data["job"] == job) &
+ (self.data["build"] == build)
+ ]["lst_failed"].values[0]
+ if not fail_tests:
+ fail_tests = None
+ else:
+ fail_tests = None
+
+ # Create the content of the offcanvas:
metadata = [
dbc.Card(
class_name="gy-2 p-0",
@@ -828,7 +824,7 @@ class Layout:
),
x.split(": ")[1]
]
- ) for x in graph_data.split("
")
+ ) for x in lst_graph_data
],
flush=True),
]
@@ -836,6 +832,30 @@ class Layout:
]
)
]
+
+ if fail_tests is not None:
+ metadata.append(
+ dbc.Card(
+ class_name="gy-2 p-0",
+ children=[
+ dbc.CardHeader(
+ f"List of Failed Tests ({len(fail_tests)})"
+ ),
+ dbc.CardBody(
+ id="failed-tests",
+ class_name="p-0",
+ children=[dbc.ListGroup(
+ children=[
+ dbc.ListGroupItem(x) \
+ for x in fail_tests
+ ],
+ flush=True),
+ ]
+ )
+ ]
+ )
+ )
+
open_canvas = True
return metadata, open_canvas