Skip to content

[ENH] Workflow connect performance #3184

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 4 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@
"name": "De La Vega, Alejandro",
"orcid": "0000-0001-9062-3778"
},
{
"affiliation": "Charite Universitatsmedizin Berlin, Germany",
"name": "Waller, Lea",
"orcid": "0000-0002-3239-6957"
},
{
"affiliation": "MIT",
"name": "Kaczmarzyk, Jakub",
Expand Down
44 changes: 37 additions & 7 deletions nipype/pipeline/engine/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,16 +770,46 @@ def _check_nodes(self, nodes):
def _has_attr(self, parameter, subtype="in"):
"""Checks if a parameter is available as an input or output
"""
hierarchy = parameter.split(".")
attrname = hierarchy.pop()
nodename = hierarchy.pop()

targetworkflow = self
for workflowname in hierarchy:
workflow = None
for node in targetworkflow._graph.nodes():
if node.name == workflowname:
if isinstance(node, Workflow):
workflow = node
break
if workflow is None:
return False
targetworkflow = workflow

targetnode = None
for node in targetworkflow._graph.nodes():
if node.name == nodename:
if isinstance(node, Workflow):
return False
else:
targetnode = node
break
if targetnode is None:
return False

if subtype == "in":
subobject = self.inputs
if not hasattr(targetnode.inputs, attrname):
return False
else:
subobject = self.outputs
attrlist = parameter.split(".")
cur_out = subobject
for attr in attrlist:
if not hasattr(cur_out, attr):
if not hasattr(targetnode.outputs, attrname):
return False
cur_out = getattr(cur_out, attr)

if subtype == "in":
for _, _, d in targetworkflow._graph.in_edges(nbunch=targetnode, data=True):
for cd in d["connect"]:
if attrname == cd[1]:
return False

return True

def _get_parameter_node(self, parameter, subtype="in"):
Expand Down