Skip to content

Commit a5e7c67

Browse files
committed
doc: Update MultiProcPlugin.__init__ docstring to explain app_config
1 parent 2c3a4b5 commit a5e7c67

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

niworkflows/engine/plugin.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,16 @@ def __init__(self, pool=None, plugin_args=None):
401401
"""
402402
Initialize the plugin.
403403
404+
If passed a nipreps-style configuration object in `plugin_args["app_config"]`,
405+
the following fields must be present:
406+
407+
app_config.environment.total_memory : :obj:`float`
408+
Memory available to the workflow in gigabytes.
409+
app_config._process_initializer : :obj:`callable`
410+
A function that accepts a file path and returns None, to be run in each worker.
411+
app_config.file_path : :obj:`str`
412+
The path to a file that will be passed to the initializer.
413+
404414
Arguments
405415
---------
406416
pool : :obj:`~concurrent.futures.Executor`

niworkflows/engine/tests/test_plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_plugin_args_noconfig(workflow, caplog):
7575
workflow.run(plugin=MultiProcPlugin(plugin_args={"n_procs": 2, "memory_gb": 0.1}))
7676

7777

78-
def touch_file(file_path):
78+
def touch_file(file_path: str) -> None:
7979
"""Module-level functions play more nicely with multiprocessing."""
8080
with open(file_path, "w") as f:
8181
f.write("flag")
@@ -89,7 +89,7 @@ def test_plugin_app_config(tmp_path, workflow, caplog):
8989
app_config = SimpleNamespace(
9090
environment=SimpleNamespace(total_memory=1),
9191
_process_initializer=touch_file,
92-
file_path=init_flag,
92+
file_path=str(init_flag),
9393
)
9494
caplog.set_level(logging.INFO, logger="nipype.workflow")
9595
workflow.run(

0 commit comments

Comments
 (0)