Skip to content

Commit 4c31b01

Browse files
authored
Merge pull request #894 from common-workflow-language/checksum_safe_size
Checksum safe size & configure PathMapper for final output
2 parents c27774b + 1d4f2b1 commit 4c31b01

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

cwltool/command_line_tool.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -693,16 +693,14 @@ def collect_output(self,
693693
if binding.get("loadContents") or compute_checksum:
694694
contents = f.read(CONTENT_LIMIT)
695695
if binding.get("loadContents"):
696-
files["contents"] = contents.decode("utf-8")
696+
files["contents"] = contents.decode("utf-8")
697697
if compute_checksum:
698698
checksum = hashlib.sha1()
699699
while contents != b"":
700700
checksum.update(contents)
701701
contents = f.read(1024 * 1024)
702702
files["checksum"] = "sha1$%s" % checksum.hexdigest()
703-
f.seek(0, 2)
704-
filesize = f.tell()
705-
files["size"] = filesize
703+
files["size"] = fs_access.size(rfile["location"])
706704

707705
optional = False
708706
single = False

cwltool/context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from .mutation import MutationManager
1414
from .software_requirements import DependenciesConfiguration
1515
from .secrets import SecretStore
16+
from .pathmapper import PathMapper
1617

1718
if TYPE_CHECKING:
1819
from .process import Process
@@ -105,6 +106,7 @@ def __init__(self, kwargs=None):
105106
self.toplevel = False # type: bool
106107
self.mutation_manager = None # type: Optional[MutationManager]
107108
self.make_fs_access = StdFsAccess # type: Callable[[Text], StdFsAccess]
109+
self.path_mapper = PathMapper
108110
self.builder = None # type: Optional[Builder]
109111
self.docker_outdir = "" # type: Text
110112
self.docker_tmpdir = "" # type: Text

cwltool/executors.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ def execute(self,
9393
self.final_output[0] = relocateOutputs(
9494
self.final_output[0], finaloutdir, self.output_dirs,
9595
runtime_context.move_outputs, runtime_context.make_fs_access(""),
96-
getdefault(runtime_context.compute_checksum, True))
96+
getdefault(runtime_context.compute_checksum, True),
97+
path_mapper=runtime_context.path_mapper)
9798

9899
if runtime_context.rm_tmpdir:
99100
cleanIntermediate(self.output_dirs)
@@ -153,10 +154,10 @@ def run_jobs(self,
153154
runtime_context.prov_obj = job.prov_obj
154155
assert runtime_context.prov_obj
155156
process_run_id = \
156-
runtime_context.prov_obj.evaluate(
157-
process, job, job_order_object,
158-
runtime_context.make_fs_access,
159-
runtime_context.research_obj)
157+
runtime_context.prov_obj.evaluate(
158+
process, job, job_order_object,
159+
runtime_context.make_fs_access,
160+
runtime_context.research_obj)
160161
runtime_context = runtime_context.copy()
161162
runtime_context.process_run_id = process_run_id
162163
job.run(runtime_context)

cwltool/process.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ def relocateOutputs(outputObj, # type: Union[Dict[Text, Any],List[Di
273273
source_directories, # type: Set[Text]
274274
action, # type: Text
275275
fs_access, # type: StdFsAccess
276-
compute_checksum=True # type: bool
276+
compute_checksum=True, # type: bool
277+
path_mapper=PathMapper
277278
):
278279
# type: (...) -> Union[Dict[Text, Any], List[Dict[Text, Any]]]
279280
adjustDirObjs(outputObj, functools.partial(get_listing, fs_access, recursive=True))
@@ -323,7 +324,7 @@ def _relocate(src, dst):
323324
shutil.copy2(src, dst)
324325

325326
outfiles = list(_collectDirEntries(outputObj))
326-
pm = PathMapper(outfiles, "", destination_path, separateDirs=False)
327+
pm = path_mapper(outfiles, "", destination_path, separateDirs=False)
327328
stageFiles(pm, stageFunc=_relocate, symLink=False)
328329

329330
def _check_adjust(file):

0 commit comments

Comments
 (0)