From: Peter Amstutz Date: Wed, 12 Oct 2016 15:51:03 +0000 (-0400) Subject: 10221: Don't depend on st.keepref from arvados.commands.run.statfile and uploadfile... X-Git-Tag: 1.1.0~666^2 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/807125b8423058d336165f069bf5d618f77845b7?ds=sidebyside 10221: Don't depend on st.keepref from arvados.commands.run.statfile and uploadfile, use file_pattern to construct predictable keep reference. --- diff --git a/sdk/cwl/arvados_cwl/pathmapper.py b/sdk/cwl/arvados_cwl/pathmapper.py index 288397a501..73c81ceb0f 100644 --- a/sdk/cwl/arvados_cwl/pathmapper.py +++ b/sdk/cwl/arvados_cwl/pathmapper.py @@ -37,11 +37,11 @@ class ArvPathMapper(PathMapper): # Local FS ref, may need to be uploaded or may be on keep # mount. ab = abspath(src, self.input_basedir) - st = arvados.commands.run.statfile("", ab, fnPattern=self.file_pattern) + st = arvados.commands.run.statfile("", ab, fnPattern="keep:%s/%s") if isinstance(st, arvados.commands.run.UploadFile): uploadfiles.add((src, ab, st)) elif isinstance(st, arvados.commands.run.ArvFile): - self._pathmap[src] = MapperEnt("keep:"+st.keepref, st.fn, "File") + self._pathmap[src] = MapperEnt(st.fn, self.collection_pattern % st.fn[5:], "File") elif src.startswith("_:"): if "contents" in srcobj: pass @@ -91,12 +91,12 @@ class ArvPathMapper(PathMapper): self.arvrunner.api, dry_run=False, num_retries=self.arvrunner.num_retries, - fnPattern=self.file_pattern, + fnPattern="keep:%s/%s", name=self.name, project=self.arvrunner.project_uuid) for src, ab, st in uploadfiles: - self._pathmap[src] = MapperEnt("keep:" + st.keepref, st.fn, "File") + self._pathmap[src] = MapperEnt(st.fn, self.collection_pattern % st.fn[5:], "File") self.arvrunner.add_uploaded(src, self._pathmap[src]) for srcobj in referenced_files: diff --git a/sdk/cwl/tests/test_pathmapper.py b/sdk/cwl/tests/test_pathmapper.py index 065904daec..7e13066d85 100644 --- a/sdk/cwl/tests/test_pathmapper.py +++ b/sdk/cwl/tests/test_pathmapper.py @@ -18,9 +18,7 @@ from arvados_cwl.pathmapper import ArvPathMapper def upload_mock(files, api, dry_run=False, num_retries=0, project=None, fnPattern="$(file %s/%s)", name=None): pdh = "99999999999999999999999999999991+99" for c in files: - c.fn = os.path.basename(c.fn) - c.keepref = "%s/%s" % (pdh, c.fn) - c.fn = fnPattern % (pdh, c.fn) + c.fn = fnPattern % (pdh, os.path.basename(c.fn)) class TestPathmap(unittest.TestCase): def test_keepref(self): @@ -79,7 +77,6 @@ class TestPathmap(unittest.TestCase): # keep mount, so we can construct a direct reference directly without upload. def statfile_mock(prefix, fn, fnPattern="$(file %s/%s)", dirPattern="$(dir %s/%s/)"): st = arvados.commands.run.ArvFile("", fnPattern % ("99999999999999999999999999999991+99", "hw.py")) - st.keepref = "99999999999999999999999999999991+99/hw.py" return st upl.side_effect = upload_mock