5
5
from typing import Any , Callable , Dict , Generator , Iterable , List , Text , Union , cast
6
6
import six
7
7
8
- from schema_salad .sourceline import SourceLine , cmap
8
+ from schema_salad .sourceline import SourceLine , cmap , strip_dup_lineno , indent , bullets
9
9
import schema_salad .validate as validate
10
10
from .process import shortname
11
11
from .errors import WorkflowException
@@ -153,17 +153,28 @@ def static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs)
153
153
src = warning .src
154
154
sink = warning .sink
155
155
linkMerge = warning .linkMerge
156
- msg = SourceLine (src , "type" ).makeError (
157
- "Source '%s' of type %s may be incompatible"
158
- % (shortname (src ["id" ]), json .dumps (src ["type" ]))) + "\n " + \
159
- SourceLine (sink , "type" ).makeError (
160
- " with sink '%s' of type %s"
161
- % (shortname (sink ["id" ]), json .dumps (sink ["type" ])))
162
- if linkMerge :
163
- msg += "\n " + SourceLine (sink ).makeError (" source has linkMerge method %s" % linkMerge )
164
156
if sink .get ("secondaryFiles" ) and sorted (sink .get ("secondaryFiles" ,[])) != sorted (src .get ("secondaryFiles" ,[])):
165
- msg += "\n " + SourceLine (sink .get ("_tool_entry" , warning .sink ), "secondaryFiles" ).makeError (" sink '%s' expects secondaryFiles %s" % (shortname (sink ["id" ]), sink .get ("secondaryFiles" )))
166
- msg += "\n " + SourceLine (src .get ("_tool_entry" , warning .src ), "secondaryFiles" ).makeError (" source '%s' has secondaryFiles %s" % (shortname (src ["id" ]), src .get ("secondaryFiles" )))
157
+ msg1 = "Sink '%s'" % (shortname (sink ["id" ]))
158
+ msg2 = SourceLine (sink .get ("_tool_entry" , sink ), "secondaryFiles" ).makeError (
159
+ "expects secondaryFiles: %s but" % (sink .get ("secondaryFiles" )))
160
+ if "secondaryFiles" in src :
161
+ msg3 = SourceLine (src , "secondaryFiles" ).makeError (
162
+ "source '%s' has secondaryFiles %s." % (shortname (src ["id" ]), src .get ("secondaryFiles" )))
163
+ else :
164
+ msg3 = SourceLine (src , "id" ).makeError (
165
+ "source '%s' does not include secondaryFiles." % (shortname (src ["id" ])))
166
+ msg4 = SourceLine (src , "id" ).makeError ("To fix, add secondaryFiles: %s to definition of '%s'." % (sink .get ("secondaryFiles" ), shortname (src ["id" ])))
167
+ msg = SourceLine (sink ).makeError ("%s\n %s" % (msg1 , bullets ([msg2 , msg3 , msg4 ], " " )))
168
+ else :
169
+ msg = SourceLine (src , "type" ).makeError (
170
+ "Source '%s' of type %s may be incompatible"
171
+ % (shortname (src ["id" ]), json .dumps (src ["type" ]))) + "\n " + \
172
+ SourceLine (sink , "type" ).makeError (
173
+ " with sink '%s' of type %s"
174
+ % (shortname (sink ["id" ]), json .dumps (sink ["type" ])))
175
+ if linkMerge :
176
+ msg += "\n " + SourceLine (sink ).makeError (" source has linkMerge method %s" % linkMerge )
177
+
167
178
warning_msgs .append (msg )
168
179
for exception in exceptions :
169
180
src = exception .src
@@ -187,8 +198,8 @@ def static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs)
187
198
% shortname (sink ["id" ]))
188
199
exception_msgs .append (msg )
189
200
190
- all_warning_msg = "\n " .join (warning_msgs )
191
- all_exception_msg = "\n " .join (exception_msgs )
201
+ all_warning_msg = strip_dup_lineno ( "\n " .join (warning_msgs ) )
202
+ all_exception_msg = strip_dup_lineno ( "\n " .join (exception_msgs ) )
192
203
193
204
if warnings :
194
205
_logger .warning ("Workflow checker warning:\n %s" % all_warning_msg )
0 commit comments