25
25
26
26
27
27
def generate_boutiques_descriptor (
28
- module , interface_name , ignored_template_inputs , docker_image ,
29
- docker_index , verbose , ignore_template_numbers ):
28
+ module , interface_name , ignored_template_inputs , container_image ,
29
+ container_index , container_type , verbose , ignore_template_numbers ):
30
30
'''
31
31
Returns a JSON string containing a JSON Boutiques description of a Nipype interface.
32
32
Arguments:
33
33
* module: module where the Nipype interface is declared.
34
- * interface: Nipype interface.
34
+ * interface_name: name of Nipype interface.
35
35
* ignored_template_inputs: a list of input names that should be ignored in the generation of output path templates.
36
36
* ignore_template_numbers: True if numbers must be ignored in output path creations.
37
+ * container_image: name of the container image where the tool is installed
38
+ * container_index: optional index where the image is available
39
+ * container_type: type of container image (Docker or Singularity)
37
40
'''
38
41
39
42
if not module :
@@ -59,21 +62,23 @@ def generate_boutiques_descriptor(
59
62
tool_desc [
60
63
'description' ] = interface_name + ", as implemented in Nipype (module: " + module_name + ", interface: " + interface_name + ")."
61
64
tool_desc ['inputs' ] = []
62
- tool_desc ['outputs' ] = []
63
- tool_desc ['tool-version' ] = interface .version
64
- tool_desc ['schema-version' ] = '0.2-snapshot'
65
- if docker_image :
66
- tool_desc ['docker-image' ] = docker_image
67
- if docker_index :
68
- tool_desc ['docker-index' ] = docker_index
65
+ tool_desc ['output-files' ] = []
66
+ tool_desc ['tool-version' ] = interface .version if interface .version is not None else 'undefined'
67
+ tool_desc ['schema-version' ] = '0.5'
68
+ if container_image :
69
+ tool_desc ['container-image' ] = {}
70
+ tool_desc ['container-image' ]['image' ] = container_image
71
+ tool_desc ['container-image' ]['type' ] = container_type
72
+ if container_index :
73
+ tool_desc ['container-image' ]['index' ] = container_index
69
74
70
75
# Generates tool inputs
71
76
for name , spec in sorted (interface .inputs .traits (transient = None ).items ()):
72
77
input = get_boutiques_input (inputs , interface , name , spec ,
73
78
ignored_template_inputs , verbose ,
74
79
ignore_template_numbers )
75
80
tool_desc ['inputs' ].append (input )
76
- tool_desc ['command-line' ] += input ['command-line -key' ] + " "
81
+ tool_desc ['command-line' ] += input ['value -key' ] + " "
77
82
if verbose :
78
83
print ("-> Adding input " + input ['name' ])
79
84
@@ -82,13 +87,13 @@ def generate_boutiques_descriptor(
82
87
output = get_boutiques_output (name , interface , tool_desc ['inputs' ],
83
88
verbose )
84
89
if output ['path-template' ] != "" :
85
- tool_desc ['outputs ' ].append (output )
90
+ tool_desc ['output-files ' ].append (output )
86
91
if verbose :
87
92
print ("-> Adding output " + output ['name' ])
88
93
elif verbose :
89
94
print ("xx Skipping output " + output ['name' ] +
90
95
" with no path template." )
91
- if tool_desc ['outputs ' ] == []:
96
+ if tool_desc ['output-files ' ] == []:
92
97
raise Exception ("Tool has no output." )
93
98
94
99
# Removes all temporary values from inputs (otherwise they will
@@ -125,7 +130,7 @@ def get_boutiques_input(inputs, interface, input_name, spec,
125
130
input ['name' ] = input_name .replace ('_' , ' ' ).capitalize ()
126
131
input ['type' ] = get_type_from_spec_info (spec_info )
127
132
input ['list' ] = is_list (spec_info )
128
- input ['command-line -key' ] = "[" + input_name .upper (
133
+ input ['value -key' ] = "[" + input_name .upper (
129
134
) + "]" # assumes that input names are unique
130
135
input ['command-line-flag' ] = ("--%s" % input_name + " " ).strip ()
131
136
input ['tempvalue' ] = None
@@ -178,7 +183,6 @@ def get_boutiques_output(name, interface, tool_inputs, verbose=False):
178
183
output = {}
179
184
output ['name' ] = name .replace ('_' , ' ' ).capitalize ()
180
185
output ['id' ] = name
181
- output ['type' ] = "File"
182
186
output ['path-template' ] = ""
183
187
output [
184
188
'optional' ] = True # no real way to determine if an output is always produced, regardless of the input values.
@@ -201,7 +205,7 @@ def get_boutiques_output(name, interface, tool_inputs, verbose=False):
201
205
if str (input_value ) in output_value :
202
206
output_value = os .path .basename (
203
207
output_value .replace (input_value ,
204
- input ['command-line -key' ])
208
+ input ['value -key' ])
205
209
) # FIXME: this only works if output is written in the current directory
206
210
output ['path-template' ] = os .path .basename (output_value )
207
211
return output
0 commit comments