Skip to content

Commit 89585b6

Browse files
author
radhika
committed
cwltool: compute_checksum updates
1 parent 213d93a commit 89585b6

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

cwltool/draft2tool.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,10 @@ def __init__(self, job, output_callback, cachebuilder, jobcache):
107107

108108
def run(self, **kwargs):
109109
# type: (**Any) -> None
110-
compute_checksum = kwargs.get("compute_checksum")
111-
if compute_checksum == None:
112-
compute_checksum = True
113110
self.output_callback(self.job.collect_output_ports(self.job.tool["outputs"],
114111
self.cachebuilder,
115112
self.outdir,
116-
compute_checksum),
113+
kwargs.get("compute_checksum", True)),
117114
"success")
118115

119116
# map files to assigned path inside a container. We need to also explicitly
@@ -337,12 +334,9 @@ def rm_pending_output_callback(output_callback, jobcachepending,
337334
else:
338335
j.command_line = flatten(map(builder.generate_arg, builder.bindings))
339336

340-
compute_checksum = kwargs.get("compute_checksum")
341-
if compute_checksum == None:
342-
compute_checksum = True
343337
j.pathmapper = builder.pathmapper
344338
j.collect_outputs = partial(
345-
self.collect_output_ports, self.tool["outputs"], builder, compute_checksum=compute_checksum)
339+
self.collect_output_ports, self.tool["outputs"], builder, compute_checksum=kwargs.get("compute_checksum", True))
346340
j.output_callback = output_callback
347341

348342
yield j
@@ -416,20 +410,19 @@ def collect_output(self, schema, builder, outdir, compute_checksum=True):
416410
getListing(builder.fs_access, files)
417411
else:
418412
with builder.fs_access.open(files["location"], "rb") as f:
419-
filesize = 0
420-
contents = f.read(CONTENT_LIMIT)
413+
contents = ""
414+
if binding.get("loadContents") or compute_checksum:
415+
contents = f.read(CONTENT_LIMIT)
421416
if binding.get("loadContents"):
422417
files["contents"] = contents
423418
if compute_checksum:
424419
checksum = hashlib.sha1()
425420
while contents != "":
426421
checksum.update(contents)
427-
filesize += len(contents)
428422
contents = f.read(1024*1024)
429423
files["checksum"] = "sha1$%s" % checksum.hexdigest()
430-
else:
431-
f.seek(0, 2)
432-
filesize = f.tell()
424+
f.seek(0, 2)
425+
filesize = f.tell()
433426
files["size"] = filesize
434427
if "format" in schema:
435428
files["format"] = builder.do_eval(schema["format"], context=files)

0 commit comments

Comments
 (0)