Skip to content

Commit 87ef62f

Browse files
committed
make ignore_exception a class attribute
1 parent ba378cb commit 87ef62f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

doc/users/saving_workflows.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ This will create a file "outputtestsave.py" with the following content:
7373
return out
7474

7575
testfunc.inputs.function_str = getsource(testfunc_1)
76-
testfunc.ignore_exception = False
76+
testfunc.interface.ignore_exception = False
7777
testfunc.inputs.in1 = '-sub'
7878
testsave.connect(inode, "a", testfunc, "in1")
7979
# Node: testsave.bet2

nipype/interfaces/base/core.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,14 @@ class BaseInterface(Interface):
170170
references_ = []
171171
resource_monitor = True # Enabled for this interface IFF enabled in the config
172172

173-
def __init__(self, from_file=None, resource_monitor=None, **inputs):
173+
def __init__(self, from_file=None, resource_monitor=None,
174+
ignore_exception=False, **inputs):
174175
if not self.input_spec:
175176
raise Exception(
176177
'No input_spec in class: %s' % self.__class__.__name__)
177178

178179
self.inputs = self.input_spec(**inputs)
180+
self.ignore_exception = ignore_exception
179181

180182
if resource_monitor is not None:
181183
self.resource_monitor = resource_monitor
@@ -470,7 +472,6 @@ def run(self, cwd=None, **inputs):
470472
os.chdir(cwd) # Change to the interface wd
471473

472474
enable_rm = config.resource_monitor and self.resource_monitor
473-
force_raise = not getattr(self.inputs, 'ignore_exception', False)
474475
self.inputs.trait_set(**inputs)
475476
self._check_mandatory_inputs()
476477
self._check_version_requirements(self.inputs)
@@ -530,7 +531,7 @@ def run(self, cwd=None, **inputs):
530531
runtime.traceback_args = ('\n'.join(
531532
['%s' % arg for arg in exc_args]), )
532533

533-
if force_raise:
534+
if not self.ignore_exception:
534535
raise
535536
finally:
536537
# This needs to be done always

0 commit comments

Comments
 (0)