Skip to content

Commit 1e9b9c1

Browse files
authored
Improve error reporting of file format errors. (#711)
1 parent ac6fbc8 commit 1e9b9c1

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

cwltool/builder.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ def checkFormat(actualFile, inputFormats, ontology):
7676
if not af:
7777
continue
7878
if "format" not in af:
79-
raise validate.ValidationException(u"Missing required 'format' for File %s" % af)
79+
raise validate.ValidationException(u"File has no 'format' defined: %s" % json.dumps(af, indent=4))
8080
for inpf in aslist(inputFormats):
8181
if af["format"] == inpf or formatSubclassOf(af["format"], inpf, ontology, set()):
8282
return
8383
raise validate.ValidationException(
84-
u"Incompatible file format, expected format(s) %s but file object is: %s" % (inputFormats, json.dumps(af, indent=4)))
84+
u"File has an incompatible format: %s" % json.dumps(af, indent=4))
8585

8686
class Builder(object):
8787
def __init__(self): # type: () -> None
@@ -237,7 +237,10 @@ def bind_input(self, schema, datum, lead_pos=None, tail_pos=None, discover_secon
237237
normalizeFilesDirs(datum["secondaryFiles"])
238238

239239
if "format" in schema:
240-
checkFormat(datum, self.do_eval(schema["format"]), self.formatgraph)
240+
try:
241+
checkFormat(datum, self.do_eval(schema["format"]), self.formatgraph)
242+
except validate.ValidationException as ve:
243+
raise WorkflowException("Expected value of '%s' to have format %s but\n %s" % (schema["name"], schema["format"], ve))
241244

242245
def _capture_files(f):
243246
self.files.append(f)

cwltool/executors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from abc import ABCMeta, abstractmethod
77

88
from typing import Dict, Text, Any, Tuple, Set, List
9+
from schema_salad.validate import ValidationException
910

1011
from .builder import Builder
1112
from .errors import WorkflowException
@@ -14,6 +15,7 @@
1415
from .process import relocateOutputs, cleanIntermediate, Process
1516
from . import loghandler
1617

18+
1719
_logger = logging.getLogger("cwltool")
1820

1921
class JobExecutor(object):
@@ -107,7 +109,7 @@ def run_jobs(self,
107109
else:
108110
logger.error("Workflow cannot make any more progress.")
109111
break
110-
except WorkflowException:
112+
except (ValidationException, WorkflowException):
111113
raise
112114
except Exception as e:
113115
logger.exception("Got workflow error")

0 commit comments

Comments
 (0)