X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Fgenerator_tables.py;h=a07a989bcede0cea7f319a32c47628d58296dcaa;hp=367e8c98781d2c2ccaabd5683d3823552e942ae6;hb=2d9a3928380ba9c2b918d84cbc7540ca6af218aa;hpb=eecad36d7d2275fa47fbcab40dbcf56108ab0a51 diff --git a/resources/tools/presentation/generator_tables.py b/resources/tools/presentation/generator_tables.py index 367e8c9878..a07a989bce 100644 --- a/resources/tools/presentation/generator_tables.py +++ b/resources/tools/presentation/generator_tables.py @@ -67,7 +67,13 @@ def table_details(table, input_data): job = table["data"].keys()[0] build = str(table["data"][job][0]) - for suite_longname, suite in input_data.suites(job, build).iteritems(): + try: + suites = input_data.suites(job, build) + except KeyError: + logging.error(" No data available. The table will not be generated.") + return + + for suite_longname, suite in suites.iteritems(): # Generate data suite_name = suite["name"] table_lst = list() @@ -128,6 +134,8 @@ def table_performance_improvements(table, input_data): line_lst.append(item["data"]) elif isinstance(item["data"], float): line_lst.append("{:.1f}".format(item["data"])) + elif item["data"] is None: + line_lst.append("") file_handler.write(",".join(line_lst) + "\n") logging.info(" Generating the table {0} ...". @@ -175,20 +183,28 @@ def table_performance_improvements(table, input_data): for build in data[job]: try: data_lst.append(float(build[tmpl_item[0]]["throughput"] - ["value"]) / 1000000) + ["value"])) except (KeyError, TypeError): # No data, ignore - pass + continue if data_lst: - tbl_item.append({"data": eval(operation)(data_lst)}) + tbl_item.append({"data": (eval(operation)(data_lst)) / + 1000000}) + else: + tbl_item.append({"data": None}) elif cmd == "operation": operation = args[0] - nr1 = tbl_item[int(args[1])]["data"] - nr2 = tbl_item[int(args[2])]["data"] - if nr1 and nr2: - tbl_item.append({"data": eval(operation)(nr1, nr2)}) - else: + try: + nr1 = float(tbl_item[int(args[1])]["data"]) + nr2 = float(tbl_item[int(args[2])]["data"]) + if nr1 and nr2: + tbl_item.append({"data": eval(operation)(nr1, nr2)}) + else: + tbl_item.append({"data": None}) + except (IndexError, ValueError, TypeError): + logging.error("No data for {0}".format(tbl_item[1]["data"])) tbl_item.append({"data": None}) + continue else: logging.error("Not supported command {0}. Skipping the table.". format(cmd)) @@ -211,21 +227,25 @@ def table_performance_improvements(table, input_data): with open(file_name, "w") as file_handler: file_handler.write(",".join(header) + "\n") for item in tbl_lst: + if isinstance(item[-1]["data"], float): + rel_change = round(item[-1]["data"], 1) + else: + rel_change = item[-1]["data"] if "ndr_top" in file_name \ and "ndr" in item[1]["data"] \ - and item[-1]["data"] >= 10: + and rel_change >= 10.0: _write_line_to_file(file_handler, item) elif "pdr_top" in file_name \ and "pdr" in item[1]["data"] \ - and item[-1]["data"] >= 10: + and rel_change >= 10.0: _write_line_to_file(file_handler, item) elif "ndr_low" in file_name \ and "ndr" in item[1]["data"] \ - and item[-1]["data"] < 10: + and rel_change < 10.0: _write_line_to_file(file_handler, item) elif "pdr_low" in file_name \ and "pdr" in item[1]["data"] \ - and item[-1]["data"] < 10: + and rel_change < 10.0: _write_line_to_file(file_handler, item) logging.info(" Done.")