-
Notifications
You must be signed in to change notification settings - Fork 535
Description
Summary
During the last OHBM Hackathon, I found two bugs while working on my project: these arise when one tries to export a given workflow using the respective export()
method (for example assembled combining multiple ones at runtime) to a .py file. I managed to fix them following @satra advices on Mattermost, and I will open a pull request shortly.
Actual behavior
- Any node defined with the
fields
parameter, e.g.:
inputnode = pe.Node(
interface=util.IdentityInterface(fields=['dwi','bvecs','bvals']),
name="inputnode")
will be misrepresented when the workflow is exported using wf.export('wf.py')
, e.g.:
workflow_inputnode = Node(IdentityInterface(mandatory_inputs=True), name="workflow_inputnode")
This issue can be fixed removing the following line (which skips the fields
parameter):
nipype/nipype/pipeline/engine/utils.py
Line 368 in 5116ee2
args = args[1:] |
- Once the previous issue is fixed, the generated Python file cannot be executed because of the following error:
NameError: name \'stream\' is not defined\n'
This is caused by these lines:
nipype/nipype/pipeline/engine/utils.py
Lines 373 to 375 in 5116ee2
filled_args.append( | |
"%s=%s" % (arg, getattr(node.interface, "_%s" % arg)) | |
) |
To correctly handle strings and lists as parameters, @satra suggested to add an if statement:
argval = getattr(node.interface, "_%s" % arg)
if isinstance(argval, str):
filled_args.append(
"%s='%s'" % (arg, argval)
)
else:
filled_args.append(
"%s=%s" % (arg, argval)
)
Expected behavior
It is expected that the export()
method would be able to handle the fields
parameter.
How to replicate the behavior
Any workflow containing an IdentityInterface
node with the fields
parameter will replicate the issues.
Script/Workflow details
NA
Platform details:
NA
Execution environment
Choose one
- Container NA
- My python environment inside container NA
- My python environment outside container 3.7.3