What is the InputSpec of an attribute composed of one or more files?

15 views
Skip to first unread message

Michael

unread,
Aug 19, 2013, 4:45:38 PM8/19/13
to nipy...@googlegroups.com
I would need to implement a command line wrapper for which the arguments of the parameter "-myinputfiles" is a list of files. What is the InputSpec of such an attribute?

When searching before asking the question here, i found two possible forms of InputSpec, as shown below. What would be the best solution?

in_files = traits.List(File(exists=True), argstr='-myinputfiles %s', minlen=1, maxlen=3,
                              desc="A list of input files which can be 1 to 3",
                              mandatory=True)

in_files = InputMultiPath(traits.Either(traits.List(File(exists=True), minlen=2, maxlen=3), File(exists=True)), 
 argstr='-myinputfiles %s',
                              desc='A list of input files which can be 1 to 3',
                              mandatory=True)

cindee

unread,
Aug 19, 2013, 4:54:25 PM8/19/13
to nipy...@googlegroups.com
The main difference is one (your first example) expects a list
['file_a', 'file_b'], or even ['file_a',]

The second example can take a list OR a string (which points to an existing File)
['file_a',]  or 'file_a'

so it depends on what kind of flexibility you want to give the user, 
also....you need to handle the potential different input types in your Interface

so you need to handle just a list of strings pointing to files, (example 1)
or 
a list (of string pointing to files) or simple string input  (example 2)




--
 
---
You received this message because you are subscribed to the Google Groups "NiPy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nipy-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Cindee Madison
Jagust Lab
UC Berkeley
cin...@gmail.com

Michael

unread,
Aug 19, 2013, 5:11:09 PM8/19/13
to nipy...@googlegroups.com
Hi Cindee,

Many thanks for your answer. In the second example do i really need to handle the potential different input types? Wouldn't the syntax argstr='-myinputfiles %s' always generate a command with a list of string no matter if the input is a single file or a list, as shown below? If not is there a syntax to accomplish this purpose?

'file_a':               -myinputfiles file_a
['file_a',]:            -myinputfiles file_a
['file_a', 'file_b']: -myinputfiles file_a file_b

cindee

unread,
Aug 19, 2013, 5:41:08 PM8/19/13
to nipy...@googlegroups.com
Hi Michael, 

you are correct, there should be a structure to parse these different types if inputs.
are you inheriting from another InputSpec class? Generally these are handled properly...

if you get a weird bug, its just a good suggestion of the first place to look (eg make sure your inputs are being parsed properly), its the only reason I bring this up...

--cindee



Reply all
Reply to author
Forward
0 new messages