-
-
Notifications
You must be signed in to change notification settings - Fork 26.2k
CI Run free-threaded test suite with pytest-run-parallel #32023
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
CI Run free-threaded test suite with pytest-run-parallel #32023
Conversation
5e0ee8f
to
47b7d33
Compare
… around _check_stop_words_consistency and avoid a weird side effect
…314t package is on conda-forge
@@ -1329,18 +1329,19 @@ def test_vectorizer_stop_words_inconsistent(): | |||
vec.fit_transform(["hello world"]) | |||
# reset stop word validation | |||
del vec._stop_words_id | |||
assert _check_stop_words_consistency(vec) is False | |||
with pytest.warns(UserWarning, match=message): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual fix, see previous discussion in #32023 (comment).
My guess right now is that the first call _check_stop_words_consistency
was raising a warning and that the next pytest.warns
was sometimes failing because of the default warnings once
strategy plus some unfavourable thread ordering. By putting this inside pytest.warns
we avoid the side-effect and the second warning is always issued.
warnings.simplefilter("error", UserWarning) | ||
vec.fit_transform(["hello world"]) | ||
assert _check_stop_words_consistency(vec) is None | ||
# Only one warning per stop list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an oversight. This puts this block inside the for loop
. Previously, this block was not inside the for loop
so only the last element of the loop was tested ...
# if the parameter is deprecated, don't show it | ||
continue | ||
finally: | ||
warnings.filters.pop(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote this test a bit to rely on warnings.catch_warnings
to reset the warnings filters.
With Python 3.14 free-threading, warning.simplefilter
does not modify warnings.filters
any more inside a warnings.catch_warnings
context, see https://docs.python.org/3.14/whatsnew/3.14.html#concurrent-safe-warnings-control.
…nto free-threaded-pytest-run-parallel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the remaining test_filter_warning_propagates
failure is caused by a bug in joblib/loky, I would just mark it as thread unsafe with an XXX
comment linking to the upstream issue.
Thanks @lesteve! |
Part of #30007
Edit: scipy free-threaded Python 3.14 package was added in conda-forge so the following 2 points are not a problem anymore:
conda-lock has a bug with rc Python versions, I generated the lock-file with a local work-aroundI opened Handle Python release candidates in PyPI solver conda/conda-lock#837 about thisconda-lock does not pick the right free-threaded pip wheel. This is an issue because there is not scipy conda package for free-threaded Python 3.14 yet. I manually tweaked the wheel URL in the lock-file. See free-threaded wheel not picked in pip dependencies conda/conda-lock#754 for the conda-lock bug.