28
28
cwl_v1_2 .InputRecordField ,
29
29
]
30
30
"""Type union for a CWL v1.x InputRecordSchema object."""
31
+ InputSchema = Union [cwl_v1_0 .InputSchema , cwl_v1_1 .InputSchema , cwl_v1_2 .InputSchema ]
32
+ """Type union for a CWL v1.x InputSchema object."""
31
33
OutputParameter = Union [
32
34
cwl_v1_0 .OutputParameter , cwl_v1_1 .OutputParameter , cwl_v1_2 .OutputParameter
33
35
]
@@ -243,8 +245,6 @@ def load_document_by_uri(
243
245
load_all : bool = False ,
244
246
) -> Any :
245
247
"""Load a CWL object from a URI or a path."""
246
- base_uri = ""
247
- real_uri = ""
248
248
if isinstance (path , str ):
249
249
uri = urlparse (path )
250
250
id_ = uri .fragment or None
@@ -259,8 +259,24 @@ def load_document_by_uri(
259
259
base_uri = path .resolve ().parent .as_uri ()
260
260
id_ = path .resolve ().name .split ("#" )[1 ] if "#" in path .resolve ().name else None
261
261
262
- if loadingOptions is None :
262
+ if isinstance (loadingOptions , cwl_v1_0 .LoadingOptions ):
263
+ loadingOptions = cwl_v1_0 .LoadingOptions (
264
+ fileuri = real_uri , baseuri = base_uri , copyfrom = loadingOptions
265
+ )
266
+ elif isinstance (loadingOptions , cwl_v1_1 .LoadingOptions ):
267
+ loadingOptions = cwl_v1_1 .LoadingOptions (
268
+ fileuri = real_uri , baseuri = base_uri , copyfrom = loadingOptions
269
+ )
270
+ elif isinstance (loadingOptions , cwl_v1_2 .LoadingOptions ):
271
+ loadingOptions = cwl_v1_2 .LoadingOptions (
272
+ fileuri = real_uri , baseuri = base_uri , copyfrom = loadingOptions
273
+ )
274
+ elif loadingOptions is None :
263
275
loadingOptions = cwl_v1_2 .LoadingOptions (fileuri = real_uri , baseuri = base_uri )
276
+ else :
277
+ raise ValidationException (
278
+ f"Unsupported loadingOptions type: { type (loadingOptions )} "
279
+ )
264
280
265
281
doc = loadingOptions .fetcher .fetch_text (real_uri )
266
282
return load_document_by_string (doc , real_uri , loadingOptions , id_ , load_all )
0 commit comments