Skip to content

Commit

Permalink
Merge pull request #1026 from Ernaldis/multi-processing-bug-fix
Browse files Browse the repository at this point in the history
Multi processing bug fix
  • Loading branch information
guzman-raphael authored May 19, 2022
2 parents e2aa1ad + cd46161 commit 0ff34f2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## Release notes

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

### 0.13.4 -- March, 28 2022
* Add - Allow reading blobs produced by legacy 32-bit compiled mYm library for matlab. PR #995
Expand Down
8 changes: 4 additions & 4 deletions datajoint/autopopulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ def populate(
:param limit: if not None, check at most this many keys
:param max_calls: if not None, populate at most this many keys
:param display_progress: if True, report progress_bar
:param processes: number of processes to use. When set to a large number, then
uses as many as CPU cores
:param processes: number of processes to use. Set to None to use all cores
:param make_kwargs: Keyword arguments which do not affect the result of computation
to be passed down to each ``make()`` call. Computation arguments should be
specified within the pipeline e.g. using a `dj.Lookup` table.
Expand Down Expand Up @@ -211,9 +210,10 @@ def handler(signum, frame):

keys = keys[:max_calls]
nkeys = len(keys)
if not nkeys:
return

if processes > 1:
processes = min(processes, nkeys, mp.cpu_count())
processes = min(*(_ for _ in (processes, nkeys, mp.cpu_count()) if _))

error_list = []
populate_kwargs = dict(
Expand Down
3 changes: 2 additions & 1 deletion docs-parts/intro/Releases_lang1.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
0.13.5 -- May 13, 2022
0.13.5 -- May 19, 2022
----------------------
* Update - Import ABC from collections.abc for Python 3.10 compatibility
* Bugfix - Fix multiprocessing value error (#1013) PR #1026

0.13.4 -- March 28, 2022
----------------------
Expand Down
9 changes: 9 additions & 0 deletions tests/test_autopopulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ def test_multi_processing(self):
== len(self.subject) * self.experiment.fake_experiments_per_subject
)

def test_max_multi_processing(self):
assert self.subject, "root tables are empty"
assert not self.experiment, "table already filled?"
self.experiment.populate(processes=None)
assert (
len(self.experiment)
== len(self.subject) * self.experiment.fake_experiments_per_subject
)

@raises(DataJointError)
def test_allow_insert(self):
assert_true(self.subject, "root tables are empty")
Expand Down

0 comments on commit 0ff34f2

Please sign in to comment.