14723: Adds comments for the changes to StagingPathMapper
authorEric Biagiotti <ebiagiotti@veritasgenetics.com>
Fri, 19 Apr 2019 14:59:06 +0000 (10:59 -0400)
committerEric Biagiotti <ebiagiotti@veritasgenetics.com>
Fri, 19 Apr 2019 14:59:06 +0000 (10:59 -0400)
Also improves executor exception handling mapping logic.

Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti <ebiagiotti@veritasgenetics.com>

sdk/cwl/arvados_cwl/executor.py
sdk/cwl/arvados_cwl/pathmapper.py

index 0e46c53606f4b79694d8bd2acfe240b1195409f8..eeb44dbd7f232193b6e7102f85e3ae905b71dfc9 100644 (file)
@@ -461,7 +461,8 @@ http://doc.arvados.org/install/install-api-server.html#disable_api_methods
                 logger.error("Creating CollectionReader for '%s' '%s': %s", k, v, e)
                 raise
             except IOError as e:
-                logger.warning("While preparing output collection: %s", e)
+                logger.error("While preparing output collection: %s", e)
+                raise
 
         def rewrite(fileobj):
             fileobj["location"] = generatemapper.mapper(fileobj["location"]).target
index f08d7d7b2a67a516118a087ca37f01ea9650c869..56c15a4a4344d6c467c0c7dba74b8ae5b126e280 100644 (file)
@@ -265,6 +265,13 @@ class ArvPathMapper(PathMapper):
 
 
 class StagingPathMapper(PathMapper):
+    # Note that StagingPathMapper internally maps files from target to source.
+    # Specifically, the 'self._pathmap' dict keys are the target location and the
+    # values are 'MapperEnt' named tuples from which we use the 'resolved' attribute
+    # as the file identifier. This makes it possible to map an input file to multiple
+    # target directories. The exception is for file literals, which store the contents of
+    # the file in 'MapperEnt.resolved' and are therefore still mapped from source to target.
+
     _follow_dirs = True
 
     def __init__(self, referenced_files, basedir, stagedir, separateDirs=True):
@@ -307,10 +314,12 @@ class StagingPathMapper(PathMapper):
                     self._pathmap[tgt] = MapperEnt(loc, tgt, "File", staged)
                 self.visitlisting(obj.get("secondaryFiles", []), stagedir, basedir)
 
-    def mapper(self, src):  # type: (Text) -> MapperEnt
+    def mapper(self, src):  # type: (Text) -> MapperEnt.
+        # Overridden to maintain the use case of mapping by source (identifier) to
+        # target regardless of how the map is structured interally.
         def getMapperEnt(src):
             for k,v in viewitems(self._pathmap):
-                if v.resolved == src or (v.type == "CreateFile" and k == src):
+                if (v.type != "CreateFile" and v.resolved == src) or (v.type == "CreateFile" and k == src):
                     return v
 
         if u"#" in src: