X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Fpal_utils.py;h=f546aa4d101c380dbede21bba6c1feb56ebafa48;hb=6357d15b639bc472c11a74bd2d3ec6e889ff1578;hp=5949432340c2526a435843eb69a0468be767947d;hpb=cbfa26dc0f5334bcd367c161b4eaad342355bbde;p=csit.git
diff --git a/resources/tools/presentation/pal_utils.py b/resources/tools/presentation/pal_utils.py
index 5949432340..f546aa4d10 100644
--- a/resources/tools/presentation/pal_utils.py
+++ b/resources/tools/presentation/pal_utils.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -227,7 +227,7 @@ def archive_input_data(spec):
logging.info(u" Archiving the input data files ...")
- extension = spec.input[u"arch-file-format"]
+ extension = spec.output[u"arch-file-format"]
data_files = list()
for ext in extension:
data_files.extend(get_files(
@@ -262,7 +262,7 @@ def classify_anomalies(data):
:param data: Full data set with unavailable samples replaced by nan.
:type data: OrderedDict
:returns: Classification and trend values
- :rtype: 2-tuple, list of strings and list of floats
+ :rtype: 3-tuple, list of strings, list of floats and list of floats
"""
# Nan means something went wrong.
# Use 0.0 to cause that being reported as a severe regression.
@@ -273,13 +273,16 @@ def classify_anomalies(data):
group_list.reverse() # Just to use .pop() for FIFO.
classification = []
avgs = []
+ stdevs = []
active_group = None
values_left = 0
avg = 0.0
+ stdv = 0.0
for sample in data.values():
if np.isnan(sample):
classification.append(u"outlier")
avgs.append(sample)
+ stdevs.append(sample)
continue
if values_left < 1 or active_group is None:
values_left = 0
@@ -287,34 +290,63 @@ def classify_anomalies(data):
active_group = group_list.pop()
values_left = len(active_group.run_list)
avg = active_group.stats.avg
+ stdv = active_group.stats.stdev
classification.append(active_group.comment)
avgs.append(avg)
+ stdevs.append(stdv)
values_left -= 1
continue
classification.append(u"normal")
avgs.append(avg)
+ stdevs.append(stdv)
values_left -= 1
- return classification, avgs
+ return classification, avgs, stdevs
-def convert_csv_to_pretty_txt(csv_file_name, txt_file_name):
+def convert_csv_to_pretty_txt(csv_file_name, txt_file_name, delimiter=u","):
"""Convert the given csv table to pretty text table.
:param csv_file_name: The path to the input csv file.
:param txt_file_name: The path to the output pretty text file.
+ :param delimiter: Delimiter for csv file.
:type csv_file_name: str
:type txt_file_name: str
+ :type delimiter: str
"""
txt_table = None
- with open(csv_file_name, u"rt") as csv_file:
- csv_content = csv.reader(csv_file, delimiter=u',', quotechar=u'"')
+ with open(csv_file_name, u"rt", encoding='utf-8') as csv_file:
+ csv_content = csv.reader(csv_file, delimiter=delimiter, quotechar=u'"')
for row in csv_content:
if txt_table is None:
txt_table = prettytable.PrettyTable(row)
else:
- txt_table.add_row(row)
- txt_table.align[u"Test case"] = u"l"
- if txt_table:
- with open(txt_file_name, u"w") as txt_file:
+ txt_table.add_row(
+ [str(itm.replace(u"\u00B1", u"+-")) for itm in row]
+ )
+ if not txt_table:
+ return
+
+ txt_table.align = u"r"
+ for itm in (u"Test Case", u"Build", u"Version", u"VPP Version"):
+ txt_table.align[itm] = u"l"
+
+ if txt_file_name.endswith(u".txt"):
+ with open(txt_file_name, u"wt", encoding='utf-8') as txt_file:
txt_file.write(str(txt_table))
+ elif txt_file_name.endswith(u".rst"):
+ with open(txt_file_name, u"wt") as txt_file:
+ txt_file.write(
+ u"\n"
+ u".. |br| raw:: html\n\n
\n\n\n"
+ u".. |prein| raw:: html\n\n
\n\n\n" + u".. |preout| raw:: html\n\n\n\n" + ) + txt_file.write( + u"\n.. only:: html\n\n" + u" .. csv-table::\n" + u" :header-rows: 1\n" + u" :widths: auto\n" + u" :align: center\n" + f" :file: {csv_file_name.split(u'/')[-1]}\n" + )