Skip to content

Commit 2b93aaf

Browse files
author
Peter Amstutz
committed
Merge branch 'master' into pack
Conflicts: cwltool/main.py cwltool/process.py
2 parents 55d7071 + d55f6e0 commit 2b93aaf

File tree

7 files changed

+217
-186
lines changed

7 files changed

+217
-186
lines changed

cwltool/draft2tool.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ def run(self, **kwargs): # type: (**Any) -> None
5252
_logger.warn(u"Failed to evaluate expression:\n%s", e, exc_info=(e if kwargs.get('debug') else False))
5353
self.output_callback({}, "permanentFail")
5454

55-
def job(self, joborder, input_basedir, output_callback, **kwargs):
55+
def job(self, joborder, output_callback, **kwargs):
5656
# type: (Dict[str,str], str, Callable[[Any, Any], Any], **Any) -> Generator[ExpressionTool.ExpressionJob, None, None]
57-
builder = self._init_job(joborder, input_basedir, **kwargs)
57+
builder = self._init_job(joborder, **kwargs)
5858

5959
j = ExpressionTool.ExpressionJob()
6060
j.builder = builder
@@ -119,19 +119,19 @@ def __init__(self, toolpath_object, **kwargs):
119119
def makeJobRunner(self): # type: () -> CommandLineJob
120120
return CommandLineJob()
121121

122-
def makePathMapper(self, reffiles, input_basedir, **kwargs):
122+
def makePathMapper(self, reffiles, **kwargs):
123123
# type: (Set[str], str, **Any) -> PathMapper
124124
dockerReq, _ = self.get_requirement("DockerRequirement")
125125
try:
126126
if dockerReq and kwargs.get("use_container"):
127-
return DockerPathMapper(reffiles, input_basedir)
127+
return DockerPathMapper(reffiles, kwargs["basedir"])
128128
else:
129-
return PathMapper(reffiles, input_basedir)
129+
return PathMapper(reffiles, kwargs["basedir"])
130130
except OSError as e:
131131
if e.errno == errno.ENOENT:
132132
raise WorkflowException(u"Missing input file %s" % e)
133133

134-
def job(self, joborder, input_basedir, output_callback, **kwargs):
134+
def job(self, joborder, output_callback, **kwargs):
135135
# type: (Dict[str,str], str, Callable[..., Any], **Any) -> Generator[Union[CommandLineJob, CallbackJob], None, None]
136136

137137
jobname = uniquename(kwargs.get("name", shortname(self.tool.get("id", "job"))))
@@ -140,9 +140,9 @@ def job(self, joborder, input_basedir, output_callback, **kwargs):
140140
cacheargs = kwargs.copy()
141141
cacheargs["outdir"] = "/out"
142142
cacheargs["tmpdir"] = "/tmp"
143-
cachebuilder = self._init_job(joborder, input_basedir, **cacheargs)
143+
cachebuilder = self._init_job(joborder, **cacheargs)
144144
cachebuilder.pathmapper = PathMapper(set((f["path"] for f in cachebuilder.files)),
145-
input_basedir)
145+
kwargs["basedir"])
146146

147147
cmdline = flatten(map(cachebuilder.generate_arg, cachebuilder.bindings))
148148
(docker_req, docker_is_req) = self.get_requirement("DockerRequirement")
@@ -198,7 +198,7 @@ def rm_pending_output_callback(output_callback, jobcachepending,
198198
partial(rm_pending_output_callback, output_callback,
199199
jobcachepending))
200200

201-
builder = self._init_job(joborder, input_basedir, **kwargs)
201+
builder = self._init_job(joborder, **kwargs)
202202

203203
reffiles = set((f["path"] for f in builder.files))
204204

@@ -232,7 +232,7 @@ def rm_pending_output_callback(output_callback, jobcachepending,
232232
if os.path.isabs(j.stdout) or ".." in j.stdout:
233233
raise validate.ValidationException("stdout must be a relative path")
234234

235-
builder.pathmapper = self.makePathMapper(reffiles, input_basedir, **kwargs)
235+
builder.pathmapper = self.makePathMapper(reffiles, **kwargs)
236236
builder.requirements = j.requirements
237237

238238
# map files to assigned path inside a container. We need to also explicitly
@@ -298,7 +298,7 @@ def collect_output_ports(self, ports, builder, outdir):
298298
custom_output = os.path.join(outdir, "cwl.output.json")
299299
if builder.fs_access.exists(custom_output):
300300
with builder.fs_access.open(custom_output, "r") as f:
301-
ret = yaml.load(f)
301+
ret = json.load(f)
302302
_logger.debug(u"Raw output from %s: %s", custom_output, json.dumps(ret, indent=4))
303303
adjustFileObjs(ret, remove_hostfs)
304304
adjustFileObjs(ret,
@@ -338,7 +338,9 @@ def collect_output(self, schema, builder, outdir):
338338
globpatterns.extend(aslist(gb))
339339

340340
for gb in globpatterns:
341-
if gb.startswith("/"):
341+
if gb.startswith(outdir):
342+
gb = gb[len(outdir)+1:]
343+
elif gb.startswith("/"):
342344
raise WorkflowException("glob patterns must not start with '/'")
343345
try:
344346
r.extend([{"path": g, "class": "File", "hostfs": True}

cwltool/factory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ def __init__(self, t, factory): # type: (Process, Factory) -> None
1313
self.factory = factory
1414

1515
def __call__(self, **kwargs): # type: (**Any) -> Union[str,Dict[str,str]]
16-
return self.factory.executor(self.t, kwargs, os.getcwd(), None, **self.factory.execkwargs)
16+
execkwargs = self.factory.execkwargs.copy()
17+
execkwargs["basedir"] = os.getcwd()
18+
return self.factory.executor(self.t, kwargs, **execkwargs)
1719

1820
class Factory(object):
1921
def __init__(self, makeTool=workflow.defaultMakeTool,

cwltool/job.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ def run(self, dry_run=False, pull_image=True, rm_container=True,
7070
# json.dump(self.joborder, fp)
7171

7272
runtime = [] # type: List[unicode]
73-
env = {"TMPDIR": self.tmpdir} # type: Mapping[str,str]
73+
74+
# spec currently says "HOME must be set to the designated output
75+
# directory." but spec might change to designated temp directory.
76+
# env = {"TMPDIR": self.tmpdir, "HOME": self.tmpdir} # type: Mapping[str,str]
77+
env = {"TMPDIR": self.tmpdir, "HOME": self.outdir} # type: Mapping[str,str]
7478

7579
(docker_req, docker_is_req) = get_feature(self, "DockerRequirement")
7680

@@ -112,6 +116,11 @@ def run(self, dry_run=False, pull_image=True, rm_container=True,
112116

113117
runtime.append("--env=TMPDIR=/tmp")
114118

119+
# spec currently says "HOME must be set to the designated output
120+
# directory." but spec might change to designated temp directory.
121+
# runtime.append("--env=HOME=/tmp")
122+
runtime.append("--env=HOME=/var/spool/cwl")
123+
115124
for t,v in self.environment.items():
116125
runtime.append(u"--env=%s=%s" % (t, v))
117126

@@ -140,7 +149,7 @@ def run(self, dry_run=False, pull_image=True, rm_container=True,
140149
_logger.info(u"[job %s] %s$ %s%s%s",
141150
self.name,
142151
self.outdir,
143-
" ".join([shellescape.quote(str(arg)) if shouldquote(str(arg)) else str(arg) for arg in (runtime + self.command_line)]),
152+
" \\\n ".join([shellescape.quote(str(arg)) if shouldquote(str(arg)) else str(arg) for arg in (runtime + self.command_line)]),
144153
u' < %s' % (self.stdin) if self.stdin else '',
145154
u' > %s' % os.path.join(self.outdir, self.stdout) if self.stdout else '')
146155

0 commit comments

Comments
 (0)