[ARVADOS] created: ffff84bc7c76e3c6581a10559dcfc193768e7b58
Git user
git at public.curoverse.com
Thu Aug 4 10:28:13 EDT 2016
at ffff84bc7c76e3c6581a10559dcfc193768e7b58 (commit)
commit ffff84bc7c76e3c6581a10559dcfc193768e7b58
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Thu Aug 4 10:23:12 2016 -0400
9552: If compute_checksum is true, check if checksum needs to be computed on final output, and add it if missing.
diff --git a/sdk/cwl/arvados_cwl/__init__.py b/sdk/cwl/arvados_cwl/__init__.py
index ce1cc26..99db9f1 100644
--- a/sdk/cwl/arvados_cwl/__init__.py
+++ b/sdk/cwl/arvados_cwl/__init__.py
@@ -8,6 +8,7 @@ import logging
import os
import sys
import threading
+import hashlib
import pkg_resources # part of setuptools
from cwltool.errors import WorkflowException
@@ -24,6 +25,7 @@ from .arvtool import ArvadosCommandTool
from .fsaccess import CollectionFsAccess
from cwltool.process import shortname, UnsupportedRequirement
+from cwltool.pathmapper import adjustFileObjs
from arvados.api import OrderedJsonModel
logger = logging.getLogger('arvados.cwl-runner')
@@ -225,6 +227,19 @@ class ArvCwlRunner(object):
if self.final_output is None:
raise WorkflowException("Workflow did not return a result.")
+ if kwargs.get("compute_checksum"):
+ def compute_checksums(fileobj):
+ if "checksum" not in fileobj:
+ checksum = hashlib.sha1()
+ with self.fs_access.open(fileobj["location"], "rb") as f:
+ contents = f.read(1024*1024)
+ while contents != "":
+ checksum.update(contents)
+ contents = f.read(1024*1024)
+ fileobj["checksum"] = "sha1$%s" % checksum.hexdigest()
+
+ adjustFileObjs(self.final_output, compute_checksums)
+
return self.final_output
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list