X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fdash%2Fapp%2Fpal%2Fstats%2Fgraphs.py;h=f533d72aa839b4d397156626b63e5f415126a69c;hb=69fd124979890cac21bd0dbc7ef442563f175372;hp=2fabf8e6aef40722040d1a9fa79b795c68c9962a;hpb=c01befc28450d5c2003d25876dda0201eb827735;p=csit.git
diff --git a/resources/tools/dash/app/pal/stats/graphs.py b/resources/tools/dash/app/pal/stats/graphs.py
index 2fabf8e6ae..f533d72aa8 100644
--- a/resources/tools/dash/app/pal/stats/graphs.py
+++ b/resources/tools/dash/app/pal/stats/graphs.py
@@ -17,43 +17,58 @@
import plotly.graph_objects as go
import pandas as pd
-from datetime import datetime, timedelta
def select_data(data: pd.DataFrame, itm:str) -> pd.DataFrame:
- """
+ """Select the data for graphs from the provided data frame.
+
+ :param data: Data frame with data for graphs.
+ :param itm: Item (in this case job name) which data will be selected from
+ the input data frame.
+ :type data: pandas.DataFrame
+ :type itm: str
+ :returns: A data frame with selected data.
+ :rtype: pandas.DataFrame
"""
df = data.loc[(data["job"] == itm)].sort_values(
by="start_time", ignore_index=True)
+ df = df.dropna(subset=["duration", ])
return df
-def graph_statistics(df: pd.DataFrame, job:str, layout: dict,
- start: datetime=datetime.utcnow()-timedelta(days=180),
- end: datetime=datetime.utcnow()) -> tuple:
- """
+def graph_statistics(df: pd.DataFrame, job:str, layout: dict) -> tuple:
+ """Generate graphs:
+ 1. Passed / failed tests,
+ 2. Job durations
+ with additional information shown in hover.
+
+ :param df: Data frame with input data.
+ :param job: The name of job which data will be presented in the graphs.
+ :param layout: Layout of plot.ly graph.
+ :type df: pandas.DataFrame
+ :type job: str
+ :type layout: dict
+ :returns: Tuple with two generated graphs (pased/failed tests and job
+ duration).
+ :rtype: tuple(plotly.graph_objects.Figure, plotly.graph_objects.Figure)
"""
data = select_data(df, job)
- data = data.dropna(subset=["duration", ])
if data.empty:
return None, None
- x_axis = [d for d in data["start_time"] if d >= start and d <= end]
- if not x_axis:
- return None, None
-
hover = list()
for _, row in data.iterrows():
+ d_type = "trex" if row["dut_type"] == "none" else row["dut_type"]
hover_itm = (
- f"date: {row['start_time'].strftime('%d-%m-%Y %H:%M:%S')}
"
+ f"date: {row['start_time'].strftime('%Y-%m-%d %H:%M:%S')}
"
f"duration: "
f"{(int(row['duration']) // 3600):02d}:"
f"{((int(row['duration']) % 3600) // 60):02d}
"
f"passed: {row['passed']}
"
f"failed: {row['failed']}
"
- f"{row['dut_type']}-ref: {row['dut_version']}
"
+ f"{d_type}-ref: {row['dut_version']}
"
f"csit-ref: {row['job']}/{row['build']}
"
f"hosts: {', '.join(row['hosts'])}"
)
@@ -62,7 +77,7 @@ def graph_statistics(df: pd.DataFrame, job:str, layout: dict,
# Job durations:
fig_duration = go.Figure(
data=go.Scatter(
- x=x_axis,
+ x=data["start_time"],
y=data["duration"],
name=u"Duration",
text=hover,
@@ -87,14 +102,14 @@ def graph_statistics(df: pd.DataFrame, job:str, layout: dict,
fig_passed = go.Figure(
data=[
go.Bar(
- x=x_axis,
+ x=data["start_time"],
y=data["passed"],
name=u"Passed",
hovertext=hover,
hoverinfo=u"text"
),
go.Bar(
- x=x_axis,
+ x=data["start_time"],
y=data["failed"],
name=u"Failed",
hovertext=hover,