X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Fgenerator_CPTA.py;h=12ebd46922addb2272a4f840e41606fd012192ea;hb=refs%2Fchanges%2F93%2F12593%2F3;hp=89e9a41b48cf5f7e4902e86dbc3a7025e5449083;hpb=5646509aea6b43ef1efb282aad908289cc005b26;p=csit.git diff --git a/resources/tools/presentation/generator_CPTA.py b/resources/tools/presentation/generator_CPTA.py index 89e9a41b48..12ebd46922 100644 --- a/resources/tools/presentation/generator_CPTA.py +++ b/resources/tools/presentation/generator_CPTA.py @@ -14,7 +14,6 @@ """Generation of Continuous Performance Trending and Analysis. """ -import datetime import logging import csv import prettytable @@ -25,6 +24,8 @@ import numpy as np import pandas as pd from collections import OrderedDict +from datetime import datetime, timedelta + from utils import split_outliers, archive_input_data, execute_command @@ -64,7 +65,7 @@ def generate_cpta(spec, data): ret_code = _generate_all_charts(spec, data) cmd = HTML_BUILDER.format( - date=datetime.datetime.utcnow().strftime('%m/%d/%Y %H:%M UTC'), + 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) @@ -226,7 +227,7 @@ def _generate_trending_traces(in_data, build_info, period, moving_win_size=10, :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) """ @@ -239,11 +240,16 @@ def _generate_trending_traces(in_data, build_info, period, moving_win_size=10, 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}
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) @@ -251,7 +257,7 @@ def _generate_trending_traces(in_data, build_info, period, moving_win_size=10, 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) @@ -272,12 +278,13 @@ def _generate_trending_traces(in_data, build_info, period, moving_win_size=10, [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, @@ -338,6 +345,7 @@ def _generate_trending_traces(in_data, build_info, period, moving_win_size=10, "width": 1, "color": color, }, + legendgroup=name, name='{name}-trend'.format(name=name) ) traces.append(trace_trend) @@ -436,13 +444,12 @@ def _generate_all_charts(spec, input_data): 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: @@ -463,16 +470,17 @@ def _generate_all_charts(spec, input_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.")