Skip to content

Commit e1db94f

Browse files
authored
Merge pull request #688 from wtsi-hgi/fix-687
Fix #687
2 parents addcaa2 + 5e3947c commit e1db94f

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

cwltool/builder.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,34 @@ def bind_input(self, schema, datum, lead_pos=None, tail_pos=None):
9393

9494
# Handle union types
9595
if isinstance(schema["type"], list):
96-
if not value_from_expression:
97-
for t in schema["type"]:
98-
if isinstance(t, (str, Text)) and self.names.has_name(t, ""):
99-
avsc = self.names.get_name(t, "")
100-
elif isinstance(t, dict) and "name" in t and self.names.has_name(t["name"], ""):
101-
avsc = self.names.get_name(t["name"], "")
102-
else:
103-
avsc = AvroSchemaFromJSONData(t, self.names)
104-
if validate.validate(avsc, datum):
105-
schema = copy.deepcopy(schema)
106-
schema["type"] = t
96+
bound_input = False
97+
for t in schema["type"]:
98+
if isinstance(t, (str, Text)) and self.names.has_name(t, ""):
99+
avsc = self.names.get_name(t, "")
100+
elif isinstance(t, dict) and "name" in t and self.names.has_name(t["name"], ""):
101+
avsc = self.names.get_name(t["name"], "")
102+
else:
103+
avsc = AvroSchemaFromJSONData(t, self.names)
104+
if validate.validate(avsc, datum):
105+
schema = copy.deepcopy(schema)
106+
schema["type"] = t
107+
if not value_from_expression:
107108
return self.bind_input(schema, datum, lead_pos=lead_pos, tail_pos=tail_pos)
109+
else:
110+
self.bind_input(schema, datum, lead_pos=lead_pos, tail_pos=tail_pos)
111+
bound_input = True
112+
if not bound_input:
108113
raise validate.ValidationException(u"'%s' is not a valid union %s" % (datum, schema["type"]))
109114
elif isinstance(schema["type"], dict):
110-
if not value_from_expression:
111-
st = copy.deepcopy(schema["type"])
112-
if binding and "inputBinding" not in st and st["type"] == "array" and "itemSeparator" not in binding:
113-
st["inputBinding"] = {}
114-
for k in ("secondaryFiles", "format", "streamable"):
115-
if k in schema:
116-
st[k] = schema[k]
115+
st = copy.deepcopy(schema["type"])
116+
if binding and "inputBinding" not in st and st["type"] == "array" and "itemSeparator" not in binding:
117+
st["inputBinding"] = {}
118+
for k in ("secondaryFiles", "format", "streamable"):
119+
if k in schema:
120+
st[k] = schema[k]
121+
if value_from_expression:
122+
self.bind_input(st, datum, lead_pos=lead_pos, tail_pos=tail_pos)
123+
else:
117124
bindings.extend(self.bind_input(st, datum, lead_pos=lead_pos, tail_pos=tail_pos))
118125
else:
119126
if schema["type"] in self.schemaDefs:

0 commit comments

Comments
 (0)