@@ -101,6 +101,10 @@ def generate_boutiques_descriptor(
101
101
for input in tool_desc ['inputs' ]:
102
102
del input ['tempvalue' ]
103
103
104
+ # Save descriptor to a file
105
+ with open (interface_name + '.json' , 'w' ) as outfile :
106
+ json .dump (tool_desc , outfile )
107
+
104
108
return json .dumps (tool_desc , indent = 4 , separators = (',' , ': ' ))
105
109
106
110
@@ -128,7 +132,10 @@ def get_boutiques_input(inputs, interface, input_name, spec,
128
132
input = {}
129
133
input ['id' ] = input_name
130
134
input ['name' ] = input_name .replace ('_' , ' ' ).capitalize ()
131
- input ['type' ] = get_type_from_spec_info (spec_info )
135
+
136
+ # Figure out the input type from its handler type
137
+ input ['type' ] = get_type_from_handler_type (spec .handler )
138
+
132
139
input ['list' ] = is_list (spec_info )
133
140
input ['value-key' ] = "[" + input_name .upper (
134
141
) + "]" # assumes that input names are unique
@@ -145,6 +152,14 @@ def get_boutiques_input(inputs, interface, input_name, spec,
145
152
if spec .usedefault :
146
153
input ['default-value' ] = spec .default_value ()[1 ]
147
154
155
+ try :
156
+ value_choices = spec .handler .values
157
+ except AttributeError :
158
+ pass
159
+ else :
160
+ if value_choices is not None :
161
+ input ['value-choices' ] = value_choices
162
+
148
163
# Create unique, temporary value.
149
164
temp_value = must_generate_value (input_name , input ['type' ],
150
165
ignored_template_inputs , spec_info , spec ,
@@ -158,9 +173,9 @@ def get_boutiques_input(inputs, interface, input_name, spec,
158
173
str (tempvalue ))
159
174
160
175
# Now that temp values have been generated, set Boolean types to
161
- # Number (there is no Boolean type in Boutiques)
176
+ # Flag (there is no Boolean type in Boutiques)
162
177
if input ['type' ] == "Boolean" :
163
- input ['type' ] = "Number "
178
+ input ['type' ] = "Flag "
164
179
165
180
return input
166
181
@@ -217,9 +232,16 @@ def get_boutiques_output(name, interface, tool_inputs, verbose=False):
217
232
input ['value-key' ])
218
233
) # FIXME: this only works if output is written in the current directory
219
234
output ['path-template' ] = os .path .basename (output_value )
235
+
236
+ if not output_value :
237
+ # Look for an input with the same name and use this as the path template
238
+ for input in tool_inputs :
239
+ if input ['id' ] == name :
240
+ output ['path-template' ] = input ['value-key' ]
220
241
return output
221
242
222
243
244
+ # TODO remove this once we know get_type_from_handler_type works well
223
245
def get_type_from_spec_info (spec_info ):
224
246
'''
225
247
Returns an input type from the spec info. There must be a better
@@ -235,6 +257,17 @@ def get_type_from_spec_info(spec_info):
235
257
return "String"
236
258
237
259
260
+ def get_type_from_handler_type (handler ):
261
+ handler_type = type (handler ).__name__
262
+ if handler_type == "File" or handler_type == "Directory" :
263
+ return "File"
264
+ elif handler_type == "Int" or handler_type == "Float" :
265
+ return "Number"
266
+ elif handler_type == "Bool" :
267
+ return "Flag"
268
+ else :
269
+ return "String"
270
+
238
271
def is_list (spec_info ):
239
272
'''
240
273
Returns True if the spec info looks like it describes a list
0 commit comments