nipy / nipype

Workflows and interfaces for neuroimaging packages
https://nipype.readthedocs.org/en/latest/
Other
742 stars 523 forks source link

AttributeError when asking for `Workfow.inputs` fields in jupyter notebook #2119

Open djarecka opened 7 years ago

djarecka commented 7 years ago

Summary

I've noticed that I'm getting errors when running first time Worflow.inputs.something within jupyter notebook. The problem doesn't happen when I write a python script, it doesn't happen when I ask first for Workflow.inputs and later Worflow.inputs.something or when print(Worflow.inputs.something). It looks like some weird interaction between jupyter and traits. Want to check if it still happens with traitlets.

How to replicate the behavior

from nipype.workflows.fmri.fsl import create_susan_smooth
susan = create_susan_smooth(separate_masks=False)
susan.inputs.inputnode

Actual behavior

Exception occurred in traits notification handler for object: fwhm = in_files = mask_file = , trait: trait_added, old value: , new value: _ipython_canary_method_should_notexist Traceback (most recent call last): File "/opt/conda/lib/python3.5/site-packages/traits/trait_notifiers.py", line 519, in _dispatch_change_event self.dispatch( handler, args ) File "/opt/conda/lib/python3.5/site-packages/traits/trait_notifiers.py", line 482, in dispatch handler( args ) File "/opt/conda/lib/python3.5/site-packages/nipype/pipeline/engine/workflows.py", line 791, in _set_input object.traits()[name].node.set_input(name, newvalue) AttributeError: 'NoneType' object has no attribute 'set_input'

Expected behavior

No error

Platform details:

nipype/workshops: latest-complete docker image with nipype 0.13.1

djarecka commented 7 years ago

@satra : just confirming that this issue exists in jupyter-lab and jupyter notebook

satra commented 7 years ago

but not in ipython right?

satra commented 7 years ago

so no error in ipython and the error does not happen if you do it a second time in the notebook/lab. so clearly a bug of some kind in the interaction with jupyter, but the bug goes away after the first time.

djarecka commented 7 years ago

actually, in ipython I also have the AtributeError

djarecka commented 7 years ago

the error looks slightly different and gives at the end the proper output:

fwhm = <undefined>
in_files = <undefined>
mask_file = <undefined>

you can try to run in python and in ipython this command: from nipype.workflows.fmri.fsl import create_susan_smooth; susan = create_susan_smooth(separate_masks=False); susan.inputs.inputnode