Skip to content

Commit f78ee23

Browse files
author
Peter Amstutz
committed
Merge branch 'chapmanb-master'
2 parents 30f32f8 + ff7bec3 commit f78ee23

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

cwltool/draft2tool.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import logging
1212
import hashlib
1313
import random
14-
from process import Process, shortname, uniquename
14+
from process import Process, shortname, uniquename, adjustFiles
1515
from errors import WorkflowException
1616
import schema_salad.validate as validate
1717
from aslist import aslist
@@ -200,6 +200,20 @@ def collect_output_ports(self, ports, builder, outdir):
200200
raise WorkflowException("Error validating output record, " + str(e) + "\n in " + json.dumps(ret, indent=4))
201201

202202
def collect_output(self, schema, builder, outdir):
203+
def revmap_file(f):
204+
"""Remap a file back to original path. For Docker, this is outside the container.
205+
206+
Uses either files in the pathmapper or remaps internal output directories
207+
to the external directory.
208+
"""
209+
revmap_f = builder.pathmapper.reversemap(f)
210+
if revmap_f:
211+
return revmap_f[-1]
212+
elif f.startswith(builder.outdir):
213+
return f.replace(builder.outdir, outdir)
214+
else:
215+
return f
216+
203217
r = None
204218
if "outputBinding" in schema:
205219
binding = schema["outputBinding"]
@@ -263,6 +277,8 @@ def collect_output(self, schema, builder, outdir):
263277
r = r[0]
264278

265279
if "secondaryFiles" in schema:
280+
# remap secondaryFiles since we check if they exist
281+
adjustFiles(r, revmap_file)
266282
for primary in aslist(r):
267283
if isinstance(primary, dict):
268284
primary["secondaryFiles"] = []
@@ -285,5 +301,6 @@ def collect_output(self, schema, builder, outdir):
285301
r = {}
286302
for f in schema["type"]["fields"]:
287303
r[shortname(f["name"])] = self.collect_output(f, builder, outdir)
288-
304+
# Ensure files point to local references outside of the run environment
305+
adjustFiles(r, revmap_file)
289306
return r

0 commit comments

Comments
 (0)