[Python] Deflake anomaly transform tests - #39669
Draft
bvolpato wants to merge 1 commit into
Draft
Conversation
bvolpato
marked this pull request as draft
August 7, 2026 04:16
bvolpato
force-pushed
the
bvolpato/deflake-anomaly-detectors
branch
from
August 7, 2026 04:33
9ed678a to
1dbdc51
Compare
bvolpato
force-pushed
the
bvolpato/deflake-anomaly-detectors
branch
from
August 7, 2026 05:19
1dbdc51 to
5ba530e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #37779.
RunOneDetectorreshuffles input before scoring. Existing transform tests used online Z-score detectors and matched each example against scores calculated in creation order. Runner scheduling can legally change that order independently for each ensemble branch, changing detector state and scores. This caused the keyed failure reported in #37779 and a new unkeyed failure in Python ML precommit.Replace online Z-score use only in the ensemble tests with a small value detector and deterministic score fields. Original
x1andx2data, expected predictions, and the single-detector Z-score test remain unchanged. Coverage remains for keyed and unkeyed inputs, feature selection, thresholds, ensemble grouping, andAnyVoteaggregation.Reproduction
Forcing one detector branch to consume reversed input reproduces score mismatches before this change. Deterministic score fields remove branch-order dependence from the four ensemble cases.
Testing
./gradlew :sdks:python:test-suites:tox:py313:testPython313 -PpythonVersion=3.13 -Pposargs='apache_beam.ml.anomaly.transforms_test'(12 passed)No
CHANGES.mdentry. Test-only change.