Skip to content

Commit 0ff34f2

Browse files
Merge pull request #1026 from Ernaldis/multi-processing-bug-fix
Multi processing bug fix
2 parents e2aa1ad + cd46161 commit 0ff34f2

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## Release notes
22

3-
### 0.13.5 -- May 13, 2022
3+
### 0.13.5 -- May 19, 2022
44
* Update - Import ABC from collections.abc for Python 3.10 compatibility
5+
* Bugfix - Fix multiprocessing value error (#1013) PR #1026
56

67
### 0.13.4 -- March, 28 2022
78
* Add - Allow reading blobs produced by legacy 32-bit compiled mYm library for matlab. PR #995

datajoint/autopopulate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ def populate(
173173
:param limit: if not None, check at most this many keys
174174
:param max_calls: if not None, populate at most this many keys
175175
:param display_progress: if True, report progress_bar
176-
:param processes: number of processes to use. When set to a large number, then
177-
uses as many as CPU cores
176+
:param processes: number of processes to use. Set to None to use all cores
178177
:param make_kwargs: Keyword arguments which do not affect the result of computation
179178
to be passed down to each ``make()`` call. Computation arguments should be
180179
specified within the pipeline e.g. using a `dj.Lookup` table.
@@ -211,9 +210,10 @@ def handler(signum, frame):
211210

212211
keys = keys[:max_calls]
213212
nkeys = len(keys)
213+
if not nkeys:
214+
return
214215

215-
if processes > 1:
216-
processes = min(processes, nkeys, mp.cpu_count())
216+
processes = min(*(_ for _ in (processes, nkeys, mp.cpu_count()) if _))
217217

218218
error_list = []
219219
populate_kwargs = dict(

docs-parts/intro/Releases_lang1.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
0.13.5 -- May 13, 2022
1+
0.13.5 -- May 19, 2022
22
----------------------
33
* Update - Import ABC from collections.abc for Python 3.10 compatibility
4+
* Bugfix - Fix multiprocessing value error (#1013) PR #1026
45

56
0.13.4 -- March 28, 2022
67
----------------------

tests/test_autopopulate.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ def test_multi_processing(self):
6969
== len(self.subject) * self.experiment.fake_experiments_per_subject
7070
)
7171

72+
def test_max_multi_processing(self):
73+
assert self.subject, "root tables are empty"
74+
assert not self.experiment, "table already filled?"
75+
self.experiment.populate(processes=None)
76+
assert (
77+
len(self.experiment)
78+
== len(self.subject) * self.experiment.fake_experiments_per_subject
79+
)
80+
7281
@raises(DataJointError)
7382
def test_allow_insert(self):
7483
assert_true(self.subject, "root tables are empty")

0 commit comments

Comments
 (0)