@@ -123,24 +123,30 @@ def _convert_stdstreams_to_files(workflowobj):
123
123
124
124
if isinstance (workflowobj , dict ):
125
125
if workflowobj .get ('class' ) == 'CommandLineTool' :
126
- 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 )
130
- for streamtype in ['stdout' , 'stderr' ]:
131
- if out .get ('type' ) == streamtype :
132
- if 'outputBinding' in out :
133
- raise ValidationException (
134
- "Not allowed to specify outputBinding when"
135
- " using %s shortcut." % streamtype )
136
- if streamtype in workflowobj :
137
- filename = workflowobj [streamtype ]
138
- else :
139
- filename = Text (hashlib .sha1 (json .dumps (workflowobj ,
140
- sort_keys = True ).encode ('utf-8' )).hexdigest ())
141
- workflowobj [streamtype ] = filename
142
- out ['type' ] = 'File'
143
- out ['outputBinding' ] = cmap ({'glob' : filename })
126
+ with SourceLine (workflowobj , "outputs" , ValidationException ,
127
+ _logger .isEnabledFor (logging .DEBUG )):
128
+ outputs = workflowobj .get ('outputs' , [])
129
+ if not isinstance (outputs , CommentedSeq ):
130
+ raise ValidationException ('"outputs" section is not '
131
+ 'valid.' )
132
+ for out in workflowobj .get ('outputs' , []):
133
+ if type (out ) is not CommentedMap :
134
+ raise ValidationException ("Output '{}' is not a "
135
+ "valid OutputParameter." .format (out ))
136
+ for streamtype in ['stdout' , 'stderr' ]:
137
+ if out .get ('type' ) == streamtype :
138
+ if 'outputBinding' in out :
139
+ raise ValidationException (
140
+ "Not allowed to specify outputBinding when"
141
+ " using %s shortcut." % streamtype )
142
+ if streamtype in workflowobj :
143
+ filename = workflowobj [streamtype ]
144
+ else :
145
+ filename = Text (hashlib .sha1 (json .dumps (workflowobj ,
146
+ sort_keys = True ).encode ('utf-8' )).hexdigest ())
147
+ workflowobj [streamtype ] = filename
148
+ out ['type' ] = 'File'
149
+ out ['outputBinding' ] = cmap ({'glob' : filename })
144
150
for inp in workflowobj .get ('inputs' , []):
145
151
if inp .get ('type' ) == 'stdin' :
146
152
if 'inputBinding' in inp :
@@ -219,9 +225,11 @@ def validate_document(document_loader, # type: Loader
219
225
workflowobj ['cwlVersion' ] = metadata ['cwlVersion' ]
220
226
else :
221
227
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." )
228
+ "No cwlVersion found. "
229
+ "Use the following syntax in your CWL document to declare "
230
+ "the version: cwlVersion: <version>.\n "
231
+ "Note: if this is a CWL draft-2 (pre v1.0) document then it "
232
+ "will need to be upgraded first." )
225
233
226
234
if not isinstance (workflowobj ["cwlVersion" ], (str , Text )):
227
235
raise Exception ("'cwlVersion' must be a string, got %s" % type (workflowobj ["cwlVersion" ]))
0 commit comments