[ARVADOS] updated: 26c14294755bc81b2bdca8332350b29b60587d13

Git user git at public.curoverse.com
Mon May 22 16:46:11 EDT 2017


Summary of changes:
 sdk/cwl/arvados_cwl/pathmapper.py  |  3 ++-
 sdk/cwl/tests/test_pathmapper.py   | 13 +++++++++++++
 sdk/python/arvados/commands/run.py |  4 ++--
 3 files changed, 17 insertions(+), 3 deletions(-)

       via  26c14294755bc81b2bdca8332350b29b60587d13 (commit)
      from  8045ed8ae35f2436cb3330de028294654af91c7b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 26c14294755bc81b2bdca8332350b29b60587d13
Author: Jiayong Li <jiayong at math.mit.edu>
Date:   Mon May 22 16:46:02 2017 -0400

    Change statfile in run.py to raise exception when a reference file is not found, and add test in test_pathmapper.py

diff --git a/sdk/cwl/arvados_cwl/pathmapper.py b/sdk/cwl/arvados_cwl/pathmapper.py
index 5e2ee46..052dd5e 100644
--- a/sdk/cwl/arvados_cwl/pathmapper.py
+++ b/sdk/cwl/arvados_cwl/pathmapper.py
@@ -60,7 +60,8 @@ class ArvPathMapper(PathMapper):
                 ab = abspath(src, self.input_basedir)
                 st = arvados.commands.run.statfile("", ab,
                                                    fnPattern="keep:%s/%s",
-                                                   dirPattern="keep:%s/%s")
+                                                   dirPattern="keep:%s/%s",
+                                                   raiseOSError=True)
                 with SourceLine(srcobj, "location", WorkflowException):
                     if isinstance(st, arvados.commands.run.UploadFile):
                         uploadfiles.add((src, ab, st))
diff --git a/sdk/cwl/tests/test_pathmapper.py b/sdk/cwl/tests/test_pathmapper.py
index b39a984..59241b3 100644
--- a/sdk/cwl/tests/test_pathmapper.py
+++ b/sdk/cwl/tests/test_pathmapper.py
@@ -101,3 +101,16 @@ class TestPathmap(unittest.TestCase):
 
         self.assertEqual({'file:tests/hw.py': MapperEnt(resolved='keep:99999999999999999999999999999991+99/hw.py', target='/test/99999999999999999999999999999991+99/hw.py', type='File', staged=True)},
                          p._pathmap)
+
+    @mock.patch("os.stat")
+    def test_missing_file(self, stat):
+        """Test pathmapper handling missing references."""
+        arvrunner = arvados_cwl.ArvCwlRunner(self.api)
+
+        stat.side_effect = OSError(2, "No such file or directory")
+
+        with self.assertRaises(OSError):
+            p = ArvPathMapper(arvrunner, [{
+                "class": "File",
+                "location": "file:tests/hw.py"
+            }], "", "/test/%s", "/test/%s/%s")
diff --git a/sdk/python/arvados/commands/run.py b/sdk/python/arvados/commands/run.py
index d8bb26e..d09d9b8 100644
--- a/sdk/python/arvados/commands/run.py
+++ b/sdk/python/arvados/commands/run.py
@@ -108,7 +108,7 @@ def determine_project(root, current_user):
 # ArvFile() (file already exists in a collection), UploadFile() (file needs to
 # be uploaded to a collection), or simply returns prefix+fn (which yields the
 # original parameter string).
-def statfile(prefix, fn, fnPattern="$(file %s/%s)", dirPattern="$(dir %s/%s/)"):
+def statfile(prefix, fn, fnPattern="$(file %s/%s)", dirPattern="$(dir %s/%s/)", raiseOSError=False):
     absfn = os.path.abspath(fn)
     try:
         st = os.stat(absfn)
@@ -125,7 +125,7 @@ def statfile(prefix, fn, fnPattern="$(file %s/%s)", dirPattern="$(dir %s/%s/)"):
             # trim leading '/' for path prefix test later
             return UploadFile(prefix, absfn[1:])
     except OSError as e:
-        if e.errno == errno.ENOENT:
+        if e.errno == errno.ENOENT and not raiseOSError:
             pass
         else:
             raise

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list