Skip to content
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

TST Fix test_nested_parallel_warnings_parent_backend for Python nogil #1394

Merged
merged 2 commits into from
Feb 20, 2023

Conversation

lesteve
Copy link
Member

@lesteve lesteve commented Feb 17, 2023

Another fix for making the test pass with Python nogil

@codecov
Copy link

codecov bot commented Feb 17, 2023

Codecov Report

Base: 93.32% // Head: 94.04% // Increases project coverage by +0.71% 🎉

Coverage data is based on head (18d762c) compared to base (83ba40f).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1394      +/-   ##
==========================================
+ Coverage   93.32%   94.04%   +0.71%     
==========================================
  Files          52       52              
  Lines        7300     7343      +43     
==========================================
+ Hits         6813     6906      +93     
+ Misses        487      437      -50     
Impacted Files Coverage Δ
joblib/test/test_parallel.py 97.06% <100.00%> (+0.24%) ⬆️
joblib/memory.py 95.26% <0.00%> (+0.01%) ⬆️
joblib/test/test_memory.py 98.58% <0.00%> (+0.14%) ⬆️
joblib/parallel.py 96.56% <0.00%> (+0.52%) ⬆️
joblib/test/test_func_inspect.py 91.36% <0.00%> (+0.74%) ⬆️
joblib/_store_backends.py 91.58% <0.00%> (+0.81%) ⬆️
joblib/func_inspect.py 92.43% <0.00%> (+1.17%) ⬆️
joblib/logger.py 86.84% <0.00%> (+1.31%) ⬆️
joblib/_memmapping_reducer.py 95.88% <0.00%> (+1.49%) ⬆️
... and 7 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I confirm that this patch makes the failing tests pass when using nogil.

Thank you, @lesteve.

Comment on lines 210 to 214
# when the outer backend is threading and with nogil, we might see
# more that one warning
warnings_have_the_right_length = (
len(warninfo) >= 1 if getattr(sys.flags, 'nogil', False)
else len(warninfo) == 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When reading this comment, nogil can be thought as a nogil-Cython context, and not as the eponymous fork of CPython.

Does this makes this adaptation slightly clearer?

Suggested change
# when the outer backend is threading and with nogil, we might see
# more that one warning
warnings_have_the_right_length = (
len(warninfo) >= 1 if getattr(sys.flags, 'nogil', False)
else len(warninfo) == 1)
# When the outer backend is threading and when one uses nogil
# (the fork of CPython), we might observe more that one warning.
python_interpreter_is_nogil = getattr(sys.flags, 'nogil', False)
n_warnings = len(warninfo)
warnings_have_the_right_length = (
n_warnings >= 1 if python_interpreter_is_nogil
else n_warnings == 1
)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tweak the wording to use "Python nogil" I guess this is good enough

@lesteve lesteve changed the title TST Fix test_nested_parallel_warnings(parent_backend for Python nogil TST Fix test_nested_parallel_warnings_parent_backend for Python nogil Feb 17, 2023
Copy link
Contributor

@tomMoral tomMoral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thx @lesteve

@tomMoral tomMoral merged commit a4d642d into joblib:master Feb 20, 2023
@lesteve lesteve deleted the nogil-len-warnings branch March 20, 2023 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants