Skip to content

BaseInterface.help() doesn't distinguish between arguments of type T and List(T) #1000

@ischwabacher

Description

@ischwabacher

Here's an example. In this case, input_image is a File(), while transforms is an InputMultiPath(File()).

In [21]: ants.ApplyTransforms.help()
Wraps command **antsApplyTransforms**
...
    [Mandatory]
    input_image: (an existing file name)
        image to apply transformation to (generally a coregistered
        functional)
...
    transforms: (an existing file name)
...

It looks like this is happening in nipype.interfaces.base.BaseInterface._get_trait_desc, which tries to set each input to None and then harvests a description of what it should have been set to from the ensuing exception's info attribute. Unfortunately, this happens:

In [1]: import nipype.interfaces.ants as ants

In [2]: import pdb

In [3]: pdb.run('ants.ApplyTransforms.help()')
> <string>(1)<module>()
(Pdb) b nipype/interfaces/base:740, name in ('input_image', 'transforms')
Breakpoint 1 at /home/schwabacher/.local/lib/python2.6/site-packages/nipype/interfaces/base.py:740
(Pdb) c
> /home/schwabacher/.local/lib/python2.6/site-packages/nipype/interfaces/base.py(740)_get_trait_desc()
-> def_val = ''
(Pdb) p excp
TraitError("The 'input_image' trait of an ApplyTransformsInputSpec instance must be an existing file name, but a value of None <type 'NoneType'> was specified.",)
(Pdb) p excp.info
'an existing file name'
(Pdb) c
> /home/schwabacher/.local/lib/python2.6/site-packages/nipype/interfaces/base.py(740)_get_trait_desc()
-> def_val = ''
(Pdb) p excp
TraitError("Each element of the 'transforms' trait of an ApplyTransformsInputSpec instance must be an existing file name, but a value of None <type 'NoneType'> was specified.",)
(Pdb) p excp.info
'an existing file name'

(The breakpoint is set at line 763 of current master)

I'm not sure how best to handle this, since I'm not optimistic about finding the perfect snippet of text in the traits package, but I hope it doesn't get forgotten in #755.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions