X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/988c59f51aa579ce8bf0eab1cc729e05a5ee5631..9f9cf2e1da7233d6b341602faeaa69454b7e201f:/sdk/cwl/arvados_cwl/pathmapper.py diff --git a/sdk/cwl/arvados_cwl/pathmapper.py b/sdk/cwl/arvados_cwl/pathmapper.py index 27e48f1f44..d083b78f5a 100644 --- a/sdk/cwl/arvados_cwl/pathmapper.py +++ b/sdk/cwl/arvados_cwl/pathmapper.py @@ -8,11 +8,13 @@ import uuid import os import urllib +from arvados_cwl.util import get_current_container, get_intermediate_collection_info import arvados.commands.run import arvados.collection from schema_salad.sourceline import SourceLine +from arvados.errors import ApiError from cwltool.pathmapper import PathMapper, MapperEnt, abspath, adjustFileObjs, adjustDirObjs from cwltool.workflow import WorkflowException @@ -42,7 +44,7 @@ class ArvPathMapper(PathMapper): pdh_dirpath = re.compile(r'^keep:[0-9a-f]{32}\+\d+(/.*)?$') def __init__(self, arvrunner, referenced_files, input_basedir, - collection_pattern, file_pattern, name=None, single_collection=False, **kwargs): + collection_pattern, file_pattern, name=None, single_collection=False): self.arvrunner = arvrunner self.input_basedir = input_basedir self.collection_pattern = collection_pattern @@ -153,9 +155,14 @@ class ArvPathMapper(PathMapper): for l in srcobj.get("listing", []): self.addentry(l, c, ".", remap) - check = self.arvrunner.api.collections().list(filters=[["portable_data_hash", "=", c.portable_data_hash()]], limit=1).execute(num_retries=self.arvrunner.num_retries) - if not check["items"]: - c.save_new(owner_uuid=self.arvrunner.project_uuid) + container = get_current_container(self.arvrunner.api, self.arvrunner.num_retries, logger) + info = get_intermediate_collection_info(None, container, self.arvrunner.intermediate_output_ttl) + + c.save_new(name=info["name"], + owner_uuid=self.arvrunner.project_uuid, + ensure_unique_name=True, + trash_at=info["trash_at"], + properties=info["properties"]) ab = self.collection_pattern % c.portable_data_hash() self._pathmap[srcobj["location"]] = MapperEnt("keep:"+c.portable_data_hash(), ab, "Directory", True) @@ -167,9 +174,14 @@ class ArvPathMapper(PathMapper): num_retries=self.arvrunner.num_retries ) self.addentry(srcobj, c, ".", remap) - check = self.arvrunner.api.collections().list(filters=[["portable_data_hash", "=", c.portable_data_hash()]], limit=1).execute(num_retries=self.arvrunner.num_retries) - if not check["items"]: - c.save_new(owner_uuid=self.arvrunner.project_uuid) + container = get_current_container(self.arvrunner.api, self.arvrunner.num_retries, logger) + info = get_intermediate_collection_info(None, container, self.arvrunner.intermediate_output_ttl) + + c.save_new(name=info["name"], + owner_uuid=self.arvrunner.project_uuid, + ensure_unique_name=True, + trash_at=info["trash_at"], + properties=info["properties"]) ab = self.file_pattern % (c.portable_data_hash(), srcobj["basename"]) self._pathmap[srcobj["location"]] = MapperEnt("keep:%s/%s" % (c.portable_data_hash(), srcobj["basename"]), @@ -202,6 +214,7 @@ class ArvPathMapper(PathMapper): else: return None + class StagingPathMapper(PathMapper): _follow_dirs = True