Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion nipype/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
data_dir = os.path.join(temp_folder, "data")
shutil.copytree(NIPYPE_DATADIR, data_dir)


@pytest.fixture(autouse=True)
def add_np(doctest_namespace):
doctest_namespace["np"] = numpy
Expand Down
34 changes: 33 additions & 1 deletion nipype/pipeline/plugins/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""Tests for the engine module
"""
import pytest
from pathlib import Path
import numpy as np
import scipy.sparse as ssp


def test_scipy_sparse():
foo = ssp.lil_matrix(np.eye(3, k=1))
goo = foo.getrowview(0)
Expand Down Expand Up @@ -39,3 +40,34 @@ def func(arg1):

wf.run(plugin='MultiProc')
"""

@pytest.mark.regression
def test_remove_nodes(tmpdir):
import os
import nipype.interfaces.utility as niu
import nipype.pipeline.engine as pe

wf = pe.Workflow(name='test')

def func(arg1):
try:
if arg1 == 2:
raise Exception('arg cannot be ' + str(arg1))
except:
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the goal to fail or not? If not, we can skip the entire try/except block. If so, we should not catch the exception.

return arg1

funkynode = pe.MapNode(niu.Function(function=func, input_names=['arg1'],
output_names=['out']),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant:

funkynode = pe.MapNode(niu.Function(function=func),

Also, is there something intrinsic about the problem and MapNodes? If not, then perhaps just make it a Node, to reduce the scope as small as possible.

iterfield=['arg1'],
name = 'functor')
funkynode.inputs.arg1 = [1,2]

wf.add_nodes([funkynode])
wf.base_dir = tmpdir
wf.config['execution']['remove_node_directories'] = 'true'
wf.config['execution']['stop_on_first_crash'] = 'false'
wf.config['logging']['crashdump_dir'] = tmpdir
res = wf.run(plugin='MultiProc')

assert os.path.isdir(Path(tmpdir)/'test/functor') is False