Skip to content

Commit 296b70f

Browse files
authored
V1.0.1 fixes (#485)
* Update snapshot of schema to v1.0.1. * Adjust behavior of `default` to conform to v1.0.1 * Update "path" of files staged to InitialWorkDir to conform to v1.0.1
1 parent c6d7917 commit 296b70f

File tree

140 files changed

+7151
-1041
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+7151
-1041
lines changed

cwltool/draft2tool.py

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ def revmap_file(builder, outdir, f):
109109
if f["location"].startswith("file://"):
110110
path = convert_pathsep_to_unix(uri_file_path(f["location"]))
111111
revmap_f = builder.pathmapper.reversemap(path)
112-
if revmap_f:
113-
f["location"] = revmap_f[1]
112+
if revmap_f and not builder.pathmapper.mapper(revmap_f[0]).type.startswith("Writable"):
113+
f["basename"] = os.path.basename(path)
114+
f["location"] = revmap_f[0]
114115
elif path == builder.outdir:
115116
f["location"] = outdir
116117
elif path.startswith(builder.outdir):
@@ -189,7 +190,7 @@ def makeJobRunner(self, use_container=True): # type: (Optional[bool]) -> JobBas
189190
"dockerPull": default_container
190191
})
191192
dockerReq = self.requirements[0]
192-
193+
193194
if dockerReq and use_container:
194195
return DockerCommandLineJob()
195196
else:
@@ -204,6 +205,17 @@ def makePathMapper(self, reffiles, stagedir, **kwargs):
204205
# type: (List[Any], Text, **Any) -> PathMapper
205206
return PathMapper(reffiles, kwargs["basedir"], stagedir)
206207

208+
def updatePathmap(self, outdir, pathmap, fn):
209+
# type: (Text, PathMapper, Dict) -> None
210+
if "location" in fn:
211+
pathmap.update(fn["location"], pathmap.mapper(fn["location"]).resolved,
212+
os.path.join(outdir, fn["basename"]),
213+
("Writable" if fn.get("writable") else "") + fn["class"], False)
214+
for sf in fn.get("secondaryFiles", []):
215+
self.updatePathmap(outdir, pathmap, sf)
216+
for ls in fn.get("listing", []):
217+
self.updatePathmap(os.path.join(outdir, fn["basename"]), pathmap, ls)
218+
207219
def job(self,
208220
job_order, # type: Dict[Text, Text]
209221
output_callbacks, # type: Callable[[Any, Any], Any]
@@ -328,46 +340,10 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
328340
builder.pathmapper = self.makePathMapper(reffiles, builder.stagedir, **make_path_mapper_kwargs)
329341
builder.requirements = j.requirements
330342

331-
if _logger.isEnabledFor(logging.DEBUG):
332-
_logger.debug(u"[job %s] path mappings is %s", j.name,
333-
json.dumps({p: builder.pathmapper.mapper(p) for p in builder.pathmapper.files()}, indent=4))
334-
335343
_check_adjust = partial(check_adjust, builder)
336344

337345
visit_class([builder.files, builder.bindings], ("File", "Directory"), _check_adjust)
338346

339-
if self.tool.get("stdin"):
340-
with SourceLine(self.tool, "stdin", validate.ValidationException):
341-
j.stdin = builder.do_eval(self.tool["stdin"])
342-
reffiles.append({"class": "File", "path": j.stdin})
343-
344-
if self.tool.get("stderr"):
345-
with SourceLine(self.tool, "stderr", validate.ValidationException):
346-
j.stderr = builder.do_eval(self.tool["stderr"])
347-
if os.path.isabs(j.stderr) or ".." in j.stderr:
348-
raise validate.ValidationException("stderr must be a relative path, got '%s'" % j.stderr)
349-
350-
if self.tool.get("stdout"):
351-
with SourceLine(self.tool, "stdout", validate.ValidationException):
352-
j.stdout = builder.do_eval(self.tool["stdout"])
353-
if os.path.isabs(j.stdout) or ".." in j.stdout or not j.stdout:
354-
raise validate.ValidationException("stdout must be a relative path, got '%s'" % j.stdout)
355-
356-
if _logger.isEnabledFor(logging.DEBUG):
357-
_logger.debug(u"[job %s] command line bindings is %s", j.name, json.dumps(builder.bindings, indent=4))
358-
359-
dockerReq = self.get_requirement("DockerRequirement")[0]
360-
if dockerReq and kwargs.get("use_container"):
361-
out_prefix = kwargs.get("tmp_outdir_prefix")
362-
j.outdir = kwargs.get("outdir") or tempfile.mkdtemp(prefix=out_prefix)
363-
tmpdir_prefix = kwargs.get('tmpdir_prefix')
364-
j.tmpdir = kwargs.get("tmpdir") or tempfile.mkdtemp(prefix=tmpdir_prefix)
365-
j.stagedir = tempfile.mkdtemp(prefix=tmpdir_prefix)
366-
else:
367-
j.outdir = builder.outdir
368-
j.tmpdir = builder.tmpdir
369-
j.stagedir = builder.stagedir
370-
371347
initialWorkdir = self.get_requirement("InitialWorkDirRequirement")[0]
372348
j.generatefiles = {"class": "Directory", "listing": [], "basename": ""}
373349
if initialWorkdir:
@@ -403,6 +379,45 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
403379
t["entry"]["writable"] = t.get("writable")
404380
ls[i] = t["entry"]
405381
j.generatefiles[u"listing"] = ls
382+
for l in ls:
383+
self.updatePathmap(builder.outdir, builder.pathmapper, l)
384+
visit_class([builder.files, builder.bindings], ("File", "Directory"), _check_adjust)
385+
386+
if _logger.isEnabledFor(logging.DEBUG):
387+
_logger.debug(u"[job %s] path mappings is %s", j.name,
388+
json.dumps({p: builder.pathmapper.mapper(p) for p in builder.pathmapper.files()}, indent=4))
389+
390+
if self.tool.get("stdin"):
391+
with SourceLine(self.tool, "stdin", validate.ValidationException):
392+
j.stdin = builder.do_eval(self.tool["stdin"])
393+
reffiles.append({"class": "File", "path": j.stdin})
394+
395+
if self.tool.get("stderr"):
396+
with SourceLine(self.tool, "stderr", validate.ValidationException):
397+
j.stderr = builder.do_eval(self.tool["stderr"])
398+
if os.path.isabs(j.stderr) or ".." in j.stderr:
399+
raise validate.ValidationException("stderr must be a relative path, got '%s'" % j.stderr)
400+
401+
if self.tool.get("stdout"):
402+
with SourceLine(self.tool, "stdout", validate.ValidationException):
403+
j.stdout = builder.do_eval(self.tool["stdout"])
404+
if os.path.isabs(j.stdout) or ".." in j.stdout or not j.stdout:
405+
raise validate.ValidationException("stdout must be a relative path, got '%s'" % j.stdout)
406+
407+
if _logger.isEnabledFor(logging.DEBUG):
408+
_logger.debug(u"[job %s] command line bindings is %s", j.name, json.dumps(builder.bindings, indent=4))
409+
410+
dockerReq = self.get_requirement("DockerRequirement")[0]
411+
if dockerReq and kwargs.get("use_container"):
412+
out_prefix = kwargs.get("tmp_outdir_prefix")
413+
j.outdir = kwargs.get("outdir") or tempfile.mkdtemp(prefix=out_prefix)
414+
tmpdir_prefix = kwargs.get('tmpdir_prefix')
415+
j.tmpdir = kwargs.get("tmpdir") or tempfile.mkdtemp(prefix=tmpdir_prefix)
416+
j.stagedir = tempfile.mkdtemp(prefix=tmpdir_prefix)
417+
else:
418+
j.outdir = builder.outdir
419+
j.tmpdir = builder.tmpdir
420+
j.stagedir = builder.stagedir
406421

407422
inplaceUpdateReq = self.get_requirement("http://commonwl.org/cwltool#InplaceUpdateRequirement")[0]
408423

cwltool/job.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def deref_links(outputs): # type: (Any) -> None
8989
if outputs.get("class") == "File":
9090
st = os.lstat(outputs["path"])
9191
if stat.S_ISLNK(st.st_mode):
92+
outputs["basename"] = os.path.basename(outputs["path"])
9293
outputs["path"] = os.readlink(outputs["path"])
9394
else:
9495
for v in outputs.values():
@@ -147,7 +148,7 @@ def _setup(self): # type: () -> None
147148

148149
for knownfile in self.pathmapper.files():
149150
p = self.pathmapper.mapper(knownfile)
150-
if p.type == "File" and not os.path.isfile(p[0]):
151+
if p.type == "File" and not os.path.isfile(p[0]) and p.staged:
151152
raise WorkflowException(
152153
u"Input file %s (at %s) not found or is not a regular "
153154
"file." % (knownfile, self.pathmapper.mapper(knownfile)[0]))

cwltool/pathmapper.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,6 @@ def reversemap(self, target): # type: (Text) -> Tuple[Text, Text]
249249
if v[1] == target:
250250
return (k, v[0])
251251
return None
252+
253+
def update(self, key, resolved, target, type, stage): # type: (Text, Text, Text, Text, bool) -> None
254+
self._pathmap[key] = MapperEnt(resolved, target, type, stage)

cwltool/process.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from .builder import Builder
3535
from .errors import UnsupportedRequirement, WorkflowException
3636
from .pathmapper import (PathMapper, adjustDirObjs, get_listing,
37-
normalizeFilesDirs, visit_class)
37+
normalizeFilesDirs, visit_class, trim_listing)
3838
from .stdfsaccess import StdFsAccess
3939
from .utils import aslist, get_feature, copytree_with_merge, onWindows
4040

@@ -283,7 +283,7 @@ def moveIt(src, dst):
283283
outfiles = [] # type: List[Dict[Text, Any]]
284284
collectFilesAndDirs(outputObj, outfiles)
285285
pm = PathMapper(outfiles, "", outdir, separateDirs=False)
286-
stageFiles(pm, stageFunc=moveIt,symLink=False)
286+
stageFiles(pm, stageFunc=moveIt, symLink=False)
287287

288288
def _check_adjust(f):
289289
f["location"] = file_uri(pm.mapper(f["location"])[1])
@@ -386,12 +386,13 @@ def fillInDefaults(inputs, job):
386386
# type: (List[Dict[Text, Text]], Dict[Text, Union[Dict[Text, Any], List, Text]]) -> None
387387
for e, inp in enumerate(inputs):
388388
with SourceLine(inputs, e, WorkflowException):
389-
if shortname(inp[u"id"]) in job:
390-
pass
391-
elif shortname(inp[u"id"]) not in job and u"default" in inp:
392-
job[shortname(inp[u"id"])] = copy.copy(inp[u"default"])
393-
elif shortname(inp[u"id"]) not in job and aslist(inp[u"type"])[0] == u"null":
389+
fieldname = shortname(inp[u"id"])
390+
if job.get(fieldname) is not None:
394391
pass
392+
elif job.get(fieldname) is None and u"default" in inp:
393+
job[fieldname] = copy.copy(inp[u"default"])
394+
elif job.get(fieldname) is None and u"null" in aslist(inp[u"type"]):
395+
job[fieldname] = None
395396
else:
396397
raise WorkflowException("Missing required input parameter `%s`" % shortname(inp["id"]))
397398

cwltool/schemas/.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.txt text eol=lf
2+
*.fastq text eol=lf
3+
*.fai text eol=lf
4+
*.fasta text eol=lf

cwltool/schemas/run_test.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ do
3131
-n*)
3232
TEST_N=$arg
3333
;;
34+
-j*)
35+
TEST_J=$arg
36+
;;
3437
-l)
3538
TEST_L=-l
3639
;;
@@ -71,7 +74,7 @@ runtest() {
7174
(cd $DRAFT
7275
cwltest --tool "$1" \
7376
--test=conformance_test_${DRAFT}.yaml ${TEST_N} \
74-
${TEST_L} ${ONLY_TOOLS} ${JUNIT_XML} --basedir ${DRAFT} -- ${EXTRA}
77+
${TEST_L} ${TEST_J} ${ONLY_TOOLS} ${JUNIT_XML} --basedir ${DRAFT} -- ${EXTRA}
7578
)
7679
checkexit
7780
}

cwltool/schemas/site/draft3-deps.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@
88
},
99
{
1010
"basename": "salad",
11-
"location": "_:0600cfcc-4e4b-4213-a821-1009e8a44f5a",
1211
"class": "Directory",
1312
"listing": [
1413
{
1514
"basename": "schema_salad",
16-
"location": "_:1b18d943-4f8f-4c39-80ba-b30d2656d64e",
1715
"class": "Directory",
1816
"listing": [
1917
{
2018
"basename": "metaschema",
21-
"location": "_:ae5f64e3-e9d7-41db-b59e-97c1611182ee",
2219
"class": "Directory",
2320
"listing": [
2421
{

0 commit comments

Comments
 (0)