X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/fddf29b24934aacaa2acf0e3c903fba3d9de52de..2512a633dac10249c351b474b80807725246144a:/sdk/cwl/arvados_cwl/pathmapper.py diff --git a/sdk/cwl/arvados_cwl/pathmapper.py b/sdk/cwl/arvados_cwl/pathmapper.py index 64fdfa0d04..448facf776 100644 --- a/sdk/cwl/arvados_cwl/pathmapper.py +++ b/sdk/cwl/arvados_cwl/pathmapper.py @@ -26,7 +26,7 @@ from cwltool.utils import adjustFileObjs, adjustDirObjs from cwltool.stdfsaccess import abspath from cwltool.workflow import WorkflowException -from .http import http_to_keep +from arvados.http_to_keep import http_to_keep logger = logging.getLogger('arvados.cwl-runner') @@ -105,11 +105,18 @@ class ArvPathMapper(PathMapper): raise WorkflowException("Directory literal '%s' is missing `listing`" % src) elif src.startswith("http:") or src.startswith("https:"): try: - keepref = http_to_keep(self.arvrunner.api, self.arvrunner.project_uuid, src) - logger.info("%s is %s", src, keepref) - self._pathmap[src] = MapperEnt(keepref, keepref, srcobj["class"], True) + if self.arvrunner.defer_downloads: + # passthrough, we'll download it later. + self._pathmap[src] = MapperEnt(src, src, srcobj["class"], True) + else: + results = http_to_keep(self.arvrunner.api, self.arvrunner.project_uuid, src, + varying_url_params=self.arvrunner.toplevel_runtimeContext.varying_url_params, + prefer_cached_downloads=self.arvrunner.toplevel_runtimeContext.prefer_cached_downloads) + keepref = "keep:%s/%s" % (results[0], results[1]) + logger.info("%s is %s", src, keepref) + self._pathmap[src] = MapperEnt(keepref, keepref, srcobj["class"], True) except Exception as e: - logger.warning(str(e)) + logger.warning("Download error: %s", e) else: self._pathmap[src] = MapperEnt(src, src, srcobj["class"], True) @@ -141,7 +148,7 @@ class ArvPathMapper(PathMapper): for opt in self.optional_deps: if obj["location"] == opt["location"]: return - raise SourceLine(obj, "location", WorkflowException).makeError("Don't know what to do with '%s'" % obj["location"]) + raise SourceLine(obj, "location", WorkflowException).makeError("Can't handle '%s'" % obj["location"]) def needs_new_collection(self, srcobj, prefix=""): """Check if files need to be staged into a new collection. @@ -156,6 +163,9 @@ class ArvPathMapper(PathMapper): if loc.startswith("_:"): return True + if self.arvrunner.defer_downloads and (loc.startswith("http:") or loc.startswith("https:")): + return False + i = loc.rfind("/") if i > -1: loc_prefix = loc[:i+1]