Skip to content

Reverse map internal run files to original path #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions cwltool/draft2tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import logging
import hashlib
import random
from process import Process, shortname, uniquename
from process import Process, shortname, uniquename, adjustFiles
from errors import WorkflowException
import schema_salad.validate as validate
from aslist import aslist
Expand Down Expand Up @@ -200,6 +200,20 @@ def collect_output_ports(self, ports, builder, outdir):
raise WorkflowException("Error validating output record, " + str(e) + "\n in " + json.dumps(ret, indent=4))

def collect_output(self, schema, builder, outdir):
def revmap_file(f):
"""Remap a file back to original path. For Docker, this is outside the container.

Uses either files in the pathmapper or remaps internal output directories
to the external directory.
"""
revmap_f = builder.pathmapper.reversemap(f)
if revmap_f:
return revmap_f[-1]
elif f.startswith(builder.outdir):
return f.replace(builder.outdir, outdir)
else:
return f

r = None
if "outputBinding" in schema:
binding = schema["outputBinding"]
Expand Down Expand Up @@ -263,6 +277,8 @@ def collect_output(self, schema, builder, outdir):
r = r[0]

if "secondaryFiles" in schema:
# remap secondaryFiles since we check if they exist
adjustFiles(r, revmap_file)
for primary in aslist(r):
if isinstance(primary, dict):
primary["secondaryFiles"] = []
Expand All @@ -285,5 +301,6 @@ def collect_output(self, schema, builder, outdir):
r = {}
for f in schema["type"]["fields"]:
r[shortname(f["name"])] = self.collect_output(f, builder, outdir)

# Ensure files point to local references outside of the run environment
adjustFiles(r, revmap_file)
return r