Skip to content

Commit a7a54d6

Browse files
committed
create a 'name' field for enum types where missing (#101)
1 parent fbecf5f commit a7a54d6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

cwltool/process.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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" in field_type and field_type["type"] == "enum":
237+
if "name" not in field_type:
238+
field_type["name"] = name_prefix+"_type_enum" # TODO modify this
239+
return field_type
240+
241+
226242
class Process(object):
227243
__metaclass__ = abc.ABCMeta
228244

@@ -278,7 +294,8 @@ 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"])
298+
print c["type"]
282299
if key == "inputs":
283300
self.inputs_record_schema["fields"].append(c) # type: ignore
284301
elif key == "outputs":

0 commit comments

Comments
 (0)