Skip to content

TST Use _sklearn_version rather than version in pickle tests #27554

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

Merged

Conversation

lesteve
Copy link
Member

@lesteve lesteve commented Oct 9, 2023

Fix #27268.

This PR checks for _sklearn_version rather than version since this is what we put in the pickle.

I saw this test failing in Pyodide see build log

I can reproduce locally inside Pyodide with a failure that happens ~ 2 times out of 1000.

With this PR I can not reproduce the issue running 100,000 times inside Pyodide.

I looked a bit at it and there is some randomness in the pickle (even with normal Python, not Pyodide related). I guess this is due to uninitialized memory in C buffers inside the Cython tree code? The only explanation I can't think of, is that if you are unlucky this unitialized bytes combined to make version and the test fails.

If this explanation is at least partially correct, checking for a longer string makes it less likely that that this test fail.

Full disclosure: this is not the complete story since even inside Pyodide I can not reproduce without using pytest for some reason ... let's just say that I have spent enough time on this already 😉.

@github-actions
Copy link

github-actions bot commented Oct 9, 2023

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 12fee9c. Link to the linter CI: here

@lesteve lesteve changed the title TST Use sklearn_version rather than version in pickle tests TST Use _sklearn_version rather than version in pickle tests Oct 9, 2023
@lesteve lesteve added Quick Review For PRs that are quick to review No Changelog Needed labels Oct 9, 2023
@lorentzenchr lorentzenchr merged commit 19932fc into scikit-learn:main Oct 9, 2023
@lesteve lesteve deleted the sklearn-version-in-pickle-tests branch October 9, 2023 21:10
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Oct 31, 2023
REDVM pushed a commit to REDVM/scikit-learn that referenced this pull request Nov 16, 2023
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.

macOS.pylatest_conda_forge_mkl sometimes fails pickling test
3 participants