Skip to content

Commit a46b620

Browse files
author
Peter Amstutz
committed
Refactor fillInDefaults
1 parent 54d7fb5 commit a46b620

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

cwltool/process.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,17 @@ def checkFormat(actualFile, inputFormats, requirements, ontology):
190190
return
191191
raise validate.ValidationException(u"Incompatible file format %s required format(s) %s" % (af["format"], inputFormats))
192192

193+
def fillInDefaults(inputs, job):
194+
for inp in inputs:
195+
if shortname(inp["id"]) in job:
196+
pass
197+
elif shortname(inp["id"]) not in job and "default" in inp:
198+
job[shortname(inp["id"])] = copy.copy(inp["default"])
199+
elif shortname(inp["id"]) not in job and inp["type"][0] == "null":
200+
pass
201+
else:
202+
raise validate.ValidationException("Missing input parameter `%s`" % shortname(inp["id"]))
203+
193204
class Process(object):
194205
__metaclass__ = abc.ABCMeta
195206

@@ -259,10 +270,7 @@ def _init_job(self, joborder, input_basedir, **kwargs):
259270
builder = Builder()
260271
builder.job = copy.deepcopy(joborder)
261272

262-
for i in self.tool["inputs"]:
263-
d = shortname(i["id"])
264-
if d not in builder.job and "default" in i:
265-
builder.job[d] = i["default"]
273+
fillInDefaults(self.tool["inputs"], builder.job)
266274

267275
# Validate job order
268276
try:

0 commit comments

Comments
 (0)