Skip to content

Commit 9333ff8

Browse files
authored
Merge pull request #2559 from satra/fix/config
fix: propagate explicit workflow config to nodes in a workflow and allow nodes to overwrite
2 parents c9315ca + fea03b8 commit 9333ff8

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

nipype/pipeline/engine/nodes.py

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ def __init__(self,
183183
self._hashed_inputs = None
184184
self._needed_outputs = []
185185
self.needed_outputs = needed_outputs
186+
self.config = None
186187

187188
@property
188189
def interface(self):

nipype/pipeline/engine/tests/test_workflows.py

+44
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# vi: set ft=python sts=4 ts=4 sw=4 et:
44
"""Tests for the engine workflows module
55
"""
6+
from glob import glob
67
import os
78
from shutil import rmtree
89
from itertools import product
@@ -229,3 +230,46 @@ def pick_first(l):
229230
assert os.path.exists(
230231
os.path.join(wf.base_dir, wf.name, n4.name,
231232
'file1.txt')) is keep_inputs
233+
234+
235+
def _test_function4():
236+
raise FileNotFoundError('Generic error')
237+
238+
239+
def test_config_setting(tmpdir):
240+
tmpdir.chdir()
241+
wf = pe.Workflow('config')
242+
wf.base_dir = os.getcwd()
243+
244+
crashdir = os.path.join(os.getcwd(), 'crashdir')
245+
os.mkdir(crashdir)
246+
wf.config = {"execution": {"crashdump_dir": crashdir}}
247+
248+
n1 = pe.Node(niu.Function(function=_test_function4),
249+
name='errorfunc')
250+
wf.add_nodes([n1])
251+
try:
252+
wf.run()
253+
except RuntimeError:
254+
pass
255+
256+
fl = glob(os.path.join(crashdir, 'crash*'))
257+
assert len(fl) == 1
258+
259+
# Now test node overwrite
260+
crashdir2 = os.path.join(os.getcwd(), 'crashdir2')
261+
os.mkdir(crashdir2)
262+
crashdir3 = os.path.join(os.getcwd(), 'crashdir3')
263+
os.mkdir(crashdir3)
264+
wf.config = {"execution": {"crashdump_dir": crashdir3}}
265+
n1.config = {"execution": {"crashdump_dir": crashdir2}}
266+
267+
try:
268+
wf.run()
269+
except RuntimeError:
270+
pass
271+
272+
fl = glob(os.path.join(crashdir2, 'crash*'))
273+
assert len(fl) == 1
274+
fl = glob(os.path.join(crashdir3, 'crash*'))
275+
assert len(fl) == 0

0 commit comments

Comments
 (0)