diff --git a/openpilot/selfdrive/test/process_replay/diff_report.py b/openpilot/selfdrive/test/process_replay/diff_report.py index 2b1fc2fd30..4137d45182 100644 --- a/openpilot/selfdrive/test/process_replay/diff_report.py +++ b/openpilot/selfdrive/test/process_replay/diff_report.py @@ -1,6 +1,6 @@ import os from collections import defaultdict -from opendbc.car.tests.car_diff import format_diff, format_numeric_diffs +from opendbc.car.tests.car_diff import format_diff, format_numeric_diffs, format_report from openpilot.selfdrive.test.process_replay.compare_logs import compare_logs from openpilot.selfdrive.test.process_replay.process_replay import PROC_REPLAY_DIR @@ -66,28 +66,18 @@ def diff_report(replay_diffs, segments, output_dir=PROC_REPLAY_DIR) -> None: else: with_diffs.append((plat, seg, proc, data)) - icon = "⚠️" if with_diffs else "✅" - lines = [ - "## Process replay diff report", - "Replays driving segments through this PR and compares the behavior to reviewed reference outputs.", - "Please review any changes carefully to ensure they are expected.\n", - f"{icon} {len(with_diffs)} changed, {n_passed} passed, {len(errors)} errors", - ] - - for plat, seg, proc, err in errors: - lines.append(f"\nERROR {plat} - {seg} [{proc}]: {err}") - - if with_diffs: - lines.append("
Show changes\n\n```") - for plat, seg, proc, (diffs, ref, new) in with_diffs: - lines.append(f"\n{plat} - {seg} [{proc}]") - by_field = defaultdict(list) - for d in diffs: - by_field[d[0]].append(d) - for field, fd in sorted(by_field.items()): - lines.append(f"\n {field} ({len(fd)} diffs)") - lines.extend(diff_format(fd, ref, new, field)) - lines.append("```\n
") + changes = [] + for plat, seg, proc, (diffs, ref, new) in with_diffs: + lines = [] + by_field = defaultdict(list) + for d in diffs: + by_field[d[0]].append(d) + for field, fd in sorted(by_field.items()): + lines.append(f"\n {field} ({len(fd)} diffs)") + lines.extend(diff_format(fd, ref, new, field)) + changes.append((f"{plat} - {seg} [{proc}]", lines)) + report = format_report("Process replay diff report", "Replays driving segments through this PR and compares the behavior to reviewed reference outputs.", + changes, n_passed, [f"{plat} - {seg} [{proc}]: {err}" for plat, seg, proc, err in errors], max_len=None) with open(os.path.join(output_dir, "diff_report.txt"), "w") as f: - f.write("\n".join(lines)) + f.write(report)