Skip to content

Commit 1bef289

Browse files
committed
Merge pull request #1122 from glatard/master
Support for optional inputs in nipype2boutiques
2 parents 5b4bcd7 + 82bff0b commit 1bef289

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

nipype/utils/nipype2boutiques.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,27 @@ def print_inputs(tool_name, module=None, function=None):
4040
tool_outputs = []
4141

4242
for name, spec in sorted(interface.inputs.traits(transient=None).items()):
43-
44-
#FIXME: optional inputs are not supported yet
45-
if not ( hasattr(spec, "mandatory") and spec.mandatory ):
46-
continue
4743

4844
input = {}
45+
4946
input['name'] = name
5047
type = spec.full_info(inputs, name, None)
51-
if not "an existing file name" in type:
52-
type = "String"
48+
if "an existing file name" in type:
49+
type = "File"
5350
else:
54-
type = "File"
51+
type = "String"
5552
input['type'] = type
5653
input['description'] = "\n".join(interface._get_trait_desc(inputs, name, spec))[len(name)+2:].replace("\n\t\t",". ")
5754
command_line_key = "["+str(input_counter)+"_"+name.upper()+"]"
5855
input_counter += 1
5956
input['command-line-key'] = command_line_key
6057
input['cardinality'] = "Single"
61-
tool_inputs.append(input)
62-
63-
if not ( hasattr(spec, "mandatory") and spec.mandatory ):
64-
command_line+= "--%s"%name+" " # unreachable code as long as optional inputs are not supported
58+
if not ( hasattr(spec, "mandatory") and spec.mandatory ):
59+
input['optional'] = "true"
60+
input['command-line-flag'] = "--%s"%name+" "
6561

62+
tool_inputs.append(input)
63+
6664
command_line+= command_line_key+" "
6765

6866
# add value to input so that output names can be generated
@@ -89,8 +87,7 @@ def print_inputs(tool_name, module=None, function=None):
8987
output['value-template'] = os.path.basename(output_value)
9088

9189
output['cardinality'] = "Single"
92-
if output['value-template'] != "": # outputs with no templates would certainly crash.
93-
tool_outputs.append(output)
90+
tool_outputs.append(output)
9491

9592
# remove all temporary file names from inputs
9693
for input in tool_inputs:
@@ -101,7 +98,7 @@ def print_inputs(tool_name, module=None, function=None):
10198
tool_desc['command-line'] = command_line
10299
tool_desc['docker-image'] = 'docker.io/robdimsdale/nipype'
103100
tool_desc['docker-index'] = 'http://index.docker.io'
104-
tool_desc['schema-version'] = '0.1'
101+
tool_desc['schema-version'] = '0.2-snapshot'
105102
print json.dumps(tool_desc, indent=4, separators=(',', ': '))
106103

107104
def main(argv):

0 commit comments

Comments
 (0)