-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from volkamerlab/fix-klifs-parallelization
KLIFS module: RecursionError with parallelization... again!
- Loading branch information
Showing
6 changed files
with
45 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
opencadd/tests/databases/test_klifs_remote_parallelization.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
Tests for opencadd.databases.klifs.remote parallelization! | ||
""" | ||
|
||
from itertools import repeat | ||
from multiprocessing import Pool | ||
|
||
import pytest | ||
|
||
from opencadd.databases.klifs import setup_remote | ||
|
||
# Set local session | ||
REMOTE = setup_remote() | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"klifs_session, structure_klifs_ids, n_cores", | ||
[(REMOTE, [111, 113], 2)], | ||
) | ||
def test_remote_parallelization(klifs_session, structure_klifs_ids, n_cores): | ||
|
||
pool = Pool(processes=n_cores) | ||
|
||
pool.starmap(_parallelize_klifs_session, zip(structure_klifs_ids, repeat(klifs_session))) | ||
pool.close() | ||
pool.join() | ||
|
||
|
||
def _parallelize_klifs_session(structure_klifs_id, klifs_session): | ||
""" | ||
Dummy function that simulates a function that takes the KLIFS session as input; | ||
shall be used in our test where we want to pass a single klifs_session to multiple functions | ||
that are called in a parallelized process. | ||
""" | ||
return klifs_session.structures.by_structure_klifs_id(structure_klifs_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters