Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Generate html report of results

laurenspriem41c32874ad2e
diff --git a/infra/ml/test/README.md b/infra/ml/test/README.md
index 916fbdd736..c10bdc03ea 100644
--- a/infra/ml/test/README.md
+++ b/infra/ml/test/README.md
@@ -32,7 +32,12 @@ Common flags:
- `--allow-empty-comparison`
- `--output-dir <path>`
-Outputs go to `infra/ml/test/out/parity/` by default, including `comparison_report.json`.
+Outputs go to `infra/ml/test/out/parity/` by default, including:
+
+- `comparison_report.json` (machine-readable comparison output)
+- `parity_report.html` (readable HTML report with per-file metrics for both pass and fail files)
+
+`run_suite.sh` compares each available platform against Python ground truth (`python -> <platform>`); non-ground-truth pairwise comparisons are excluded by default.
## Manual CI Run
@@ -60,6 +65,6 @@ Use this process when corpus/threshold/model behavior changes intentionally:
bash infra/ml/test/tools/run_suite.sh --suite full --platforms all --output-dir infra/ml/test/out/parity
```
-3. Review `infra/ml/test/out/parity/comparison_report.json` and per-platform `results.json` files.
+3. Review `infra/ml/test/out/parity/parity_report.html`, `comparison_report.json`, and per-platform `results.json` files.
4. If drift is expected, adjust thresholds/known exceptions and rerun until stable.
5. Commit code/config/docs updates only; do not commit generated `out/`, `test_data/`, or cache artifacts.
diff --git a/infra/ml/test/comparator/__init__.py b/infra/ml/test/comparator/__init__.py
index e4f48041dd..1abe172388 100644
--- a/infra/ml/test/comparator/__init__.py
+++ b/infra/ml/test/comparator/__init__.py
@@ -2,6 +2,7 @@ from .compare import (
AggregateMetric,
ComparisonFinding,
ComparisonReport,
+ FileMetricMeasurement,
ThresholdConfig,
compare_platform_matrix,
compare_result_sets,
@@ -11,6 +12,7 @@ __all__ = [
"AggregateMetric",
"ComparisonFinding",
"ComparisonReport",
+ "FileMetricMeasurement",
"ThresholdConfig",
"compare_platform_matrix",
"compare_result_sets",
diff --git a/infra/ml/test/comparator/compare.py b/infra/ml/test/comparator/compare.py
index d62c3f10bb..c6064e5067 100644
--- a/infra/ml/test/comparator/compare.py
+++ b/infra/ml/test/comparator/compare.py
@@ -147,16 +147,43 @@ class ComparisonFinding:
return payload
+@dataclass(frozen=True)
+class FileMetricMeasurement:
+ metric: str
+ value: float | None
+ threshold: float | None
+ passed: bool
+ direction: str | None = None
+ count: int | None = None
+ applicable: bool = True
+ message: str | None = None
+
+ def to_dict(self) -> dict[str, Any]:
+ payload: dict[str, Any] = {
+ "metric": self.metric,
+ "value": self.value,
+ "threshold": self.threshold,
+ "passed": self.passed,
+ "direction": self.direction,
+ "count": self.count,
+ "applicable": self.applicable,
+ "message": self.message,
+ }
+ return payload
+
+
@dataclass(frozen=True)
class FileComparisonStatus:
file_id: str
passed: bool
+ metrics: tuple[FileMetricMeasurement, ...]
failures: tuple[ComparisonFinding, ...]
def to_dict(self) -> dict[str, Any]:
return {
"file_id": self.file_id,
"passed": self.passed,
+ "metrics": [metric.to_dict() for metric in self.metrics],
"failure_count": len(self.failures),
"failures": [failure.to_dict() for failure in self.failures],
}
@@ -299,12 +326,42 @@ def compare_result_sets(
file_failures: dict[str, list[ComparisonFinding]] = {
file_id: [] for file_id in reference_results
}
+ file_metrics: dict[str, list[FileMetricMeasurement]] = {
+ file_id: [] for file_id in reference_results
+ }
def add_finding(finding: ComparisonFinding) -> None:
findings.append(finding)
if finding.file_id in file_failures:
file_failures[finding.file_id].append(finding)
+ def add_file_metric(
+ *,
+ file_id: str,
+ metric: str,
+ value: float | None,
+ threshold: float | None,
+ passed: bool,
+ direction: str | None = None,
+ count: int | None = None,
+ applicable: bool = True,
+ message: str | None = None,
+ ) -> None:
+ if file_id not in file_metrics:
+ return
+ file_metrics[file_id].append(
+ FileMetricMeasurement(
+ metric=metric,
+ value=value,
+ threshold=threshold,
+ passed=passed,
+ direction=direction,
+ count=count,
+ applicable=applicable,
+ message=message,
+ )
+ )
+
for missing_file in missing_files:
add_finding(
ComparisonFinding(
@@ -313,6 +370,15 @@ def compare_result_sets(
message=f"Missing from {candidate_platform}",
),
)
+ add_file_metric(
+ file_id=missing_file,
+ metric="file_presence",
+ value=0.0,
+ threshold=1.0,
+ passed=False,
+ direction="==",
+ message=f"Missing from {candidate_platform}",
+ )
for extra_file in extra_files:
add_finding(
ComparisonFinding(
@@ -335,6 +401,15 @@ def compare_result_sets(
clip_distance = cosine_distance(reference.clip.embedding, candidate.clip.embedding)
clip_distances.append(clip_distance)
+ add_file_metric(
+ file_id=file_id,
+ metric="clip_cosine_distance",
+ value=clip_distance,
+ threshold=clip_threshold,
+ passed=clip_distance <= clip_threshold,
+ direction="<=",
+ message="CLIP cosine distance",
+ )
if clip_distance > clip_threshold:
add_finding(
ComparisonFinding(
@@ -346,6 +421,35 @@ def compare_result_sets(
),
)
+ reference_face_count = len(reference.faces)
+ candidate_face_count = len(candidate.faces)
+ add_file_metric(
+ file_id=file_id,
+ metric="reference_face_count",
+ value=float(reference_face_count),
+ threshold=None,
+ passed=True,
+ message=f"{reference_platform} face count",
+ )
+ add_file_metric(
+ file_id=file_id,
+ metric="candidate_face_count",
+ value=float(candidate_face_count),
+ threshold=None,
+ passed=True,
+ message=f"{candidate_platform} face count",
+ )
+ face_count_delta = abs(reference_face_count - candidate_face_count)
+ add_file_metric(
+ file_id=file_id,
+ metric="face_count_delta",
+ value=float(face_count_delta),
+ threshold=0.0,
+ passed=face_count_delta == 0,
+ direction="<=",
+ message="Absolute face count difference",
+ )
+
if len(reference.faces) != len(candidate.faces):
add_finding(
ComparisonFinding(
@@ -357,10 +461,25 @@ def compare_result_sets(
)
matches = _match_faces(reference.faces, candidate.faces)
+ add_file_metric(
+ file_id=file_id,
+ metric="matched_face_count",
+ value=float(len(matches)),
+ threshold=None,
+ passed=True,
+ count=len(matches),
+ message="Greedy IoU face matches",
+ )
+
+ file_ious: list[float] = []
+ file_landmark_errors: list[float] = []
+ file_score_deltas: list[float] = []
+ file_embedding_distances: list[float] = []
for reference_index, candidate_index, iou in matches:
reference_face = reference.faces[reference_index]
candidate_face = candidate.faces[candidate_index]
+ file_ious.append(iou)
iou_error = 1.0 - iou
iou_errors.append(iou_error)
if iou < thresholds.box_iou_threshold:
@@ -388,6 +507,7 @@ def compare_result_sets(
),
)
else:
+ file_landmark_errors.append(landmark_error)
landmark_errors.append(landmark_error)
if landmark_error > thresholds.landmark_error_threshold:
add_finding(
@@ -401,6 +521,7 @@ def compare_result_sets(
)
score_delta = abs(reference_face.score - candidate_face.score)
+ file_score_deltas.append(score_delta)
score_deltas.append(score_delta)
if score_delta > thresholds.score_delta_threshold:
add_finding(
@@ -417,6 +538,7 @@ def compare_result_sets(
reference_face.embedding,
candidate_face.embedding,
)
+ file_embedding_distances.append(embedding_distance)
face_embedding_distances.append(embedding_distance)
if embedding_distance > thresholds.face_embedding_cosine_distance:
add_finding(
@@ -426,8 +548,108 @@ def compare_result_sets(
message="Face embedding cosine distance exceeded threshold",
value=embedding_distance,
threshold=thresholds.face_embedding_cosine_distance,
- ),
- )
+ ),
+ )
+
+ if file_ious:
+ min_iou = min(file_ious)
+ add_file_metric(
+ file_id=file_id,
+ metric="face_box_iou_min",
+ value=min_iou,
+ threshold=thresholds.box_iou_threshold,
+ passed=min_iou >= thresholds.box_iou_threshold,
+ direction=">=",
+ count=len(file_ious),
+ message="Minimum IoU across matched faces",
+ )
+ else:
+ add_file_metric(
+ file_id=file_id,
+ metric="face_box_iou_min",
+ value=None,
+ threshold=thresholds.box_iou_threshold,
+ passed=reference_face_count == 0 and candidate_face_count == 0,
+ direction=">=",
+ count=0,
+ applicable=False,
+ message="No matched faces",
+ )
+
+ if file_landmark_errors:
+ max_landmark_error = max(file_landmark_errors)
+ add_file_metric(
+ file_id=file_id,
+ metric="landmark_error_max",
+ value=max_landmark_error,
+ threshold=thresholds.landmark_error_threshold,
+ passed=max_landmark_error <= thresholds.landmark_error_threshold,
+ direction="<=",
+ count=len(file_landmark_errors),
+ message="Maximum landmark error across matched faces",
+ )
+ else:
+ add_file_metric(
+ file_id=file_id,
+ metric="landmark_error_max",
+ value=None,
+ threshold=thresholds.landmark_error_threshold,
+ passed=reference_face_count == 0 and candidate_face_count == 0,
+ direction="<=",
+ count=0,
+ applicable=False,
+ message="No matched faces",
+ )
+
+ if file_score_deltas:
+ max_score_delta = max(file_score_deltas)
+ add_file_metric(
+ file_id=file_id,
+ metric="score_delta_max",
+ value=max_score_delta,
+ threshold=thresholds.score_delta_threshold,
+ passed=max_score_delta <= thresholds.score_delta_threshold,
+ direction="<=",
+ count=len(file_score_deltas),
+ message="Maximum face score delta across matched faces",
+ )
+ else:
+ add_file_metric(
+ file_id=file_id,
+ metric="score_delta_max",
+ value=None,
+ threshold=thresholds.score_delta_threshold,
+ passed=reference_face_count == 0 and candidate_face_count == 0,
+ direction="<=",
+ count=0,
+ applicable=False,
+ message="No matched faces",
+ )
+
+ if file_embedding_distances:
+ max_embedding_distance = max(file_embedding_distances)
+ add_file_metric(
+ file_id=file_id,
+ metric="face_embedding_cosine_distance_max",
+ value=max_embedding_distance,
+ threshold=thresholds.face_embedding_cosine_distance,
+ passed=max_embedding_distance <= thresholds.face_embedding_cosine_distance,
+ direction="<=",
+ count=len(file_embedding_distances),
+ message="Maximum face embedding cosine distance across matched faces",
+ )
+ else:
+ add_file_metric(
+ file_id=file_id,
+ metric="face_embedding_cosine_distance_max",
+ value=None,
+ threshold=thresholds.face_embedding_cosine_distance,
+ passed=reference_face_count == 0 and candidate_face_count == 0,
+ direction="<=",
+ count=0,
+ applicable=False,
+ message="No matched faces",
+ )
aggregates = {
"clip_cosine_distance": _make_aggregate(clip_distances, clip_threshold),
@@ -465,6 +687,7 @@ def compare_result_sets(
FileComparisonStatus(
file_id=file_id,
passed=not file_failures[file_id],
+ metrics=tuple(file_metrics[file_id]),
failures=tuple(file_failures[file_id]),
)
for file_id in sorted_reference_files
diff --git a/infra/ml/test/tests/test_comparator.py b/infra/ml/test/tests/test_comparator.py
index 96524842fc..6e05b9b81c 100644
--- a/infra/ml/test/tests/test_comparator.py
+++ b/infra/ml/test/tests/test_comparator.py
@@ -112,6 +112,15 @@ def test_compare_result_sets_passes_when_within_thresholds() -> None:
assert report.passing_files == ("man.jpeg",)
assert report.failing_files == ()
assert report.file_statuses[0].passed is True
+ metric_names = {metric.metric for metric in report.file_statuses[0].metrics}
+ assert "clip_cosine_distance" in metric_names
+ assert "face_count_delta" in metric_names
+ clip_metric = next(
+ metric
+ for metric in report.file_statuses[0].metrics
+ if metric.metric == "clip_cosine_distance"
+ )
+ assert clip_metric.passed is True
def test_compare_result_sets_fails_on_clip_drift() -> None:
@@ -172,6 +181,12 @@ def test_compare_result_sets_fails_on_face_count_mismatch() -> None:
assert any(
failure.metric == "face_count" for failure in report.file_statuses[0].failures
)
+ face_count_metric = next(
+ metric
+ for metric in report.file_statuses[0].metrics
+ if metric.metric == "face_count_delta"
+ )
+ assert face_count_metric.passed is False
def test_aggregate_gate_failure_is_reported() -> None:
diff --git a/infra/ml/test/tools/render_parity_html_report.py b/infra/ml/test/tools/render_parity_html_report.py
new file mode 100755
index 0000000000..591a31363c
--- /dev/null
+++ b/infra/ml/test/tools/render_parity_html_report.py
@@ -0,0 +1,320 @@
+#!/usr/bin/env python3
+from __future__ import annotations
+
+import argparse
+import html
+import json
+from pathlib import Path
+from typing import Any
+
+
+def _format_value(value: object) -> str:
+ if isinstance(value, float):
+ return f"{value:.6f}"
+ if isinstance(value, int):
+ return str(value)
+ if value is None:
+ return "-"
+ return str(value)
+
+
+def _status_class(passed: bool) -> str:
+ return "pass" if passed else "fail"
+
+
+def _status_label(passed: bool) -> str:
+ return "PASS" if passed else "FAIL"
+
+
+def _platform_stats(report_dir: Path) -> dict[str, dict[str, Any]]:
+ stats: dict[str, dict[str, Any]] = {}
+ for platform in ("python", "desktop", "android", "ios"):
+ path = report_dir / platform / "results.json"
+ if not path.exists():
+ stats[platform] = {
+ "path": str(path),
+ "available": False,
+ "result_count": None,
+ "error_count": None,
+ }
+ continue
+
+ payload = json.loads(path.read_text())
+ results = payload.get("results", [])
+ errors = payload.get("errors", [])
+ stats[platform] = {
+ "path": str(path),
+ "available": True,
+ "result_count": len(results) if isinstance(results, list) else None,
+ "error_count": len(errors) if isinstance(errors, list) else None,
+ "errors": errors if isinstance(errors, list) else [],
+ }
+
+ return stats
+
+
+def _render_comparison(comparison: dict[str, Any]) -> str:
+ reference = str(comparison.get("reference_platform", "unknown"))
+ candidate = str(comparison.get("candidate_platform", "unknown"))
+ file_summary = comparison.get("file_summary") or {}
+ pass_count = int(file_summary.get("pass_count", 0))
+ fail_count = int(file_summary.get("fail_count", 0))
+ total_files = int(file_summary.get("total_reference_files", 0))
+
+ html_parts: list[str] = []
+ html_parts.append(f"<h2>{html.escape(candidate)} vs {html.escape(reference)}</h2>")
+ html_parts.append("<table><thead><tr><th>Pass</th><th>Fail</th><th>Total</th></tr></thead><tbody>")
+ html_parts.append(
+ "<tr>"
+ f"<td class='pass'>{pass_count}</td>"
+ f"<td class='fail'>{fail_count}</td>"
+ f"<td>{total_files}</td>"
+ "</tr>"
+ )
+ html_parts.append("</tbody></table>")
+
+ missing_files = comparison.get("missing_files", [])
+ extra_files = comparison.get("extra_files", [])
+ if isinstance(missing_files, list) and missing_files:
+ html_parts.append("<p><strong>Missing files:</strong> " + ", ".join(html.escape(str(value)) for value in missing_files) + "</p>")
+ if isinstance(extra_files, list) and extra_files:
+ html_parts.append("<p><strong>Extra files:</strong> " + ", ".join(html.escape(str(value)) for value in extra_files) + "</p>")
+
+ statuses = comparison.get("file_statuses", [])
+ if not isinstance(statuses, list):
+ statuses = []
+
+ rows: list[dict[str, Any]] = []
+ for status in statuses:
+ if not isinstance(status, dict):
+ continue
+ rows.append(status)
+
+ rows.sort(key=lambda row: (bool(row.get("passed", False)), str(row.get("file_id", ""))))
+
+ html_parts.append("<h3>Files</h3>")
+ if not rows:
+ html_parts.append("<p class='muted'>No file-level entries.</p>")
+ return "".join(html_parts)
+
+ for status in rows:
+ file_id = str(status.get("file_id", ""))
+ passed = bool(status.get("passed", False))
+ failures = status.get("failures", [])
+ if not isinstance(failures, list):
+ failures = []
+ metrics = status.get("metrics", [])
+ if not isinstance(metrics, list):
+ metrics = []
+
+ open_attr = " open" if not passed else ""
+ html_parts.append(
+ f"<details{open_attr}><summary>{html.escape(file_id)} "
+ f"<span class='{_status_class(passed)}'>{_status_label(passed)}</span></summary>"
+ )
+
+ html_parts.append(
+ "<table><thead><tr>"
+ "<th>Metric</th><th>Value</th><th>Threshold</th><th>Direction</th><th>Passed</th><th>Count</th><th>Applicable</th><th>Note</th>"
+ "</tr></thead><tbody>"
+ )
+ if metrics:
+ for metric in metrics:
+ if not isinstance(metric, dict):
+ continue
+ metric_name = html.escape(str(metric.get("metric", "-")))
+ value = html.escape(_format_value(metric.get("value")))
+ threshold = html.escape(_format_value(metric.get("threshold")))
+ direction = html.escape(_format_value(metric.get("direction")))
+ metric_passed = bool(metric.get("passed", False))
+ count = html.escape(_format_value(metric.get("count")))
+ applicable = bool(metric.get("applicable", True))
+ message = html.escape(str(metric.get("message", "")))
+ html_parts.append(
+ "<tr>"
+ f"<td>{metric_name}</td>"
+ f"<td>{value}</td>"
+ f"<td>{threshold}</td>"
+ f"<td>{direction}</td>"
+ f"<td class='{_status_class(metric_passed)}'>{_status_label(metric_passed)}</td>"
+ f"<td>{count}</td>"
+ f"<td>{'yes' if applicable else 'no'}</td>"
+ f"<td>{message}</td>"
+ "</tr>"
+ )
+ else:
+ html_parts.append(
+ "<tr><td colspan='8' class='muted'>No metrics available in report for this file.</td></tr>"
+ )
+ html_parts.append("</tbody></table>")
+
+ html_parts.append("<h4>Threshold Failures</h4>")
+ html_parts.append("<table><thead><tr><th>Metric</th><th>Value</th><th>Threshold</th><th>Message</th></tr></thead><tbody>")
+ if failures:
+ for failure in failures:
+ if not isinstance(failure, dict):
+ continue
+ html_parts.append(
+ "<tr>"
+ f"<td>{html.escape(str(failure.get('metric', '-')))}</td>"
+ f"<td>{html.escape(_format_value(failure.get('value')))}</td>"
+ f"<td>{html.escape(_format_value(failure.get('threshold')))}</td>"
+ f"<td>{html.escape(str(failure.get('message', '')))}</td>"
+ "</tr>"
+ )
+ else:
+ html_parts.append("<tr><td colspan='4' class='muted'>None</td></tr>")
+ html_parts.append("</tbody></table>")
+
+ html_parts.append("</details>")
+
+ return "".join(html_parts)
+
+
+def render_report(
+ *,
+ report_path: Path,
+ output_path: Path,
+ include_pairwise: bool,
+) -> None:
+ payload = json.loads(report_path.read_text())
+ ground_truth_platform = str(payload.get("ground_truth_platform", "python"))
+
+ comparisons = payload.get("comparisons", [])
+ if not isinstance(comparisons, list):
+ comparisons = []
+
+ if not include_pairwise:
+ comparisons = [
+ comparison
+ for comparison in comparisons
+ if isinstance(comparison, dict)
+ and str(comparison.get("reference_platform", "")) == ground_truth_platform
+ ]
+
+ report_dir = report_path.parent
+ platform_stats = _platform_stats(report_dir)
+
+ html_parts: list[str] = []
+ html_parts.append("<!doctype html><html><head><meta charset='utf-8'><title>ML Indexing Parity Report</title>")
+ html_parts.append(
+ "<style>"
+ "body{font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;margin:20px;line-height:1.35;color:#111827;}"
+ "h1,h2,h3,h4{margin:14px 0 8px;}"
+ "table{border-collapse:collapse;width:100%;margin:8px 0 14px;table-layout:fixed;}"
+ "th,td{border:1px solid #d0d5dd;padding:8px;vertical-align:top;overflow-wrap:anywhere;word-break:break-word;}"
+ "th{background:#f9fafb;text-align:left;}"
+ "details{margin:10px 0;border:1px solid #e4e7ec;border-radius:8px;padding:8px 10px;background:#fff;}"
+ "summary{cursor:pointer;font-weight:600;}"
+ ".pass{color:#067647;font-weight:600;}"
+ ".fail{color:#b42318;font-weight:600;}"
+ ".muted{color:#667085;}"
+ ".chip{display:inline-block;padding:3px 8px;border-radius:999px;background:#f2f4f7;margin-right:6px;font-size:12px;}"
+ "</style>"
+ )
+ html_parts.append("</head><body>")
+
+ html_parts.append("<h1>ML Indexing Parity Report</h1>")
+ html_parts.append(
+ f"<p><span class='chip'>Generated: {html.escape(str(payload.get('generated_at', '-')))}</span>"
+ f"<span class='chip'>Ground truth: {html.escape(ground_truth_platform)}</span>"
+ f"<span class='chip'>Comparisons shown: {len(comparisons)}</span></p>"
+ )
+
+ html_parts.append("<h2>Platform Outputs</h2>")
+ html_parts.append("<table><thead><tr><th>Platform</th><th>Output File</th><th>Results</th><th>Runner Errors</th><th>Status</th></tr></thead><tbody>")
+ for platform in ("python", "desktop", "android", "ios"):
+ info = platform_stats[platform]
+ status_text = "generated" if info["available"] else "missing"
+ status_class = "pass" if info["available"] else "fail"
+ results = _format_value(info.get("result_count"))
+ errors = _format_value(info.get("error_count"))
+ html_parts.append(
+ "<tr>"
+ f"<td>{html.escape(platform)}</td>"
+ f"<td><code>{html.escape(info['path'])}</code></td>"
+ f"<td>{html.escape(results)}</td>"
+ f"<td>{html.escape(errors)}</td>"
+ f"<td class='{status_class}'>{status_text}</td>"
+ "</tr>"
+ )
+ html_parts.append("</tbody></table>")
+
+ if not comparisons:
+ html_parts.append("<p class='muted'>No comparisons available.</p>")
+ else:
+ comparisons = sorted(
+ comparisons,
+ key=lambda comparison: (
+ str(comparison.get("reference_platform", "")),
+ str(comparison.get("candidate_platform", "")),
+ ),
+ )
+ for comparison in comparisons:
+ if not isinstance(comparison, dict):
+ continue
+ html_parts.append(_render_comparison(comparison))
+
+ html_parts.append("<h2>Runner Errors</h2>")
+ for platform in ("desktop", "ios", "android", "python"):
+ info = platform_stats[platform]
+ html_parts.append(f"<h3>{html.escape(platform)}</h3>")
+ errors = info.get("errors") if info.get("available") else None
+ if not errors:
+ html_parts.append("<p class='muted'>None</p>")
+ continue
+ html_parts.append("<table><thead><tr><th>File</th><th>Error</th></tr></thead><tbody>")
+ for error in errors:
+ if not isinstance(error, dict):
+ continue
+ html_parts.append(
+ "<tr>"
+ f"<td>{html.escape(str(error.get('file_id', '-')))}</td>"
+ f"<td>{html.escape(str(error.get('error', '-')))}</td>"
+ "</tr>"
+ )
+ html_parts.append("</tbody></table>")
+
+ html_parts.append("</body></html>")
+
+ output_path.parent.mkdir(parents=True, exist_ok=True)
+ output_path.write_text("".join(html_parts))
+
+
+def main() -> int:
+ parser = argparse.ArgumentParser(
+ description="Render a readable HTML report from ML parity comparison JSON.",
+ )
+ parser.add_argument(
+ "--report",
+ required=True,
+ help="Path to comparison_report.json",
+ )
+ parser.add_argument(
+ "--output",
+ help="Output HTML path (default: <report_dir>/parity_report.html)",
+ )
+ parser.add_argument(
+ "--include-pairwise",
+ action="store_true",
+ help="Include non-ground-truth pairwise comparisons in the report.",
+ )
+ args = parser.parse_args()
+
+ report_path = Path(args.report)
+ if args.output:
+ output_path = Path(args.output)
+ else:
+ output_path = report_path.parent / "parity_report.html"
+
+ render_report(
+ report_path=report_path,
+ output_path=output_path,
+ include_pairwise=args.include_pairwise,
+ )
+ print(output_path)
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/infra/ml/test/tools/run_suite.sh b/infra/ml/test/tools/run_suite.sh
index 79e521aad8..c431e60a8c 100755
--- a/infra/ml/test/tools/run_suite.sh
+++ b/infra/ml/test/tools/run_suite.sh
@@ -629,6 +629,21 @@ if not printed_any_table:
PY
}
+render_html_report() {
+ local report_path="$1"
+ local html_output_path="$OUTPUT_DIR/parity_report.html"
+
+ if ! python3 "$ML_DIR/tools/render_parity_html_report.py" \
+ --report "$report_path" \
+ --output "$html_output_path"; then
+ echo "Failed to render HTML parity report at $html_output_path"
+ return 1
+ fi
+
+ echo "HTML parity report: $html_output_path"
+ return 0
+}
+
declare -a failed_platform_runners=()
for platform in "${selected_platforms[@]}"; do
@@ -696,6 +711,7 @@ compare_output="$OUTPUT_DIR/comparison_report.json"
compare_cmd=(
uv run --project "$UV_PROJECT_DIR" --no-sync python "$ML_DIR/tools/compare_parity_outputs.py"
--ground-truth "$PYTHON_OUTPUT_DIR/results.json"
+ --no-pairwise
--output "$compare_output"
)
if ((${#compare_args[@]} > 0)); then
@@ -710,6 +726,7 @@ set -e
echo "Comparison report: $compare_output"
if [[ -f "$compare_output" ]]; then
render_file_level_report_tables "$compare_output"
+ render_html_report "$compare_output"
fi
if ((compare_exit != 0)); then