Skip to content

armgit / ente

Public Imported from GitHub
0

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

Last changes for ML indexing tests

laurenspriem1f2bf9d5f7ce
diff --git a/.github/workflows/ml-indexing-parity.yml b/.github/workflows/ml-indexing-parity.yml
deleted file mode 100644
index 230a856860..0000000000
--- a/.github/workflows/ml-indexing-parity.yml
+++ /dev/null
@@ -1,166 +0,0 @@
-name: "ML Indexing Parity"
-
-on:
- workflow_dispatch: # Manual trigger only. No automatic PR/push/schedule triggers.
- inputs:
- platforms:
- description: "Platform runner(s) to execute"
- required: true
- default: "all"
- type: choice
- options:
- - all
- - desktop
- - android
- - ios
- fail_on_missing_platform:
- description: "Fail if any selected platform output is missing"
- required: false
- default: false
- type: boolean
- allow_empty_comparison:
- description: "Allow completion when no platform output is produced"
- required: false
- default: false
- type: boolean
- android_device_id:
- description: "Optional explicit Flutter Android device ID"
- required: false
- default: ""
- type: string
- ios_device_id:
- description: "Optional explicit Flutter iOS device ID"
- required: false
- default: ""
- type: string
-
-env:
- FLUTTER_VERSION: "3.32.8"
-
-permissions:
- contents: read
-
-jobs:
- parity:
- if: github.event_name == 'workflow_dispatch'
- runs-on: macos-latest
- timeout-minutes: 120
- defaults:
- run:
- shell: bash
- steps:
- - name: Checkout code and submodules
- uses: actions/checkout@v4
- with:
- submodules: recursive
-
- - name: Setup JDK 17
- uses: actions/setup-java@v4
- with:
- distribution: "temurin"
- java-version: "17"
-
- - name: Setup Python 3.12
- uses: actions/setup-python@v5
- with:
- python-version: "3.12"
-
- - name: Install uv
- uses: astral-sh/setup-uv@v5
-
- - name: Setup Node.js 22
- uses: actions/setup-node@v4
- with:
- node-version: "22"
-
- - name: Enable Yarn 1.22.22
- run: |
- corepack enable
- corepack prepare [email protected] --activate
-
- - name: Install Flutter ${{ env.FLUTTER_VERSION }}
- uses: subosito/flutter-action@v2
- with:
- channel: "stable"
- flutter-version: ${{ env.FLUTTER_VERSION }}
- cache: true
-
- - name: Install desktop dependencies
- run: yarn --cwd desktop install --frozen-lockfile
-
- - name: Install web dependencies
- run: yarn --cwd web install --frozen-lockfile
-
- - name: Install Python parity dependencies
- run: uv sync --project infra/ml
-
- - name: Install Flutter Rust Bridge codegen
- run: cargo install flutter_rust_bridge_codegen
-
- - name: Install mobile package dependencies (core)
- run: flutter pub get
- working-directory: mobile/packages/rust
-
- - name: Generate Rust bindings (core)
- run: flutter_rust_bridge_codegen generate
- working-directory: mobile/packages/rust
-
- - name: Install mobile app dependencies (photos)
- run: flutter pub get
- working-directory: mobile/apps/photos
-
- - name: Generate Rust bindings (photos)
- run: flutter_rust_bridge_codegen generate
- working-directory: mobile/apps/photos
-
- - name: Set Android device override
- if: ${{ github.event.inputs.android_device_id != '' }}
- run: echo "ML_PARITY_ANDROID_DEVICE_ID=${{ github.event.inputs.android_device_id }}" >> "$GITHUB_ENV"
-
- - name: Resolve iOS simulator
- if: ${{ github.event.inputs.platforms == 'ios' || github.event.inputs.platforms == 'all' }}
- run: |
- if [[ -n "${{ github.event.inputs.ios_device_id }}" ]]; then
- echo "ML_PARITY_IOS_DEVICE_ID=${{ github.event.inputs.ios_device_id }}" >> "$GITHUB_ENV"
- exit 0
- fi
-
- simulator_id="$(xcrun simctl list devices available | awk -F '[()]' '/iPhone 16/{print $2; exit}')"
- if [[ -z "$simulator_id" ]]; then
- simulator_id="$(xcrun simctl list devices available | awk -F '[()]' '/iPhone/{print $2; exit}')"
- fi
- if [[ -z "$simulator_id" ]]; then
- echo "No available iOS simulator found" >&2
- exit 1
- fi
-
- xcrun simctl boot "$simulator_id" || true
- xcrun simctl bootstatus "$simulator_id" -b
- echo "ML_PARITY_IOS_DEVICE_ID=$simulator_id" >> "$GITHUB_ENV"
-
- - name: Run ML indexing parity suite
- env:
- PARITY_PLATFORMS: ${{ github.event.inputs.platforms }}
- PARITY_FAIL_ON_MISSING: ${{ github.event.inputs.fail_on_missing_platform }}
- PARITY_ALLOW_EMPTY: ${{ github.event.inputs.allow_empty_comparison }}
- run: |
- args=(
- --platforms "$PARITY_PLATFORMS"
- --output-dir "infra/ml/test/out/parity"
- )
- if [[ "$PARITY_FAIL_ON_MISSING" == "true" ]]; then
- args+=(--fail-on-missing-platform)
- fi
- if [[ "$PARITY_ALLOW_EMPTY" == "true" ]]; then
- args+=(--allow-empty-comparison)
- fi
-
- bash infra/ml/test/tools/run_suite.sh "${args[@]}"
-
- - name: Upload parity artifacts
- if: always()
- uses: actions/upload-artifact@v4
- with:
- name: "ml-indexing-parity-${{ github.run_id }}-${{ github.run_attempt }}"
- path: "infra/ml/test/out/parity/**"
- if-no-files-found: ignore
diff --git a/desktop/scripts/ml_parity_runner.ts b/desktop/scripts/ml_parity_runner.ts
index e5b77f70cf..db670ceb61 100755
--- a/desktop/scripts/ml_parity_runner.ts
+++ b/desktop/scripts/ml_parity_runner.ts
@@ -47,6 +47,7 @@ interface HostResponse {
interface PendingRequest {
resolve: (value: unknown) => void;
reject: (reason: unknown) => void;
+ timeoutHandle: ReturnType<typeof setTimeout>;
}
interface WebMLBindings {
@@ -104,6 +105,24 @@ const MODEL_FILE_NAMES: Record<string, string> = {
face_embedding: "mobilefacenet_opset15.onnx",
};
const HOST_RESPONSE_PREFIX = "__ML_PARITY_JSON__";
+const DEFAULT_HOST_REQUEST_TIMEOUT_MS = 120_000;
+
+const parseHostRequestTimeoutMS = (value: string | undefined): number => {
+ const trimmed = value?.trim();
+ if (!trimmed) {
+ return DEFAULT_HOST_REQUEST_TIMEOUT_MS;
+ }
+ const parsed = Number.parseInt(trimmed, 10);
+ if (!Number.isFinite(parsed) || parsed < 1_000) {
+ throw new Error(
+ "ML_PARITY_HOST_REQUEST_TIMEOUT_MS must be an integer >= 1000",
+ );
+ }
+ return parsed;
+};
+const HOST_REQUEST_TIMEOUT_MS = parseHostRequestTimeoutMS(
+ process.env.ML_PARITY_HOST_REQUEST_TIMEOUT_MS,
+);
const usage = () => {
process.stderr.write(`Usage: desktop/scripts/ml_parity_runner.ts [flags]\n\n`);
@@ -255,6 +274,7 @@ class HostClient {
private readonly rl: readline.Interface;
private nextID = 1;
private readonly pending = new Map<number, PendingRequest>();
+ private readonly requestTimeoutMS: number;
private closed = false;
constructor(
@@ -262,6 +282,7 @@ class HostClient {
hostScriptPath: string,
userDataPath: string,
) {
+ this.requestTimeoutMS = HOST_REQUEST_TIMEOUT_MS;
this.process = spawn(electronBinPath, [hostScriptPath], {
cwd: DESKTOP_ROOT,
env: {
@@ -313,6 +334,7 @@ class HostClient {
if (!pending) {
return;
}
+ clearTimeout(pending.timeoutHandle);
this.pending.delete(message.id);
if (message.ok) {
@@ -341,6 +363,7 @@ class HostClient {
return;
}
for (const pending of this.pending.values()) {
+ clearTimeout(pending.timeoutHandle);
pending.reject(error);
}
this.pending.clear();
@@ -362,10 +385,31 @@ class HostClient {
this.nextID += 1;
const resultPromise = new Promise<unknown>((resolve, reject) => {
- this.pending.set(id, { resolve, reject });
+ const timeoutHandle = setTimeout(() => {
+ const pending = this.pending.get(id);
+ if (!pending) {
+ return;
+ }
+ this.pending.delete(id);
+ pending.reject(
+ new Error(
+ `Host request '${method}' timed out after ${this.requestTimeoutMS}ms`,
+ ),
+ );
+ }, this.requestTimeoutMS);
+ this.pending.set(id, { resolve, reject, timeoutHandle });
});
- await this.writeRequest({ id, method, params });
+ try {
+ await this.writeRequest({ id, method, params });
+ } catch (error) {
+ const pending = this.pending.get(id);
+ if (pending) {
+ clearTimeout(pending.timeoutHandle);
+ this.pending.delete(id);
+ }
+ throw error;
+ }
return resultPromise;
}
diff --git a/infra/ml/test/README.md b/infra/ml/test/README.md
index 66b115e3c8..8a43a9a469 100644
--- a/infra/ml/test/README.md
+++ b/infra/ml/test/README.md
@@ -71,18 +71,6 @@ Useful optional filters:
- `--file-id <fixture_name>` (repeatable)
- `--output-dir <custom_dir>`
-## Manual CI Run
-
-Workflow: `.github/workflows/ml-indexing-parity.yml`
-
-Run via `workflow_dispatch` and choose:
-
-- `platforms`
-- strictness flags
-- optional explicit Android/iOS device IDs
-
-CI uploads artifacts from `infra/ml/test/out/parity/**`.
-
## Golden Update / Maintenance
Goldens are runtime artifacts and are not committed.
diff --git a/infra/ml/test/comparator/compare.py b/infra/ml/test/comparator/compare.py
index 183d314edd..ae966e5e56 100644
--- a/infra/ml/test/comparator/compare.py
+++ b/infra/ml/test/comparator/compare.py
@@ -237,8 +237,12 @@ class ComparisonReport:
passed: bool
def to_dict(self) -> dict[str, Any]:
+ total_files = len(self.file_statuses)
+ non_reference_file_count = max(0, total_files - self.total_reference_files)
file_summary = {
"total_reference_files": self.total_reference_files,
+ "total_files": total_files,
+ "non_reference_file_count": non_reference_file_count,
"checked_files": self.checked_files,
"pass_count": len(self.passing_files),
"warning_count": len(self.warning_files),
@@ -384,25 +388,30 @@ def compare_result_sets(
extra_files = tuple(sorted(set(candidate_results) - set(reference_results)))
findings: list[ComparisonFinding] = []
warnings: list[ComparisonFinding] = []
- file_failures: dict[str, list[ComparisonFinding]] = {
- file_id: [] for file_id in reference_results
- }
- file_warnings: 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
- }
+ file_failures: dict[str, list[ComparisonFinding]] = {}
+ file_warnings: dict[str, list[ComparisonFinding]] = {}
+ file_metrics: dict[str, list[FileMetricMeasurement]] = {}
+
+ def ensure_file_entry(file_id: str) -> None:
+ if file_id not in file_failures:
+ file_failures[file_id] = []
+ if file_id not in file_warnings:
+ file_warnings[file_id] = []
+ if file_id not in file_metrics:
+ file_metrics[file_id] = []
+
+ for file_id in reference_results:
+ ensure_file_entry(file_id)
def add_failure(finding: ComparisonFinding) -> None:
findings.append(finding)
- if finding.file_id in file_failures:
- file_failures[finding.file_id].append(finding)
+ ensure_file_entry(finding.file_id)
+ file_failures[finding.file_id].append(finding)
def add_warning(warning: ComparisonFinding) -> None:
warnings.append(warning)
- if warning.file_id in file_warnings:
- file_warnings[warning.file_id].append(warning)
+ ensure_file_entry(warning.file_id)
+ file_warnings[warning.file_id].append(warning)
def add_file_metric(
*,
@@ -417,8 +426,7 @@ def compare_result_sets(
applicable: bool = True,
message: str | None = None,
) -> None:
- if file_id not in file_metrics:
- return
+ ensure_file_entry(file_id)
file_metrics[file_id].append(
FileMetricMeasurement(
metric=metric,
@@ -461,6 +469,16 @@ def compare_result_sets(
severity=STATUS_FAIL,
),
)
+ add_file_metric(
+ file_id=extra_file,
+ metric="file_presence",
+ value=1.0,
+ threshold=0.0,
+ status=STATUS_FAIL,
+ passed=False,
+ direction="==",
+ message=f"Unexpected file in {candidate_platform}",
+ )
clip_distances: list[float] = []
iou_errors: list[float] = []
@@ -932,6 +950,19 @@ def compare_result_sets(
for metric_name, metric in aggregates.items():
if metric.status == STATUS_PASS:
continue
+ threshold = metric.warning_threshold if metric.status == STATUS_WARNING else metric.threshold
+ add_file_metric(
+ file_id="*aggregate*",
+ metric=metric_name,
+ value=metric.max,
+ threshold=threshold,
+ status=metric.status,
+ passed=metric.status != STATUS_FAIL,
+ direction="<=",
+ count=metric.count,
+ applicable=metric.count > 0,
+ message="Aggregate threshold gate",
+ )
if metric.status == STATUS_WARNING:
add_warning(
ComparisonFinding(
@@ -957,7 +988,12 @@ def compare_result_sets(
report_findings = tuple(findings)
report_warnings = tuple(warnings)
- sorted_reference_files = sorted(reference_results)
+ sorted_file_ids = sorted(
+ set(reference_results)
+ | set(file_failures)
+ | set(file_warnings)
+ | set(file_metrics),
+ )
file_statuses = tuple(
FileComparisonStatus(
file_id=file_id,
@@ -973,7 +1009,7 @@ def compare_result_sets(
failures=tuple(file_failures[file_id]),
warnings=tuple(file_warnings[file_id]),
)
- for file_id in sorted_reference_files
+ for file_id in sorted_file_ids
)
passing_files = tuple(
file_status.file_id
diff --git a/infra/ml/test/ground_truth/README.md b/infra/ml/test/ground_truth/README.md
index 88c7ed1787..9bfe8188c7 100644
--- a/infra/ml/test/ground_truth/README.md
+++ b/infra/ml/test/ground_truth/README.md
@@ -37,6 +37,12 @@ The default corpus is sourced from:
HEIC/HEIF decoding requires the `pillow-heif` plugin (declared in
`infra/ml/pyproject.toml`).
+If Pillow decode fails, Python ground truth now fails by default instead of
+silently falling back to OpenCV decode (to avoid EXIF-orientation drift in
+parity outputs). Set `ML_PARITY_ALLOW_OPENCV_DECODE_FALLBACK=1` only for
+debugging; this emits explicit warnings and should not be used for trusted
+parity runs.
+
## Generate Goldens
```bash
diff --git a/infra/ml/test/ground_truth/_runtime.py b/infra/ml/test/ground_truth/_runtime.py
index 93bd2986c9..d8c2176e05 100644
--- a/infra/ml/test/ground_truth/_runtime.py
+++ b/infra/ml/test/ground_truth/_runtime.py
@@ -2,9 +2,12 @@ from __future__ import annotations
from dataclasses import dataclass
import hashlib
+import os
from pathlib import Path
+import sys
import tempfile
from typing import Final
+import warnings
import cv2
import numpy as np
@@ -23,6 +26,7 @@ except Exception:
DEFAULT_MODEL_BASE_URL: Final[str] = "https://models.ente.io/"
DEFAULT_PADDING_RGB: Final[tuple[int, int, int]] = (114, 114, 114)
+ALLOW_OPENCV_FALLBACK_ENV: Final[str] = "ML_PARITY_ALLOW_OPENCV_DECODE_FALLBACK"
@dataclass(frozen=True)
@@ -120,6 +124,34 @@ def decode_image_rgb(source_path: Path) -> np.ndarray:
pixels = np.array(image, dtype=np.uint8, copy=True)
return np.ascontiguousarray(pixels)
except Exception as pillow_error:
+ fallback_enabled = os.environ.get(ALLOW_OPENCV_FALLBACK_ENV, "").strip().lower() in {
+ "1",
+ "true",
+ "yes",
+ "on",
+ }
+ if not fallback_enabled:
+ suffix = source_path.suffix.lower()
+ heif_note = (
+ " Install pillow-heif to decode HEIC/HEIF files."
+ if suffix in {".heic", ".heif"}
+ else ""
+ )
+ raise RuntimeError(
+ f"Failed to decode image '{source_path}' with Pillow ({pillow_error}). "
+ "OpenCV decode fallback is DISABLED by default because it may diverge from "
+ "Pillow EXIF-orientation behavior and can break parity trust."
+ f"{heif_note} To force fallback anyway, set {ALLOW_OPENCV_FALLBACK_ENV}=1."
+ ) from pillow_error
+
+ warning_message = (
+ f"FALLING BACK to OpenCV decode for '{source_path}' after Pillow failure "
+ f"({pillow_error}). This can diverge from Pillow EXIF-orientation semantics and "
+ "may produce unreliable parity results."
+ )
+ warnings.warn(warning_message, RuntimeWarning, stacklevel=2)
+ print(f"[ml_parity][WARNING] {warning_message}", file=sys.stderr)
+
raw = np.fromfile(str(source_path), dtype=np.uint8)
decoded = cv2.imdecode(raw, cv2.IMREAD_COLOR)
if decoded is None:
diff --git a/infra/ml/test/tests/test_comparator.py b/infra/ml/test/tests/test_comparator.py
index c6cc75a7cf..5d3ebf15d6 100644
--- a/infra/ml/test/tests/test_comparator.py
+++ b/infra/ml/test/tests/test_comparator.py
@@ -91,6 +91,10 @@ def _result(
)
+def _status_for_file(report: object, file_id: str):
+ return next(status for status in report.file_statuses if status.file_id == file_id)
+
+
def test_compare_result_sets_passes_when_within_thresholds() -> None:
reference_faces = (_face(100, x=0.22, y=0.10, score=0.95),)
reference = _result(
@@ -134,13 +138,14 @@ def test_compare_result_sets_passes_when_within_thresholds() -> None:
assert report.total_reference_files == 1
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}
+ file_status = _status_for_file(report, "man.jpeg")
+ assert file_status.passed is True
+ metric_names = {metric.metric for metric in file_status.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
+ for metric in file_status.metrics
if metric.metric == "clip_cosine_distance"
)
assert clip_metric.passed is True
@@ -210,7 +215,7 @@ def test_compare_result_sets_passes_when_iou_above_single_loose_threshold() -> N
assert report.passed is True
assert not any(finding.metric == "face_box_iou" for finding in report.findings)
- file_status = report.file_statuses[0]
+ file_status = _status_for_file(report, reference.file_id)
iou_shortfall_metric = next(
metric
for metric in file_status.metrics
@@ -262,7 +267,7 @@ def test_compare_result_sets_fails_when_iou_below_single_loose_threshold() -> No
assert iou_failures
assert iou_failures[0].threshold == pytest.approx(0.80)
- file_status = report.file_statuses[0]
+ file_status = _status_for_file(report, reference.file_id)
iou_shortfall_metric = next(
metric
for metric in file_status.metrics
@@ -302,13 +307,13 @@ def test_compare_result_sets_fails_on_face_count_mismatch() -> None:
assert report.total_reference_files == 1
assert report.passing_files == ()
assert report.failing_files == ("people.jpeg",)
- assert report.file_statuses[0].file_id == "people.jpeg"
+ file_status = _status_for_file(report, "people.jpeg")
assert any(
- failure.metric == "face_count" for failure in report.file_statuses[0].failures
+ failure.metric == "face_count" for failure in file_status.failures
)
face_count_metric = next(
metric
- for metric in report.file_statuses[0].metrics
+ for metric in file_status.metrics
if metric.metric == "face_count_delta"
)
assert face_count_metric.passed is False
@@ -347,7 +352,7 @@ def test_compare_result_sets_ignores_faces_below_min_score_threshold() -> None:
assert report.failing_files == ()
assert report.passing_files == ("score-filter.jpeg",)
- file_status = report.file_statuses[0]
+ file_status = _status_for_file(report, "score-filter.jpeg")
assert file_status.status == "pass"
assert file_status.passed is True
assert file_status.failures == ()
@@ -396,7 +401,7 @@ def test_compare_result_sets_marks_face_embedding_warning_band() -> None:
assert report.passed is True
assert report.findings == ()
assert report.failing_files == ()
- assert report.warning_files == ("embedding-warning.jpeg",)
+ assert report.warning_files == ("*aggregate*", "embedding-warning.jpeg")
assert report.passing_files == ()
assert any(
warning.metric == "face_embedding_cosine_distance"
@@ -405,7 +410,7 @@ def test_compare_result_sets_marks_face_embedding_warning_band() -> None:
)
assert any(warning.file_id == "*aggregate*" for warning in report.warnings)
- file_status = report.file_statuses[0]
+ file_status = _status_for_file(report, "embedding-warning.jpeg")
assert file_status.status == "warning"
assert file_status.passed is True
assert file_status.failures == ()
@@ -455,13 +460,13 @@ def test_compare_result_sets_fails_face_embedding_above_warning_band() -> None:
assert report.status == "fail"
assert report.passed is False
- assert report.failing_files == ("embedding-fail.jpeg",)
+ assert report.failing_files == ("*aggregate*", "embedding-fail.jpeg")
assert report.warning_files == ()
assert any(
finding.metric == "face_embedding_cosine_distance" for finding in report.findings
)
- file_status = report.file_statuses[0]
+ file_status = _status_for_file(report, "embedding-fail.jpeg")
assert file_status.status == "fail"
assert file_status.passed is False
@@ -524,7 +529,7 @@ def test_compare_result_sets_reports_unmatched_faces_after_iou_gating() -> None:
)
assert not any(finding.metric == "face_box_iou" for finding in report.findings)
- file_status = report.file_statuses[0]
+ file_status = _status_for_file(report, "offset-face.jpeg")
matched_metric = next(
metric for metric in file_status.metrics if metric.metric == "matched_face_count"
)
@@ -581,6 +586,39 @@ def test_aggregate_gate_failure_is_reported() -> None:
assert report.passed is False
assert any(finding.file_id == "*aggregate*" for finding in report.findings)
+ assert "*aggregate*" in report.failing_files
+ aggregate_status = next(
+ status for status in report.file_statuses if status.file_id == "*aggregate*"
+ )
+ assert aggregate_status.status == "fail"
+ assert any(metric.metric == "clip_cosine_distance" for metric in aggregate_status.metrics)
+
+
+def test_extra_candidate_file_is_included_in_file_status_summary() -> None:
+ extra_candidate = _result(
+ file_id="unexpected.jpeg",
+ platform="desktop",
+ clip_seed=55,
+ faces=(),
+ )
+
+ report = compare_result_sets(
+ reference_platform="python",
+ candidate_platform="desktop",
+ reference_results={},
+ candidate_results={extra_candidate.file_id: extra_candidate},
+ )
+
+ assert report.status == "fail"
+ assert report.passed is False
+ assert report.failing_files == ("unexpected.jpeg",)
+ status = next(
+ file_status
+ for file_status in report.file_statuses
+ if file_status.file_id == "unexpected.jpeg"
+ )
+ assert status.status == "fail"
+ assert any(failure.metric == "file_presence" for failure in status.failures)
def test_compare_platform_matrix_includes_pairwise_reports() -> None:
diff --git a/infra/ml/test/tools/render_parity_html_report.py b/infra/ml/test/tools/render_parity_html_report.py
index 2e249d74d9..c163b49d6f 100755
--- a/infra/ml/test/tools/render_parity_html_report.py
+++ b/infra/ml/test/tools/render_parity_html_report.py
@@ -101,7 +101,12 @@ def _render_comparison(comparison: dict[str, Any]) -> str:
pass_count = int(file_summary.get("pass_count", 0))
warning_count = int(file_summary.get("warning_count", 0))
fail_count = int(file_summary.get("fail_count", 0))
- total_files = int(file_summary.get("total_reference_files", 0))
+ total_files = int(
+ file_summary.get(
+ "total_files",
+ file_summary.get("total_reference_files", 0),
+ )
+ )
findings = comparison.get("findings", [])
warnings = comparison.get("warnings", [])
finding_count = len(findings) if isinstance(findings, list) else 0
diff --git a/infra/ml/test/tools/render_parity_markdown_report.py b/infra/ml/test/tools/render_parity_markdown_report.py
index 2395adfb8e..5483e70239 100644
--- a/infra/ml/test/tools/render_parity_markdown_report.py
+++ b/infra/ml/test/tools/render_parity_markdown_report.py
@@ -318,19 +318,32 @@ def _render_comparison(comparison: dict[str, Any]) -> list[str]:
pass_count = int(file_summary.get("pass_count", 0))
warning_count = int(file_summary.get("warning_count", 0))
fail_count = int(file_summary.get("fail_count", 0))
- total_files = int(file_summary.get("total_reference_files", 0))
+ total_files = int(
+ file_summary.get(
+ "total_files",
+ file_summary.get("total_reference_files", 0),
+ )
+ )
+ reference_total_files = int(
+ file_summary.get("total_reference_files", comparison.get("total_reference_files", 0))
+ )
checked_files = int(file_summary.get("checked_files", comparison.get("checked_files", 0)))
findings = comparison.get("findings", [])
warnings = comparison.get("warnings", [])
finding_count = len(findings) if isinstance(findings, list) else 0
warning_finding_count = len(warnings) if isinstance(warnings, list) else 0
+ total_summary = (
+ f"{total_files} total files"
+ if total_files == reference_total_files
+ else f"{total_files} total files ({reference_total_files} reference)"
+ )
lines: list[str] = [
f"## {candidate} vs {reference}",
"",
(
f"- Summary: {pass_count} pass / {warning_count} warning / {fail_count} fail / "
- f"{total_files} total reference files"
+ f"{total_summary}"
),
f"- Checked files: {checked_files}",
f"- Threshold findings: {finding_count} fail / {warning_finding_count} warning",
diff --git a/infra/ml/test/tools/run_suite.sh b/infra/ml/test/tools/run_suite.sh
index f11a272c70..eff5031b4f 100755
--- a/infra/ml/test/tools/run_suite.sh
+++ b/infra/ml/test/tools/run_suite.sh
@@ -1682,7 +1682,12 @@ for comparison in comparisons:
file_summary = comparison.get("file_summary") or {}
if not isinstance(file_summary, dict):
file_summary = {}
- total_files = int(file_summary.get("total_reference_files", comparison.get("total_reference_files", 0)))
+ total_files = int(
+ file_summary.get(
+ "total_files",
+ file_summary.get("total_reference_files", comparison.get("total_reference_files", 0)),
+ )
+ )
pass_count = int(file_summary.get("pass_count", len(comparison.get("passing_files", []))))
warning_count = int(file_summary.get("warning_count", len(comparison.get("warning_files", []))))
fail_count = int(file_summary.get("fail_count", len(comparison.get("failing_files", []))))
@@ -1861,7 +1866,12 @@ for comparison in comparisons:
pass_count = int(file_summary.get("pass_count", len(comparison.get("passing_files", []))))
warning_count = int(file_summary.get("warning_count", len(comparison.get("warning_files", []))))
fail_count = int(file_summary.get("fail_count", len(comparison.get("failing_files", []))))
- total_files = int(file_summary.get("total_reference_files", comparison.get("total_reference_files", 0)))
+ total_files = int(
+ file_summary.get(
+ "total_files",
+ file_summary.get("total_reference_files", comparison.get("total_reference_files", 0)),
+ )
+ )
summary_by_platform[candidate_platform] = (
pass_count,
warning_count,