From e1fee37abae47ea261be1fd9b0e3fbdfd17d15bb Mon Sep 17 00:00:00 2001 From: Tristan Glatard Date: Thu, 18 Jun 2015 22:16:19 -1000 Subject: [PATCH 1/2] nipype2boutiques: added support for optional inputs --- nipype/utils/nipype2boutiques.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/nipype/utils/nipype2boutiques.py b/nipype/utils/nipype2boutiques.py index 0be9377935..641626e86a 100644 --- a/nipype/utils/nipype2boutiques.py +++ b/nipype/utils/nipype2boutiques.py @@ -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 @@ -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: From 82bff0bf8a6d96ef45e34527bf99f2f273b0fe78 Mon Sep 17 00:00:00 2001 From: Tristan Glatard Date: Thu, 18 Jun 2015 22:20:08 -1000 Subject: [PATCH 2/2] nipype2boutiques: Boutiques schema is 0.2-snapshot --- nipype/utils/nipype2boutiques.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/utils/nipype2boutiques.py b/nipype/utils/nipype2boutiques.py index 641626e86a..18dc9aca8e 100644 --- a/nipype/utils/nipype2boutiques.py +++ b/nipype/utils/nipype2boutiques.py @@ -98,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):