Skip to content

armgit / ente

Public Imported from GitHub
0

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

minor changes

laurenspriembfbe1ca6b4b2
diff --git a/infra/ml/comparator/compare.py b/infra/ml/comparator/compare.py
index fa6939501c..3b7b9009be 100644
--- a/infra/ml/comparator/compare.py
+++ b/infra/ml/comparator/compare.py
@@ -199,6 +199,29 @@ def _make_aggregate(values: list[float], threshold: float) -> AggregateMetric:
)
+def _index_results(
+ results: Sequence[ParityResult],
+ *,
+ platform: str,
+) -> dict[str, ParityResult]:
+ indexed: dict[str, ParityResult] = {}
+ duplicate_ids: set[str] = set()
+
+ for result in results:
+ if result.file_id in indexed:
+ duplicate_ids.add(result.file_id)
+ continue
+ indexed[result.file_id] = result
+
+ if duplicate_ids:
+ duplicates = ", ".join(sorted(duplicate_ids))
+ raise ValueError(
+ f"platform '{platform}' emitted duplicate file_id values: {duplicates}"
+ )
+
+ return indexed
+
+
def _match_faces(
reference_faces: Sequence[FaceResult],
candidate_faces: Sequence[FaceResult],
@@ -422,7 +445,7 @@ def compare_platform_matrix(
raise ValueError(f"ground truth platform '{ground_truth_platform}' missing")
by_platform: dict[str, dict[str, ParityResult]] = {
- platform: {result.file_id: result for result in results}
+ platform: _index_results(results, platform=platform)
for platform, results in platform_results.items()
}
diff --git a/infra/ml/tests/test_comparator.py b/infra/ml/tests/test_comparator.py
index 2dd9a5ad78..58ef65efb6 100644
--- a/infra/ml/tests/test_comparator.py
+++ b/infra/ml/tests/test_comparator.py
@@ -2,6 +2,8 @@ from __future__ import annotations
import math
+import pytest
+
from comparator.compare import (
ThresholdConfig,
compare_platform_matrix,
@@ -234,3 +236,32 @@ def test_compare_platform_matrix_includes_pairwise_reports() -> None:
assert len(reports) == 6
assert all(report.passed for report in reports)
+
+
+def test_compare_platform_matrix_rejects_duplicate_file_ids() -> None:
+ reference = _result(
+ file_id="man.jpeg",
+ platform="python",
+ clip_seed=6,
+ faces=(_face(200, x=0.25, y=0.12, score=0.9),),
+ )
+ android_primary = _result(
+ file_id="man.jpeg",
+ platform="android",
+ clip_seed=6,
+ faces=(_face(200, x=0.25, y=0.12, score=0.9),),
+ )
+ android_duplicate = _result(
+ file_id="man.jpeg",
+ platform="android",
+ clip_seed=7,
+ faces=(_face(201, x=0.25, y=0.12, score=0.9),),
+ )
+
+ with pytest.raises(ValueError, match="platform 'android' emitted duplicate file_id values"):
+ compare_platform_matrix(
+ {
+ "python": (reference,),
+ "android": (android_primary, android_duplicate),
+ }
+ )
diff --git a/infra/ml/tools/run_suite.sh b/infra/ml/tools/run_suite.sh
index eee4f43c91..5b1ae0ab38 100755
--- a/infra/ml/tools/run_suite.sh
+++ b/infra/ml/tools/run_suite.sh
@@ -57,7 +57,12 @@ while (($# > 0)); do
esac
done
+if [[ "$OUTPUT_DIR" != /* ]]; then
+ OUTPUT_DIR="$ROOT_DIR/$OUTPUT_DIR"
+fi
+
mkdir -p "$OUTPUT_DIR"
+OUTPUT_DIR="$(cd "$OUTPUT_DIR" && pwd -P)"
PYTHON_OUTPUT_DIR="$OUTPUT_DIR/python"
mkdir -p "$PYTHON_OUTPUT_DIR"