1 # Copyright (c) 2022 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
18 import plotly.graph_objects as go
22 from datetime import datetime
24 from dash import no_update
27 def trending_tput(data: pd.DataFrame, sel:dict, layout: dict, start: datetime,
33 return no_update, no_update
35 def _generate_trace(ttype: str, name: str, df: pd.DataFrame,
36 start: datetime, end: datetime):
39 "mrr": "result_receive_rate_rate_avg",
40 "ndr": "result_ndr_lower_rate_value",
41 "pdr": "result_pdr_lower_rate_value"
44 "mrr": "result_receive_rate_rate_unit",
45 "ndr": "result_ndr_lower_rate_unit",
46 "pdr": "result_pdr_lower_rate_unit"
50 d for d in df["start_time"] if d >= start and d <= end
53 for _, row in df.iterrows():
56 f"{row['start_time'].strftime('%d-%m-%Y %H:%M:%S')}<br>"
57 f"average [{row[unit[ttype]]}]: "
58 f"{row[value[ttype]]}<br>"
59 f"{row['dut_type']}-ref: {row['dut_version']}<br>"
60 f"csit-ref: {row['job']}/{row['build']}"
64 f"stdev [{row['result_receive_rate_rate_unit']}]: "
65 f"{row['result_receive_rate_rate_stdev']}<br>"
69 hover_itm = hover_itm.replace("<stdev>", stdev)
70 hover_txt.append(hover_itm)
78 hoverinfo=u"text+name"
84 phy = itm["phy"].split("-")
86 topo, arch, nic, drv = phy
87 if drv in ("dpdk", "ixgbe"):
94 "weekly" if (arch == "aws" or itm["testtype"] != "mrr") else "daily"
97 f"{itm['testtype'] if itm['testtype'] == 'mrr' else 'ndrpdr'}-"
98 f"{cadence}-master-{topo}-{arch}"
100 df_sel = data.loc[(data["job"] == sel_topo_arch)]
102 f"^.*{nic}.*\.{itm['framesize']}-{itm['core']}-{drv}{itm['test']}-"
103 f"{'mrr' if itm['testtype'] == 'mrr' else 'ndrpdr'}$"
106 df_sel["test_id"].apply(
107 lambda x: True if re.search(regex, x) else False
109 ].sort_values(by="start_time", ignore_index=True)
111 f"{itm['phy']}-{itm['framesize']}-{itm['core']}-"
112 f"{itm['test']}-{itm['testtype']}"
114 fig.add_trace(_generate_trace(itm['testtype'], name, df, start, end))
117 "vertical-align": "top",
118 "display": "inline-block",
123 layout = layout.get("plot-trending", dict())
124 fig.update_layout(layout)