X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/27816b602e9da83a2565e6fe8f87f250555b1ba5..3a0aa1db801154916f50b1b299d5100945a3e1df:/sdk/cwl/arvados_cwl/pathmapper.py?ds=inline diff --git a/sdk/cwl/arvados_cwl/pathmapper.py b/sdk/cwl/arvados_cwl/pathmapper.py index 12f7cd7021..fb4ae5ad45 100644 --- a/sdk/cwl/arvados_cwl/pathmapper.py +++ b/sdk/cwl/arvados_cwl/pathmapper.py @@ -1,5 +1,6 @@ import re import logging +import uuid import arvados.commands.run import arvados.collection @@ -123,6 +124,9 @@ class ArvPathMapper(PathMapper): ab = self.file_pattern % (c.portable_data_hash(), srcobj["basename"]) self._pathmap[srcobj["location"]] = MapperEnt(ab, ab, "File") + if srcobj.get("secondaryFiles"): + ab = self.collection_pattern % c.portable_data_hash() + self._pathmap["_:" + unicode(uuid.uuid4())] = MapperEnt(ab, ab, "Directory") for loc, sub in subdirs: ab = self.file_pattern % (c.portable_data_hash(), sub[2:]) self._pathmap[loc] = MapperEnt(ab, ab, "Directory") @@ -136,3 +140,17 @@ class ArvPathMapper(PathMapper): return (target, "keep:" + target[len(self.keepdir)+1:]) else: return super(ArvPathMapper, self).reversemap(target) + +class InitialWorkDirPathMapper(PathMapper): + def setup(self, referenced_files, basedir): + # type: (List[Any], unicode) -> None + + # Go through each file and set the target to its own directory along + # with any secondary files. + stagedir = self.stagedir + for fob in referenced_files: + self.visit(fob, stagedir, basedir) + + for path, (ab, tgt, type) in self._pathmap.items(): + if type in ("File", "Directory") and ab.startswith("keep:"): + self._pathmap[path] = MapperEnt("$(task.keep)/%s" % ab[5:], tgt, type)