Loading ci/basop-pages/create_report_pages.py +42 −10 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ SUBPAGE_TMPL_CSS = """ .tbase .tunder{font-weight:bold;text-align:center;text-decoration:underline;vertical-align:top} .tbase .tcenter{font-weight:bold;text-align:center;vertical-align:top} .tbase .tleft{text-align:left;vertical-align:top} .tbase .tincrease{text-align:left;vertical-align:top;background-color:#ff0000;border-color:inherit;font-weight:bold;} .tbase .treduce{text-align:left;vertical-align:top;background-color:#00ff00;border-color:inherit;font-weight:bold;} </style> """ Loading @@ -27,6 +29,8 @@ Comparing: <li>Previous run - id: {id_previous}</li> </ul> <br> <b>Table is sorted by Difference in MLD.</b> <br> <table class="tbase"><thead> Loading @@ -46,14 +50,21 @@ Comparing: </tbody> </table> """ TD_TMPL = "<td class='tleft'>{}</td>" TD_TMPL_NORMAL = "<td class='tleft'>{}</td>" TD_TMPL_INCREASE = "<td class='tincrease'>{}</td>" TD_TMPL_REDUCE = "<td class='treduce'>{}</td>" TR_TMPL = "<tr>{}</tr>" COLUMNS = ["testcase", "MLD", "MAXIMUM ABS DIFF"] def create_subpage( html_out, csv_current: str, csv_previous: str, id_current: int, id_previous: int, job_name: str html_out, csv_current: str, csv_previous: str, id_current: int, id_previous: int, job_name: str, ): merged_reports = merge_and_cleanup_mld_reports( csv_current, csv_previous, id_current, id_previous Loading @@ -62,7 +73,10 @@ def create_subpage( tr_from_row(row, id_current, id_previous) for row in merged_reports ) new_subpage = SUBPAGE_TMPL_CSS + SUBPAGE_TMPL_HTML.format( id_current=id_current, id_previous=id_previous, table_body=table_body, job_name=job_name id_current=id_current, id_previous=id_previous, table_body=table_body, job_name=job_name, ) with open(html_out, "w") as f: f.write(new_subpage) Loading @@ -72,10 +86,22 @@ def tr_from_row(row, id_current, id_previous): tr = list() for c in COLUMNS: try: tr.append(TD_TMPL.format(row[c])) # this is for the "testcase" column - here we don't compare, just one value is used tr.append(TD_TMPL_NORMAL.format(row[c])) except KeyError: tr.append(TD_TMPL.format(row[f"{c}-{id_previous}"])) tr.append(TD_TMPL.format(row[f"{c}-{id_current}"])) # this is for all columns where we compare between current and previous run prev = row[f"{c}-{id_previous}"] curr = row[f"{c}-{id_current}"] # use red background if increase, green if decrease, white if same td_tmpl = TD_TMPL_NORMAL if float(curr) > float(prev): td_tmpl = TD_TMPL_INCREASE if float(curr) < float(prev): td_tmpl = TD_TMPL_REDUCE tr.append(td_tmpl.format(row[f"{c}-{id_previous}"])) tr.append(td_tmpl.format(row[f"{c}-{id_current}"])) return TR_TMPL.format("\n".join(tr)) Loading @@ -97,13 +123,19 @@ def merge_and_cleanup_mld_reports( ) # TODO: sort on result as well mld_col = f"MLD-{id_current}" mld_col_curr = f"MLD-{id_current}" mld_col_prev = f"MLD-{id_previous}" # sort based on difference in MLD between current and previous run # put cases with "None" at the top of the list def sort_func(x): return float("inf") if x[mld_col] == "None" else float(x[mld_col]) return ( float("inf") if x[mld_col_curr] == "None" or x[mld_col_prev] == "None" else float(x[mld_col_curr]) - float(x[mld_col_prev]) ) merged = sorted(merged, key=sort_func, reverse=True) print(merged) # remove the unecessary whole path from the testcase names for row in merged: Loading Loading @@ -148,5 +180,5 @@ if __name__ == "__main__": args.csv_previous, args.id_current, args.id_previous, args.job_name args.job_name, ) Loading
ci/basop-pages/create_report_pages.py +42 −10 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ SUBPAGE_TMPL_CSS = """ .tbase .tunder{font-weight:bold;text-align:center;text-decoration:underline;vertical-align:top} .tbase .tcenter{font-weight:bold;text-align:center;vertical-align:top} .tbase .tleft{text-align:left;vertical-align:top} .tbase .tincrease{text-align:left;vertical-align:top;background-color:#ff0000;border-color:inherit;font-weight:bold;} .tbase .treduce{text-align:left;vertical-align:top;background-color:#00ff00;border-color:inherit;font-weight:bold;} </style> """ Loading @@ -27,6 +29,8 @@ Comparing: <li>Previous run - id: {id_previous}</li> </ul> <br> <b>Table is sorted by Difference in MLD.</b> <br> <table class="tbase"><thead> Loading @@ -46,14 +50,21 @@ Comparing: </tbody> </table> """ TD_TMPL = "<td class='tleft'>{}</td>" TD_TMPL_NORMAL = "<td class='tleft'>{}</td>" TD_TMPL_INCREASE = "<td class='tincrease'>{}</td>" TD_TMPL_REDUCE = "<td class='treduce'>{}</td>" TR_TMPL = "<tr>{}</tr>" COLUMNS = ["testcase", "MLD", "MAXIMUM ABS DIFF"] def create_subpage( html_out, csv_current: str, csv_previous: str, id_current: int, id_previous: int, job_name: str html_out, csv_current: str, csv_previous: str, id_current: int, id_previous: int, job_name: str, ): merged_reports = merge_and_cleanup_mld_reports( csv_current, csv_previous, id_current, id_previous Loading @@ -62,7 +73,10 @@ def create_subpage( tr_from_row(row, id_current, id_previous) for row in merged_reports ) new_subpage = SUBPAGE_TMPL_CSS + SUBPAGE_TMPL_HTML.format( id_current=id_current, id_previous=id_previous, table_body=table_body, job_name=job_name id_current=id_current, id_previous=id_previous, table_body=table_body, job_name=job_name, ) with open(html_out, "w") as f: f.write(new_subpage) Loading @@ -72,10 +86,22 @@ def tr_from_row(row, id_current, id_previous): tr = list() for c in COLUMNS: try: tr.append(TD_TMPL.format(row[c])) # this is for the "testcase" column - here we don't compare, just one value is used tr.append(TD_TMPL_NORMAL.format(row[c])) except KeyError: tr.append(TD_TMPL.format(row[f"{c}-{id_previous}"])) tr.append(TD_TMPL.format(row[f"{c}-{id_current}"])) # this is for all columns where we compare between current and previous run prev = row[f"{c}-{id_previous}"] curr = row[f"{c}-{id_current}"] # use red background if increase, green if decrease, white if same td_tmpl = TD_TMPL_NORMAL if float(curr) > float(prev): td_tmpl = TD_TMPL_INCREASE if float(curr) < float(prev): td_tmpl = TD_TMPL_REDUCE tr.append(td_tmpl.format(row[f"{c}-{id_previous}"])) tr.append(td_tmpl.format(row[f"{c}-{id_current}"])) return TR_TMPL.format("\n".join(tr)) Loading @@ -97,13 +123,19 @@ def merge_and_cleanup_mld_reports( ) # TODO: sort on result as well mld_col = f"MLD-{id_current}" mld_col_curr = f"MLD-{id_current}" mld_col_prev = f"MLD-{id_previous}" # sort based on difference in MLD between current and previous run # put cases with "None" at the top of the list def sort_func(x): return float("inf") if x[mld_col] == "None" else float(x[mld_col]) return ( float("inf") if x[mld_col_curr] == "None" or x[mld_col_prev] == "None" else float(x[mld_col_curr]) - float(x[mld_col_prev]) ) merged = sorted(merged, key=sort_func, reverse=True) print(merged) # remove the unecessary whole path from the testcase names for row in merged: Loading Loading @@ -148,5 +180,5 @@ if __name__ == "__main__": args.csv_previous, args.id_current, args.id_previous, args.job_name args.job_name, )