Skip to content

Support for optional inputs in nipype2boutiques #1122

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

Merged
merged 3 commits into from
Jul 1, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions nipype/utils/nipype2boutiques.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,27 @@ def print_inputs(tool_name, module=None, function=None):
tool_outputs = []

for name, spec in sorted(interface.inputs.traits(transient=None).items()):

#FIXME: optional inputs are not supported yet
if not ( hasattr(spec, "mandatory") and spec.mandatory ):
continue

input = {}

input['name'] = name
type = spec.full_info(inputs, name, None)
if not "an existing file name" in type:
type = "String"
if "an existing file name" in type:
type = "File"
else:
type = "File"
type = "String"
input['type'] = type
input['description'] = "\n".join(interface._get_trait_desc(inputs, name, spec))[len(name)+2:].replace("\n\t\t",". ")
command_line_key = "["+str(input_counter)+"_"+name.upper()+"]"
input_counter += 1
input['command-line-key'] = command_line_key
input['cardinality'] = "Single"
tool_inputs.append(input)

if not ( hasattr(spec, "mandatory") and spec.mandatory ):
command_line+= "--%s"%name+" " # unreachable code as long as optional inputs are not supported
if not ( hasattr(spec, "mandatory") and spec.mandatory ):
input['optional'] = "true"
input['command-line-flag'] = "--%s"%name+" "

tool_inputs.append(input)

command_line+= command_line_key+" "

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

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

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

def main(argv):
Expand Down