Skip to content

Commit 88cbfa8

Browse files
authored
BUG: Fixing Report multiprocessing (#9109)
* Fixing missing attribute in Report._get_state_params for correct pickling in multiprocessing * Add test to simulate multiprocessing-compatibility of report * add changes to latest.inc [skip github][skip azp] * Fix issues in comments
1 parent bd6dcf7 commit 88cbfa8

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

doc/changes/latest.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ Bugs
201201

202202
- Fix :func:`mne.read_dipole` yielding :class:`mne.Dipole` objects that could not be indexed (:gh:`8963` by `Marijn van Vliet`_)
203203

204+
- Fix bug when setting n_jobs > 1 in :func:`mne.Report.parse_folder` (:gh:`9109` by `Martin Schulz`_)
205+
204206
API changes
205207
~~~~~~~~~~~
206208
- ``mne.read_selection`` has been deprecated in favor of `mne.read_vectorview_selection`. ``mne.read_selection`` will be removed in MNE-Python 0.24 (:gh:`8870` by `Richard Höchenberger`_)

mne/report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ def _get_state_params(self):
16591659
# Note: self._fname is not part of the state
16601660
return (['baseline', 'cov_fname', 'fnames', 'html', 'include',
16611661
'image_format', 'info_fname', 'initial_id', 'raw_psd',
1662-
'_sectionlabels', 'sections', '_sectionvars',
1662+
'_sectionlabels', 'sections', '_sectionvars', 'projs',
16631663
'_sort_sections', 'subjects_dir', 'subject', 'title',
16641664
'verbose'],
16651665
['data_path', 'lang', '_sort'])

mne/tests/test_report.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import base64
88
import copy
99
import glob
10+
import pickle
1011
from io import BytesIO
1112
import os
1213
import os.path as op
@@ -625,4 +626,21 @@ def test_split_files(tmpdir, split_naming):
625626
assert len(report.fnames) == 1
626627

627628

629+
def test_survive_pickle(tmpdir):
630+
"""Testing functionality of Report-Object after pickling."""
631+
tempdir = str(tmpdir)
632+
raw_fname_new = op.join(tempdir, 'temp_raw.fif')
633+
shutil.copyfile(raw_fname, raw_fname_new)
634+
635+
# Pickle report object to simulate multiprocessing with joblib
636+
report = Report(info_fname=raw_fname_new)
637+
pickled_report = pickle.dumps(report)
638+
report = pickle.loads(pickled_report)
639+
640+
# Just test if no errors occur
641+
report.parse_folder(tempdir, render_bem=False)
642+
save_name = op.join(tempdir, 'report.html')
643+
report.save(fname=save_name, open_browser=False)
644+
645+
628646
run_tests_if_main()

0 commit comments

Comments
 (0)