Skip to content

FIX: Detecting and apropriately warning about unconnected duplicatlely nodes #2163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions nipype/pipeline/engine/tests/test_workflows.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""Tests for the engine workflows module
"""
import pytest

from ... import engine as pe
from ....interfaces import utility as niu


def test_duplicate_node_check():

wf = pe.Workflow(name="testidentity")

original_list = [0,1,2,3,4,5,6,7,8,9]

selector1 = pe.Node(niu.Select(), name="selector1")
selector1.inputs.index = original_list[:-1]
selector1.inputs.inlist = original_list
selector2 = pe.Node(niu.Select(), name="selector2")
selector2.inputs.index = original_list[:-2]
selector3 = pe.Node(niu.Select(), name="selector3")
selector3.inputs.index = original_list[:-3]
selector4 = pe.Node(niu.Select(), name="selector3")
selector4.inputs.index = original_list[:-4]

wf_connections = [
(selector1, selector2, [("out","inlist")]),
(selector2, selector3, [("out","inlist")]),
(selector3, selector4, [("out","inlist")]),
]

with pytest.raises(IOError) as excinfo:
wf.connect(wf_connections)
assert 'Duplicate node name "selector3" found.' == str(excinfo.value)
9 changes: 7 additions & 2 deletions nipype/pipeline/engine/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,13 @@ def _check_nodes(self, nodes):
for node in nodes:
if node.name in node_names:
idx = node_names.index(node.name)
if node_lineage[idx] in [node._hierarchy, self.name]:
raise IOError('Duplicate node name %s found.' % node.name)
try:
this_node_lineage = node_lineage[idx]
except IndexError:
raise IOError('Duplicate node name "%s" found.' % node.name)
else:
if this_node_lineage in [node._hierarchy, self.name]:
raise IOError('Duplicate node name "%s" found.' % node.name)
else:
node_names.append(node.name)

Expand Down