-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
ref(snapshots): Add configurable diff_threshold for snapshot comparison #112728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -381,6 +381,8 @@ def compare_snapshots( | |
| comparison.save(update_fields=["state", "error_code", "date_updated"]) | ||
| return | ||
|
|
||
| diff_threshold = head_manifest.diff_threshold | ||
|
|
||
| head_images = head_manifest.images | ||
| base_images = base_manifest.images | ||
|
|
||
|
|
@@ -571,12 +573,29 @@ def _fetch_hash(h: str) -> None: | |
| ) | ||
| session.put(diff_mask_bytes, key=diff_mask_key, content_type="image/png") | ||
|
|
||
| is_changed = diff_result.changed_pixels > 0 | ||
| diff_pct = ( | ||
| diff_result.changed_pixels / diff_result.total_pixels | ||
| if diff_result.total_pixels > 0 | ||
| else 0 | ||
| ) | ||
| effective_threshold = diff_threshold if diff_threshold is not None else 0.0 | ||
| is_changed = diff_pct > effective_threshold | ||
|
sentry[bot] marked this conversation as resolved.
cursor[bot] marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing hash-mismatch safety check described in PRMedium Severity The PR description explicitly states "Add a hash-mismatch safety check: if odiff reports 0 diff but content hashes differ, force the image as changed," and the PR discussion shows a Reviewed by Cursor Bugbot for commit 2fdde05. Configure here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. forgot to update PR description |
||
| if is_changed: | ||
| changed_count += 1 | ||
| else: | ||
| unchanged_count += 1 | ||
|
|
||
| logger.debug( | ||
| "compare_snapshots: %s diff_pct=%.6f threshold=%s is_changed=%s pixels=%d/%d", | ||
| name, | ||
| diff_pct, | ||
| diff_threshold, | ||
| is_changed, | ||
| diff_result.changed_pixels, | ||
| diff_result.total_pixels, | ||
| extra={"head_artifact_id": head_artifact_id}, | ||
| ) | ||
|
|
||
| diff_mask_image_id = f"{head_artifact_id}/{base_artifact_id}/diff/{stem}.png" | ||
|
|
||
| image_results[name] = { | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.