@@ -223,6 +223,22 @@ def fillInDefaults(inputs, job):
223223 else :
224224 raise validate .ValidationException ("Missing input parameter `%s`" % shortname (inp ["id" ]))
225225
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+
226242class Process (object ):
227243 __metaclass__ = abc .ABCMeta
228244
@@ -252,7 +268,7 @@ def __init__(self, toolpath_object, **kwargs):
252268
253269 if sd :
254270 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 ())
256272 for i in av :
257273 self .schemaDefs [i ["name" ]] = i
258274 avro .schema .make_avsc_object (av , self .names )
@@ -278,7 +294,7 @@ def __init__(self, toolpath_object, **kwargs):
278294 c ["type" ] = ["null" ] + aslist (c ["type" ])
279295 else :
280296 c ["type" ] = c ["type" ]
281-
297+ c [ "type" ] = avroize_type ( c [ "type" ], c [ "name" ])
282298 if key == "inputs" :
283299 self .inputs_record_schema ["fields" ].append (c ) # type: ignore
284300 elif key == "outputs" :
0 commit comments