Skip to content

[MRG+1] Remove warnings in nested Parallel when the inner Parallel has n_jobs=1 - #406

Merged
aabadie merged 8 commits into
joblib:masterfrom
harishmk:patch-1
Oct 5, 2016
Merged

[MRG+1] Remove warnings in nested Parallel when the inner Parallel has n_jobs=1#406
aabadie merged 8 commits into
joblib:masterfrom
harishmk:patch-1

Conversation

@harishmk

Copy link
Copy Markdown
Contributor

suppress a warning if a daemonic process creates parallel jobs with n_jobs=1
#405

suppress a warning if a daemonic process creates parallel jobs with n_jobs=1
@GaelVaroquaux GaelVaroquaux changed the title Update _parallel_backends.py [MRG+1] Update _parallel_backends.py Oct 1, 2016
@GaelVaroquaux

Copy link
Copy Markdown
Member

LGTM. +1 for merge. Thank you!

@aabadie

aabadie commented Oct 1, 2016

Copy link
Copy Markdown
Contributor

I could reproduce the initial problem mentionned in #405 on Windows with python 2.7. The fix looks good to me.
One thing is missing though : a test. Can you add a test function in joblib/test/test_parallel.py that checks no warning is raised when n_jobs = 1 ?

@lesteve

lesteve commented Oct 5, 2016

Copy link
Copy Markdown
Member

A snippet reproducing the problem:

from joblib import Parallel, delayed


def func():
    return 42


def inner_parallel_func():
    Parallel(n_jobs=1)(delayed(func)() for _ in range(10))

if __name__ == '__main__':
    Parallel(n_jobs=2)(delayed(inner_parallel_func)() for _ in range(10))

@lesteve lesteve changed the title [MRG+1] Update _parallel_backends.py [MRG+1] Remove warnings in nested Parallel when the inner Parallel has n_jobs=1 Oct 5, 2016
Enhance check_subprocess_call to be able to check stderr as well as
stdout.
@lesteve

lesteve commented Oct 5, 2016

Copy link
Copy Markdown
Member

I used this as an excuse to test the recent features of github where PR authors can allow the maintainers to push commits on the PR branch and it seems to work just fine, this is very nifty!

I added a test for the warnings, as you can see from the diff it's not that easy to catch the warnings because they happen in child processes so I reuse and enhanced check_subprocess_call ...

@lesteve

lesteve commented Oct 5, 2016

Copy link
Copy Markdown
Member

@aabadie do you want to have a look at this one before I merge?

Comment thread joblib/test/test_parallel.py Outdated

def parallel_func():
res = Parallel(n_jobs={inner_n_jobs})(delayed(func)() for _ in range(3))
# Needed otherwise some warnings may be missed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not super critical but I think this comment is useless or there's something missing after.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

good point, I tried different ways of flushing stderr to get the number of warnings I expected to no avail so I eventually gave up, except I forgot the comment there.

@aabadie aabadie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I admit adding a test for this was a bit tricky :)

@lesteve

lesteve commented Oct 5, 2016

Copy link
Copy Markdown
Member

I admit adding a test for this was a bit tricky :)

I was quite happy that check_subprocess_call (originally here for checking that a function defined in __main__ can be used inside Parallel, which is very useful in interactive i.e. IPython settings) could be reused without too much pain for the test.

@aabadie

aabadie commented Oct 5, 2016

Copy link
Copy Markdown
Contributor

Merging this one. Thanks @harishmk and @lesteve

@aabadie
aabadie merged commit 5f169bb into joblib:master Oct 5, 2016
lesteve pushed a commit that referenced this pull request Oct 6, 2016
…s n_jobs=1 (#406)

* Update _parallel_backends.py

suppress a warning if a daemonic process creates parallel jobs with n_jobs=1

* Add test for warnings in nested Parallel calls

Enhance check_subprocess_call to be able to check stderr as well as
stdout.
@lesteve

lesteve commented Oct 18, 2016

Copy link
Copy Markdown
Member

@harishmk do you mind giving me your full name ?

I would need it for CHANGES.rst since I am planning to do a bug-fix release of joblib (mainly for scikit-learn 0.18.1) and this PR would be part of it. If I don't hear from you, I'll just use your github user name.

yarikoptic added a commit to yarikoptic/joblib that referenced this pull request Dec 8, 2016
* tag '0.10.3':
  MAINT simplify setup.py
  Bump up version for 0.10.3 release
  Add entries for 0.10.3 release in CHANGES.rst
  [MRG+1] Fix tests when multiprocessing is disabled (joblib#409)
  [MRG+1] Remove warnings in nested Parallel when the inner Parallel has n_jobs=1 (joblib#406)
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.

4 participants