"""Generation of Continuous Performance Trending and Analysis.
"""
-import datetime
import logging
import csv
import prettytable
import pandas as pd
from collections import OrderedDict
+from datetime import datetime, timedelta
+
from utils import split_outliers, archive_input_data, execute_command
HTML_BUILDER = 'sphinx-build -v -c conf_cpta -a ' \
'-b html -E ' \
'-t html ' \
- '-D version="Generated on {date}" ' \
+ '-D version="{date}" ' \
'{working_dir} ' \
'{build_dir}/'
ret_code = _generate_all_charts(spec, data)
cmd = HTML_BUILDER.format(
- date=datetime.date.today().strftime('%d-%b-%Y'),
+ date=datetime.utcnow().strftime('%m/%d/%Y %H:%M UTC'),
working_dir=spec.environment["paths"]["DIR[WORKING,SRC]"],
build_dir=spec.environment["paths"]["DIR[BUILD,HTML]"])
execute_command(cmd)
:type show_trend_line: bool
:type name: str
:type color: str
- :returns: Generated traces (list) and the evaluated result (float).
+ :returns: Generated traces (list) and the evaluated result.
:rtype: tuple(traces, result)
"""
data_y = list(in_data.values())
hover_text = list()
+ xaxis = list()
for idx in data_x:
- hover_text.append("vpp-build: {0}".
- format(build_info[str(idx)][1].split("~")[-1]))
+ hover_text.append("vpp-ref: {0}<br>csit-ref: mrr-daily-build-{1}".
+ format(build_info[str(idx)][1].rsplit('~', 1)[0],
+ idx))
+ date = build_info[str(idx)][0]
+ xaxis.append(datetime(int(date[0:4]), int(date[4:6]), int(date[6:8]),
+ int(date[9:11]), int(date[12:])))
- data_pd = pd.Series(data_y, index=data_x)
+ data_pd = pd.Series(data_y, index=xaxis)
t_data, outliers = split_outliers(data_pd, outlier_const=1.5,
window=moving_win_size)
anomalies = pd.Series()
anomalies_res = list()
- for idx, item in enumerate(in_data.items()):
+ for idx, item in enumerate(data_pd.items()):
item_pd = pd.Series([item[1], ], index=[item[0], ])
if item[0] in outliers.keys():
anomalies = anomalies.append(item_pd)
[1.00, "green"]]
trace_samples = plgo.Scatter(
- x=data_x,
+ x=xaxis,
y=data_y,
mode='markers',
line={
"width": 1
},
+ legendgroup=name,
name="{name}-thput".format(name=name),
marker={
"size": 5,
"width": 1,
"color": color,
},
+ legendgroup=name,
name='{name}-trend'.format(name=name)
)
traces.append(trace_trend)
for build in builds_lst:
item = tst_data.get(int(build), '')
tst_lst.append(str(item))
- # tst_lst.append(str(item) if item else '')
csv_table.append("{0},".format(tst_name) + ",".join(tst_lst) + '\n')
for period in chart["periods"]:
# Generate traces:
traces = list()
- win_size = 14 if period == 1 else 5 if period < 20 else 3
+ win_size = 14
idx = 0
for test_name, test_data in chart_data.items():
if not test_data:
results.append(result)
idx += 1
- # Generate the chart:
- chart["layout"]["xaxis"]["title"] = \
- chart["layout"]["xaxis"]["title"].format(job=job_name)
- _generate_chart(traces,
- chart["layout"],
- file_name="{0}-{1}-{2}{3}".format(
- spec.cpta["output-file"],
- chart["output-file-name"],
- period,
- spec.cpta["output-file-type"]))
+ if traces:
+ # Generate the chart:
+ chart["layout"]["xaxis"]["title"] = \
+ chart["layout"]["xaxis"]["title"].format(job=job_name)
+ _generate_chart(traces,
+ chart["layout"],
+ file_name="{0}-{1}-{2}{3}".format(
+ spec.cpta["output-file"],
+ chart["output-file-name"],
+ period,
+ spec.cpta["output-file-type"]))
logging.info(" Done.")