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

BUG: Fix bug with verbosity #813

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/v1.5.md.inc
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ All users are encouraged to update.
- Fixed bug with parallelization across runs for Maxwell filtering (#761 by @larsoner)
- Fixed bug where head position files were not written with a proper suffix and extension (#761 by @larsoner)
- Fixed bug where default values for `decoding_csp_times` and `decoding_csp_freqs` were not set dynamically based on the config parameters (#779 by @larsoner)
- Fixed bug where the MNE logger verbosity was not respected inside parallel jobs (#813 by @larsoner)
- A number of processing steps erroneously **always** operated on un-cleaned epochs (`sensor/decoding_full_epochs`, `sensor/decoding_time_by_time`, `sensor/decoding_csp`); or operated on un-cleaned epochs (without PTP rejection) if no ICA or SSP was requested (`sensor/ime_frequency`, `sensor/make_cov`) The bug in `sensor/make_cov` could propagate to the source level, as the covariance matrix is used for inverse modeling. (#796 by @hoechenberger)
25 changes: 14 additions & 11 deletions mne_bids_pipeline/_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from types import SimpleNamespace

import joblib
from mne.utils import use_log_level, logger as mne_logger

from ._logging import logger, gen_log_kwargs, _is_testing

Expand Down Expand Up @@ -127,19 +128,21 @@ def get_parallel_backend(exec_params: SimpleNamespace) -> joblib.parallel_backen


def parallel_func(func: Callable, *, exec_params: SimpleNamespace):
if get_parallel_backend_name(exec_params=exec_params) == "loky":
if get_n_jobs(exec_params=exec_params) == 1:
my_func = func
parallel = list
else:
from joblib import Parallel, delayed

parallel = Parallel()
my_func = delayed(func)
else: # Dask
if (
get_parallel_backend_name(exec_params=exec_params) == "loky"
and get_n_jobs(exec_params=exec_params) == 1
):
my_func = func
parallel = list
else: # Dask or n_jobs > 1
from joblib import Parallel, delayed

parallel = Parallel()
my_func = delayed(func)

def run_verbose(*args, verbose=mne_logger.level, **kwargs):
with use_log_level(verbose=verbose):
return func(*args, **kwargs)

my_func = delayed(run_verbose)

return parallel, my_func
Loading