Skip to content

Commit 75a939a

Browse files
author
Anton Khodak
committed
Merge branch 'master' into singularity-support
2 parents a8f8431 + fcd80f9 commit 75a939a

17 files changed

+893
-1131
lines changed

cwltool/builder.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ def generate_arg(self, binding): # type: (Dict[Text,Any]) -> List[Text]
217217

218218
prefix = binding.get("prefix")
219219
sep = binding.get("separate", True)
220+
if prefix is None and not sep:
221+
with SourceLine(binding, "separate", WorkflowException, _logger.isEnabledFor(logging.DEBUG)):
222+
raise WorkflowException("'separate' option can not be specified without prefix")
220223

221224
l = [] # type: List[Dict[Text,Text]]
222225
if isinstance(value, list):
@@ -249,8 +252,8 @@ def generate_arg(self, binding): # type: (Dict[Text,Any]) -> List[Text]
249252

250253
return [a for a in args if a is not None]
251254

252-
def do_eval(self, ex, context=None, pull_image=True, recursive=False):
253-
# type: (Union[Dict[Text, Text], Text], Any, bool, bool) -> Any
255+
def do_eval(self, ex, context=None, pull_image=True, recursive=False, strip_whitespace=True):
256+
# type: (Union[Dict[Text, Text], Text], Any, bool, bool, bool) -> Any
254257
if recursive:
255258
if isinstance(ex, dict):
256259
return {k: self.do_eval(v, context, pull_image, recursive) for k, v in iteritems(ex)}
@@ -265,4 +268,5 @@ def do_eval(self, ex, context=None, pull_image=True, recursive=False):
265268
timeout=self.timeout,
266269
debug=self.debug,
267270
js_console=self.js_console,
268-
force_docker_pull=self.force_docker_pull)
271+
force_docker_pull=self.force_docker_pull,
272+
strip_whitespace=strip_whitespace)

cwltool/command_line_tool.py

Lines changed: 705 additions & 0 deletions
Large diffs are not rendered by default.

cwltool/draft2tool.py

Lines changed: 4 additions & 704 deletions
Large diffs are not rendered by default.

cwltool/executors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def execute(self, t, # type: Process
7171
if self.final_output and self.final_output[0] and finaloutdir:
7272
self.final_output[0] = relocateOutputs(self.final_output[0], finaloutdir,
7373
self.output_dirs, kwargs.get("move_outputs"),
74-
kwargs["make_fs_access"](""))
74+
kwargs["make_fs_access"](""),
75+
kwargs["compute_checksum"])
7576

7677
if kwargs.get("rm_tmpdir"):
7778
cleanIntermediate(self.output_dirs)

cwltool/expression.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,10 @@ def evaluator(ex, jslib, obj, fullJS=False, timeout=None, force_docker_pull=Fals
173173

174174
def interpolate(scan, rootvars,
175175
timeout=None, fullJS=None, jslib="", force_docker_pull=False,
176-
debug=False, js_console=False):
177-
# type: (Text, Dict[Text, Any], int, bool, Union[str, Text], bool, bool, bool) -> JSON
178-
scan = scan.strip()
176+
debug=False, js_console=False, strip_whitespace=True):
177+
# type: (Text, Dict[Text, Any], int, bool, Union[str, Text], bool, bool, bool, bool) -> JSON
178+
if strip_whitespace:
179+
scan = scan.strip()
179180
parts = []
180181
w = scanner(scan)
181182
while w:
@@ -202,8 +203,9 @@ def interpolate(scan, rootvars,
202203

203204

204205
def do_eval(ex, jobinput, requirements, outdir, tmpdir, resources,
205-
context=None, pull_image=True, timeout=None, force_docker_pull=False, debug=False, js_console=False):
206-
# type: (Union[dict, AnyStr], Dict[Text, Union[Dict, List, Text]], List[Dict[Text, Any]], Text, Text, Dict[Text, Union[int, Text]], Any, bool, int, bool, bool, bool) -> Any
206+
context=None, pull_image=True, timeout=None, force_docker_pull=False,
207+
debug=False, js_console=False, strip_whitespace=True):
208+
# type: (Union[dict, AnyStr], Dict[Text, Union[Dict, List, Text]], List[Dict[Text, Any]], Text, Text, Dict[Text, Union[int, Text]], Any, bool, int, bool, bool, bool, bool) -> Any
207209

208210
runtime = copy.copy(resources)
209211
runtime["tmpdir"] = docker_windows_path_adjust(tmpdir)
@@ -231,7 +233,8 @@ def do_eval(ex, jobinput, requirements, outdir, tmpdir, resources,
231233
jslib=jslib,
232234
force_docker_pull=force_docker_pull,
233235
debug=debug,
234-
js_console=js_console)
236+
js_console=js_console,
237+
strip_whitespace=strip_whitespace)
235238

236239
except Exception as e:
237240
raise WorkflowException("Expression evaluation error:\n%s" % e)

cwltool/load_tool.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from avro.schema import Names
2121
from ruamel.yaml.comments import CommentedMap, CommentedSeq
2222
from schema_salad.ref_resolver import ContextType, Fetcher, Loader, file_uri
23-
from schema_salad.sourceline import cmap
23+
from schema_salad.sourceline import cmap, SourceLine
2424
from schema_salad.validate import ValidationException
2525

2626
from . import process, update
@@ -124,6 +124,9 @@ def _convert_stdstreams_to_files(workflowobj):
124124
if isinstance(workflowobj, dict):
125125
if workflowobj.get('class') == 'CommandLineTool':
126126
for out in workflowobj.get('outputs', []):
127+
if type(out) is not CommentedMap:
128+
with SourceLine(workflowobj, "outputs", ValidationException, _logger.isEnabledFor(logging.DEBUG)):
129+
raise ValidationException("Output '%s' is not a valid OutputParameter." % out)
127130
for streamtype in ['stdout', 'stderr']:
128131
if out.get('type') == streamtype:
129132
if 'outputBinding' in out:
@@ -215,9 +218,10 @@ def validate_document(document_loader, # type: Loader
215218
if metadata and 'cwlVersion' in metadata:
216219
workflowobj['cwlVersion'] = metadata['cwlVersion']
217220
else:
218-
raise ValidationException("No cwlVersion found."
219-
"Use the following syntax in your CWL document to declare "
220-
"the version: cwlVersion: <version>")
221+
raise ValidationException(
222+
"No cwlVersion found. "
223+
"Use the following syntax in your CWL document to declare the version: cwlVersion: <version>.\n"
224+
"Note: if this is a CWL draft-2 (pre v1.0) document then it will need to be upgraded first.")
221225

222226
if not isinstance(workflowobj["cwlVersion"], (str, Text)):
223227
raise Exception("'cwlVersion' must be a string, got %s" % type(workflowobj["cwlVersion"]))
@@ -227,16 +231,14 @@ def validate_document(document_loader, # type: Loader
227231
workflowobj["cwlVersion"])
228232
if workflowobj["cwlVersion"] not in list(ALLUPDATES):
229233
# print out all the Supported Versions of cwlVersion
230-
versions = list(ALLUPDATES) # ALLUPDATES is a dict
234+
versions = []
235+
for version in list(ALLUPDATES):
236+
if "dev" in version:
237+
version += " (with --enable-dev flag only)"
238+
versions.append(version)
231239
versions.sort()
232-
raise ValidationException("'cwlVersion' not valid. Supported CWL versions are: \n{}".format("\n".join(versions)))
233-
234-
if workflowobj["cwlVersion"] == "draft-2":
235-
workflowobj = cast(CommentedMap, cmap(update._draft2toDraft3dev1(
236-
workflowobj, document_loader, uri, update_steps=False)))
237-
if "@graph" in workflowobj:
238-
workflowobj["$graph"] = workflowobj["@graph"]
239-
del workflowobj["@graph"]
240+
raise ValidationException("The CWL reference runner no longer supports pre CWL v1.0 documents. "
241+
"Supported versions are: \n{}".format("\n".join(versions)))
240242

241243
(sch_document_loader, avsc_names) = \
242244
process.get_schema(workflowobj["cwlVersion"])[:2]
@@ -257,8 +259,6 @@ def validate_document(document_loader, # type: Loader
257259
raise ValidationException("Workflow must be a dict or list.")
258260

259261
if not new_metadata:
260-
if not isinstance(processobj, dict):
261-
raise ValidationException("Draft-2 workflows must be a dict.")
262262
new_metadata = cast(CommentedMap, cmap(
263263
{"$namespaces": processobj.get("$namespaces", {}),
264264
"$schemas": processobj.get("$schemas", []),

cwltool/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from schema_salad.ref_resolver import Loader, file_uri, uri_file_path
2222
from schema_salad.sourceline import strip_dup_lineno
2323

24-
from . import draft2tool, workflow
24+
from . import command_line_tool, workflow
2525
from .argparser import arg_parser, generate_parser, DEFAULT_TMP_PREFIX
2626
from .cwlrdf import printdot, printrdf
2727
from .errors import UnsupportedRequirement, WorkflowException
@@ -419,7 +419,7 @@ def main(argsl=None, # type: List[str]
419419
arg_parser().print_help()
420420
return 1
421421
if args.relax_path_checks:
422-
draft2tool.ACCEPTLIST_RE = draft2tool.ACCEPTLIST_EN_RELAXED_RE
422+
command_line_tool.ACCEPTLIST_RE = command_line_tool.ACCEPTLIST_EN_RELAXED_RE
423423

424424
if args.ga4gh_tool_registries:
425425
ga4gh_tool_registries[:] = args.ga4gh_tool_registries

cwltool/process.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ def collectFilesAndDirs(obj, out):
256256
collectFilesAndDirs(l, out)
257257

258258

259-
def relocateOutputs(outputObj, outdir, output_dirs, action, fs_access):
260-
# type: (Union[Dict[Text, Any], List[Dict[Text, Any]]], Text, Set[Text], Text, StdFsAccess) -> Union[Dict[Text, Any], List[Dict[Text, Any]]]
259+
def relocateOutputs(outputObj, outdir, output_dirs, action, fs_access, compute_checksum):
260+
# type: (Union[Dict[Text, Any], List[Dict[Text, Any]]], Text, Set[Text], Text, StdFsAccess, bool) -> Union[Dict[Text, Any], List[Dict[Text, Any]]]
261261
adjustDirObjs(outputObj, functools.partial(get_listing, fs_access, recursive=True))
262262

263263
if action not in ("move", "copy"):
@@ -299,8 +299,8 @@ def _check_adjust(f):
299299
return f
300300

301301
visit_class(outputObj, ("File", "Directory"), _check_adjust)
302-
303-
visit_class(outputObj, ("File",), functools.partial(compute_checksums, fs_access))
302+
if compute_checksum:
303+
visit_class(outputObj, ("File",), functools.partial(compute_checksums, fs_access))
304304

305305
# If there are symlinks to intermediate output directories, we want to move
306306
# the real files into the final output location. If a file is linked more than once,

0 commit comments

Comments
 (0)