Skip to content

Bunch has no attribute insert (from neurostars) #1690

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

Closed
oesteban opened this issue Oct 24, 2016 · 9 comments
Closed

Bunch has no attribute insert (from neurostars) #1690

oesteban opened this issue Oct 24, 2016 · 9 comments
Labels

Comments

@oesteban
Copy link
Contributor

Just seen this in neurostars:

161023-16:13:46,511 workflow INFO:
         Running: antsApplyTransforms --default-value 0 --input /home/contematto/exp/fmri_pipelines/workdir/bids_preprocess/featpreproc/_subject_id_sub-sid000003_task_id_1back/addmean/mapflow/_addmean0/sub-sid000003_task-1back_run-01_bold_dtype_mcf_mask_smooth_mask_gms_tempfilt_maths.nii.gz --input-image-type 3 --interpolation Linear --output sub-sid000003_task-1back_run-01_bold_dtype_mcf_mask_smooth_mask_gms_tempfilt_maths_trans.nii.gz --reference-image /usr/share/fsl/5.0/data/standard/MNI152_T1_2mm.nii.gz --transform [ /home/contematto/exp/fmri_pipelines/workdir/bids_preprocess/registration/_subject_id_sub-sid000003_task_id_1back/antsRegister/output_Composite.h5, 0 ] --transform [ /home/contematto/exp/fmri_pipelines/workdir/bids_preprocess/registration/_subject_id_sub-sid000003_task_id_1back/convert2itk/affine.txt, 0 ]
161023-16:13:46,512 interface DEBUG:
         default_value_0.0
161023-16:13:46,512 interface DEBUG:
         input_image_/home/contematto/exp/fmri_pipelines/workdir/bids_preprocess/featpreproc/_subject_id_sub-sid000003_task_id_1back/addmean/mapflow/_addmean0/sub-sid000003_task-1back_run-01_bold_dtype_mcf_mask_smooth_mask_gms_tempfilt_maths.nii.gz
161023-16:13:46,512 interface DEBUG:
         input_image_type_3
161023-16:13:46,512 interface DEBUG:
         reference_image_/usr/share/fsl/5.0/data/standard/MNI152_T1_2mm.nii.gz
161023-16:13:46,513 interface DEBUG:
         {'DISPLAY': ':1'}
161023-16:15:40,447 interface DEBUG:
         Not a string literal
161023-16:15:40,511 interface DEBUG:
         Not a string literal
Traceback (most recent call last):
  File "preprocess.py", line 1129, in <module>
    wf.run(args.plugin)
  File "/home/contematto/exp/fmri_pipelines/venv2/local/lib/python2.7/site-packages/nipype/pipeline/engine/workflows.py", line 597, in run
    runner.run(execgraph, updatehash=updatehash, config=self.config)
  File "/home/contematto/exp/fmri_pipelines/venv2/local/lib/python2.7/site-packages/nipype/pipeline/plugins/linear.py", line 39, in run
    node.run(updatehash=updatehash)
  File "/home/contematto/exp/fmri_pipelines/venv2/local/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 394, in run
    self._run_interface()
  File "/home/contematto/exp/fmri_pipelines/venv2/local/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 1306, in _run_interface
    updatehash=updatehash))
  File "/home/contematto/exp/fmri_pipelines/venv2/local/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 1170, in _collate_results
    self._result.runtime.insert(i, None)
AttributeError: 'Bunch' object has no attribute 'insert'
@oesteban oesteban added the bug label Oct 24, 2016
@mvdoc
Copy link
Member

mvdoc commented Oct 24, 2016

@oesteban just following up here instead of on neurostars: if I disable the debug mode, the pipeline seems to execute that node

@mvdoc
Copy link
Member

mvdoc commented Oct 24, 2016

And for reference:

(venv2)contematto@head1 ~/exp/fmri_pipelines (master*) $ python -c "import nipype; print(nipype.__version__)"
0.12.1

@mattcieslak
Copy link
Contributor

Any word on this? I'm also running into it when trying anything that uses a MapNode

@satra
Copy link
Member

satra commented Nov 7, 2016

@mvdoc - any chance you could test this with current master?

@mattcieslak
Copy link
Contributor

I get the same error on 0.13.0-g5e0597b.dev

@satra
Copy link
Member

satra commented Nov 7, 2016

@mattcieslak - thanks for the update. it would really help if you can create a simple example? because we do run many pipelines with mapnodes in our test suite, so we are trying to figure out why we don't see this error.

@mvdoc
Copy link
Member

mvdoc commented Nov 8, 2016

@satra I found something interesting and subtle while writing up a small example. It seems that if there is an error in the pipeline, and config.enable_debug_mode() is set, the pipeline fails with AttributeError: 'Bunch' object has no attribute 'insert'. But if the pipeline exits fine, no such error is thrown. Example below:

This is the small working example

from nipype import MapNode, config
from nipype.interfaces import Function
config.enable_debug_mode()


def myfunction(string):
    return string + 'meh'

node = MapNode(Function(input_names=['string'],
                        output_names=['newstring'],
                        function=myfunction),
               iterfield=['string'],
               name='myfunc')

node.inputs.string = ['string' + str(i) for i in range(3)]
node.run()

And this is the output, running fine with enable_debug_mode set

contematto@talete ~/Documents/experiments_work/pipelines (master*) $ python example-mapnode.py
161107-19:43:37,85 workflow INFO:
         Executing node myfunc in dir: /var/folders/gs/4v1cn8mj4n52qrr9r6xv4ckm0000gn/T/tmp43HUxH/myfunc
161107-19:43:37,97 workflow INFO:
         Executing node _myfunc0 in dir: /var/folders/gs/4v1cn8mj4n52qrr9r6xv4ckm0000gn/T/tmp43HUxH/myfunc/mapflow/_myfunc0
161107-19:43:37,123 workflow INFO:
         Runtime memory and threads stats unavailable
161107-19:43:37,125 workflow INFO:
         Executing node _myfunc1 in dir: /var/folders/gs/4v1cn8mj4n52qrr9r6xv4ckm0000gn/T/tmp43HUxH/myfunc/mapflow/_myfunc1
161107-19:43:37,139 workflow INFO:
         Runtime memory and threads stats unavailable
161107-19:43:37,141 workflow INFO:
         Executing node _myfunc2 in dir: /var/folders/gs/4v1cn8mj4n52qrr9r6xv4ckm0000gn/T/tmp43HUxH/myfunc/mapflow/_myfunc2
161107-19:43:37,154 workflow INFO:
         Runtime memory and threads stats unavailable

Now if I introduce a small error in the code, and run the following code (note the input_names=['WRONG']), it results in the AttributeError:

from nipype import MapNode, config
from nipype.interfaces import Function
config.enable_debug_mode()


def myfunction(string):
    return string + 'meh'

node = MapNode(Function(input_names=['WRONG'],
                        output_names=['newstring'],
                        function=myfunction),
               iterfield=['WRONG'],
               name='myfunc')

node.inputs.WRONG = ['string' + str(i) for i in range(3)]
node.run()

here's the output

contematto@talete ~/Documents/experiments_work/pipelines (master*) $ python example-mapnode.py
161107-19:46:02,754 workflow INFO:
         Executing node myfunc in dir: /var/folders/gs/4v1cn8mj4n52qrr9r6xv4ckm0000gn/T/tmpZUoT2V/myfunc
161107-19:46:02,767 workflow INFO:
         Executing node _myfunc0 in dir: /var/folders/gs/4v1cn8mj4n52qrr9r6xv4ckm0000gn/T/tmpZUoT2V/myfunc/mapflow/_myfunc0
Traceback (most recent call last):
  File "example-mapnode.py", line 16, in <module>
    node.run()
  File "/Users/contematto/anaconda/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 394, in run
    self._run_interface()
  File "/Users/contematto/anaconda/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 1306, in _run_interface
    updatehash=updatehash))
  File "/Users/contematto/anaconda/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 1170, in _collate_results
    self._result.runtime.insert(i, None)
AttributeError: 'Bunch' object has no attribute 'insert'

If I disable the enable_debug_mode(), it pukes and that's it:

contematto@talete ~/Documents/experiments_work/pipelines (master*) $ python example-mapnode.py
161107-19:47:19,859 workflow INFO:
         Executing node myfunc in dir: /var/folders/gs/4v1cn8mj4n52qrr9r6xv4ckm0000gn/T/tmp5fBpWk/myfunc
161107-19:47:19,876 workflow INFO:
         Executing node _myfunc0 in dir: /var/folders/gs/4v1cn8mj4n52qrr9r6xv4ckm0000gn/T/tmp5fBpWk/myfunc/mapflow/_myfunc0
161107-19:47:19,909 workflow INFO:
         Executing node _myfunc1 in dir: /var/folders/gs/4v1cn8mj4n52qrr9r6xv4ckm0000gn/T/tmp5fBpWk/myfunc/mapflow/_myfunc1
161107-19:47:19,919 workflow INFO:
         Executing node _myfunc2 in dir: /var/folders/gs/4v1cn8mj4n52qrr9r6xv4ckm0000gn/T/tmp5fBpWk/myfunc/mapflow/_myfunc2
Traceback (most recent call last):
  File "example-mapnode.py", line 16, in <module>
    node.run()
  File "/Users/contematto/anaconda/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 394, in run
    self._run_interface()
  File "/Users/contematto/anaconda/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 1306, in _run_interface
    updatehash=updatehash))
  File "/Users/contematto/anaconda/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py", line 1211, in _collate_results
    (self.name, '\n'.join(msg)))
Exception: Subnodes of node: myfunc failed:
Subnode 0 failed
Error:
myfunction() got an unexpected keyword argument 'WRONG'
Interface Function failed to run. 
Subnode 1 failed
Error:
myfunction() got an unexpected keyword argument 'WRONG'
Interface Function failed to run. 
Subnode 2 failed
Error:
myfunction() got an unexpected keyword argument 'WRONG'
Interface Function failed to run. 

And for reference, this is with 0.12.1

contematto@talete ~/Documents/experiments_work/pipelines (master*) $ python -c "import nipype; print(nipype.__version__)"
0.12.1

@satra
Copy link
Member

satra commented Nov 8, 2016

@mvdoc - awesome that helps a lot - we need to create a pipeline+mapnode test with an error :) - i'll add this as a test. should be a relatively easy fix.

@mvdoc
Copy link
Member

mvdoc commented Nov 8, 2016

Just run with master and got the same error

contematto@talete ~/Documents/experiments_work/pipelines (master*) $ python -c "import nipype; print(nipype.__version__)"
0.13.0-dev

@satra satra closed this as completed in d7fdb6f Dec 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants