Skip to content

[BUG] Need traits>=4.5: unicode string problems #1809

@oesteban

Description

@oesteban

Summary

Traits error checking strings. I think this is duplicated of #1621.

Actual behavior

Traits errors are raised for most of the interfaces, particularly FSL interfaces check and set dictionaries that are prone to reproduce this error.

python -c "from nipype.interfaces.fsl import BET; BET()"

.
.
.

traits.trait_errors.TraitError: Each key of the 'environ' trait of a BETInputSpec instance must be an implementor of, or can be adapted to implement, newbytes or None or an implementor of, or can be adapted to implement, newstr or None, but a value of u'FSLOUTPUTTYPE' <type 'unicode'> was specified.

Expected behavior

No errors

python -c "from nipype.interfaces.fsl import BET; BET()"
170210-18:07:18,599 interface WARNING:
	 FSLOUTPUTTYPE environment variable is not set. Setting FSLOUTPUTTYPE=NIFTI

How to replicate the behavior

pip install "traits==4.4" --user
Collecting traits==4.4
  Downloading traits-4.4.0.tar.gz (226kB)
    100% |████████████████████████████████| 229kB 1.3MB/s 
Building wheels for collected packages: traits
  Running setup.py bdist_wheel for traits
  Stored in directory: /scratch/users/oesteban/.cache/pip/wheels/cc/8e/0f/5a1d87bc760cd08234133ce38b5737859839c94473eacd452d
Successfully built traits
Installing collected packages: traits
  Found existing installation: traits 4.5.0
    Uninstalling traits-4.5.0:
      Successfully uninstalled traits-4.5.0
Successfully installed traits-4.4.0
You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.


[oesteban@sherlock-ln02 login_node ~]$ python -c "from nipype.interfaces.fsl import BET; BET()"
170210-18:11:48,650 interface WARNING:
	 FSLOUTPUTTYPE environment variable is not set. Setting FSLOUTPUTTYPE=NIFTI
Exception occurred in traits notification handler.
Please check the log file for details.
Exception occurred in traits notification handler for object: 
args = <undefined>
center = <undefined>
environ = {}
frac = <undefined>
functional = <undefined>
ignore_exception = False
in_file = <undefined>
mask = <undefined>
mesh = <undefined>
no_output = <undefined>
out_file = <undefined>
outline = <undefined>
output_type = NIFTI
padding = <undefined>
radius = <undefined>
reduce_bias = <undefined>
remove_eyes = <undefined>
robust = <undefined>
skull = <undefined>
surfaces = <undefined>
t2_guided = <undefined>
terminal_output = stream
threshold = <undefined>
vertical_gradient = <undefined>
, trait: output_type, old value: <undefined>, new value: NIFTI
Traceback (most recent call last):
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_notifiers.py", line 520, in _dispatch_change_event
    self.dispatch( handler, *args )
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_notifiers.py", line 483, in dispatch
    handler( *args )
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/nipype/interfaces/fsl/base.py", line 174, in _output_update
    self.inputs.environ.update({'FSLOUTPUTTYPE': self.inputs.output_type})
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_handlers.py", line 3206, in update
    new_dic = self._validate_dic( dic )
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_handlers.py", line 3304, in _validate_dic
    raise excp
TraitError: Each key of the 'environ' trait of a BETInputSpec instance must be an implementor of, or can be adapted to implement, newbytes or None or an implementor of, or can be adapted to implement, newstr or None, but a value of u'FSLOUTPUTTYPE' <type 'unicode'> was specified.
170210-18:11:48,650 traits ERROR:
	 Exception occurred in traits notification handler for object: 
args = <undefined>
center = <undefined>
environ = {}
frac = <undefined>
functional = <undefined>
ignore_exception = False
in_file = <undefined>
mask = <undefined>
mesh = <undefined>
no_output = <undefined>
out_file = <undefined>
outline = <undefined>
output_type = NIFTI
padding = <undefined>
radius = <undefined>
reduce_bias = <undefined>
remove_eyes = <undefined>
robust = <undefined>
skull = <undefined>
surfaces = <undefined>
t2_guided = <undefined>
terminal_output = stream
threshold = <undefined>
vertical_gradient = <undefined>
, trait: output_type, old value: <undefined>, new value: NIFTI
Traceback (most recent call last):
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_notifiers.py", line 520, in _dispatch_change_event
    self.dispatch( handler, *args )
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_notifiers.py", line 483, in dispatch
    handler( *args )
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/nipype/interfaces/fsl/base.py", line 174, in _output_update
    self.inputs.environ.update({'FSLOUTPUTTYPE': self.inputs.output_type})
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_handlers.py", line 3206, in update
    new_dic = self._validate_dic( dic )
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_handlers.py", line 3304, in _validate_dic
    raise excp
TraitError: Each key of the 'environ' trait of a BETInputSpec instance must be an implementor of, or can be adapted to implement, newbytes or None or an implementor of, or can be adapted to implement, newstr or None, but a value of u'FSLOUTPUTTYPE' <type 'unicode'> was specified.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/nipype/interfaces/fsl/base.py", line 168, in __init__
    self.inputs.output_type = self._output_type
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_notifiers.py", line 475, in __call__
    self.notify_listener( self, object, trait_name, old, new )
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_notifiers.py", line 546, in _notify_method_listener
    listener )
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_notifiers.py", line 527, in _dispatch_change_event
    handle_exception( object, trait_name, old, new )
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_notifiers.py", line 520, in _dispatch_change_event
    self.dispatch( handler, *args )
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_notifiers.py", line 483, in dispatch
    handler( *args )
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/nipype/interfaces/fsl/base.py", line 174, in _output_update
    self.inputs.environ.update({'FSLOUTPUTTYPE': self.inputs.output_type})
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_handlers.py", line 3206, in update
    new_dic = self._validate_dic( dic )
  File "/scratch/users/oesteban/.local/lib/python2.7/site-packages/traits/trait_handlers.py", line 3304, in _validate_dic
    raise excp
traits.trait_errors.TraitError: Each key of the 'environ' trait of a BETInputSpec instance must be an implementor of, or can be adapted to implement, newbytes or None or an implementor of, or can be adapted to implement, newstr or None, but a value of u'FSLOUTPUTTYPE' <type 'unicode'> was specified.

Platform details:

{'nibabel_version': '2.0.1', 'networkx_version': '1.10', 'numpy_version': '1.9.3', 'sys_platform': 'linux2', 'sys_version': '2.7.10 |Continuum Analytics, Inc.| (default, Oct 19 2015, 18:04:42) \n[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]', 'commit_source': u'installation', 'commit_hash': u'61978ad', 'pkg_path': '/scratch/users/oesteban/.local/lib/python2.7/site-packages/nipype', 'sys_executable': '/share/PI/russpold/software/anaconda/bin/python', 'traits_version': '4.4.0', 'scipy_version': '0.16.0'}

Fix

Installing traits>=4.5 seems to fix the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions