Skip to content

Fix module-level side effects and global random seeding#39462

Open
Abacn wants to merge 1 commit into
apache:masterfrom
Abacn:fix-leak-random-seed
Open

Fix module-level side effects and global random seeding#39462
Abacn wants to merge 1 commit into
apache:masterfrom
Abacn:fix-leak-random-seed

Conversation

@Abacn

@Abacn Abacn commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

When running unrelated tests, logs show the following lines

2026-07-23T12:28:41.2081273Z Seed value                      1784809694

global random seed has been set accidentally

  • Remove top-level dataset generation, stdout printing, and global seeding from perf_test.py by moving setup logic into PerfTest.setUpClass.

  • Replace calls to global random.seed() in perf_test.py, mean_test.py, quantile_test.py, and stdev_test.py with isolated random.Random instances. This prevents state leakage and unneeded computation when modules are imported during test collection.

Please add a meaningful description for your change here


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

… ML anomaly tests

* Remove top-level dataset generation, stdout printing, and global seeding from perf_test.py by moving setup logic into PerfTest.setUpClass.

* Replace calls to global random.seed() in perf_test.py, mean_test.py, quantile_test.py, and stdev_test.py with isolated random.Random instances.
  This prevents state leakage and unneeded computation when modules are imported during test collection.
@Abacn
Abacn force-pushed the fix-leak-random-seed branch from 30d7e2b to aa29e54 Compare July 23, 2026 17:33
@Abacn

Abacn commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

R: @shunping

@github-actions

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant