@@ -223,6 +223,22 @@ def fillInDefaults(inputs, job):
223
223
else :
224
224
raise validate .ValidationException ("Missing input parameter `%s`" % shortname (inp ["id" ]))
225
225
226
+
227
+ def avroize_type (field_type , name_prefix = "" ):
228
+ """
229
+ adds missing information to a type so that CWL types are valid in schema_salad.
230
+ """
231
+ if type (field_type ) == list :
232
+ field_type_result = []
233
+ for idx , field_type_item in enumerate (field_type ):
234
+ field_type_result .append (avroize_type (field_type_item , name_prefix + "_" + str (idx )))
235
+ return field_type_result
236
+ elif type (field_type ) == dict and "type" in field_type and field_type ["type" ] == "enum" :
237
+ if "name" not in field_type :
238
+ field_type ["name" ] = name_prefix + "_type_enum"
239
+ return field_type
240
+
241
+
226
242
class Process (object ):
227
243
__metaclass__ = abc .ABCMeta
228
244
@@ -252,7 +268,7 @@ def __init__(self, toolpath_object, **kwargs):
252
268
253
269
if sd :
254
270
sdtypes = sd ["types" ]
255
- av = schema_salad .schema .make_valid_avro (sdtypes , {t ["name" ]: t for t in sdtypes }, set ())
271
+ av = schema_salad .schema .make_valid_avro (sdtypes , {t ["name" ]: t for t in avroize_type ( sdtypes ) }, set ())
256
272
for i in av :
257
273
self .schemaDefs [i ["name" ]] = i
258
274
avro .schema .make_avsc_object (av , self .names )
@@ -278,7 +294,7 @@ def __init__(self, toolpath_object, **kwargs):
278
294
c ["type" ] = ["null" ] + aslist (c ["type" ])
279
295
else :
280
296
c ["type" ] = c ["type" ]
281
-
297
+ c [ "type" ] = avroize_type ( c [ "type" ], c [ "name" ])
282
298
if key == "inputs" :
283
299
self .inputs_record_schema ["fields" ].append (c ) # type: ignore
284
300
elif key == "outputs" :
0 commit comments