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
"""
"""
- DEFAULT_JOB = "csit-vpp-perf-mrr-daily-master-2n-icx"
-
- 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:
"""
# 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
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(),
"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:
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))
lst_job[1], lst_job[3], lst_job[4]))
}
- def _show_tooltip(self, id: str, title: str) -> list:
- """
- """
- return [
- 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):
"""
"""
),
dcc.Loading(
dbc.Offcanvas(
- class_name="w-25",
+ class_name="w-50",
id="offcanvas-metadata",
title="Detailed Information",
placement="end",
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"
),
dcc.Download(id="download-data")
- ]),
+ ])
]
),
dbc.Col( # Show URL
width=10,
children=[
- dbc.Card(
- id="card-url",
- body=True,
- class_name="gy-2 p-0",
- children=[]
- ),
+ dbc.InputGroup(
+ class_name="me-1",
+ children=[
+ dbc.InputGroupText(
+ style=C.URL_STYLE,
+ children=show_tooltip(
+ self._tooltips,
+ "help-url", "URL",
+ "input-url"
+ )
+ ),
+ dbc.Input(
+ id="input-url",
+ readonly=True,
+ type="url",
+ style=C.URL_STYLE,
+ value=""
+ )
+ ]
+ )
]
)
]
children=[
dbc.Label(
class_name="p-0",
- children=self._show_tooltip(
+ children=show_tooltip(self._tooltips,
"help-dut", "Device under Test")
),
dbc.Row(
children=[
dbc.Label(
class_name="p-0",
- children=self._show_tooltip(
+ children=show_tooltip(self._tooltips,
"help-ttype", "Test Type"),
),
dbc.RadioItems(
children=[
dbc.Label(
class_name="p-0",
- children=self._show_tooltip(
+ children=show_tooltip(self._tooltips,
"help-cadence", "Cadence"),
),
dbc.RadioItems(
children=[
dbc.Label(
class_name="p-0",
- children=self._show_tooltip(
+ children=show_tooltip(self._tooltips,
"help-tbed", "Test Bed"),
),
dbc.Select(
children=[
dbc.Label(
class_name="gy-1",
- children=self._show_tooltip(
+ children=show_tooltip(self._tooltips,
"help-time-period", "Time Period"),
),
dcc.DatePickerRange(
Output("control-panel", "data"), # Store
Output("graph-passed", "figure"),
Output("graph-duration", "figure"),
- Output("card-url", "children"),
+ Output("input-url", "value"),
Output("ri-ttypes", "options"),
Output("ri-cadences", "options"),
Output("dd-tbeds", "options"),
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,
- [ # URL
- dcc.Clipboard(
- target_id="card-url",
- title="Copy URL",
- style={"display": "inline-block"}
- ),
- new_url
- ]
+ gen_new_url(
+ parsed_url,
+ {
+ "job": job,
+ "start": start,
+ "end": end
+ }
+ )
]
ret_val.extend(ctrl_panel.values())
return ret_val
elif trigger_id == "graph-duration":
graph_data = duration_data["points"][0].get("text", "")
if graph_data:
+ lst_graph_data = graph_data.split("<br>")
+
+ # 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",
),
x.split(": ")[1]
]
- ) for x in graph_data.split("<br>")
+ ) for x in lst_graph_data
],
flush=True),
]
]
)
]
+
+ 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