18
18
from typing import (Any , Callable , Dict , Generator , List , Set , Text ,
19
19
Tuple , Union , cast )
20
20
21
- import avro .schema
22
- import schema_salad .schema
21
+ import schema_salad .schema as schema
23
22
import schema_salad .validate as validate
24
23
import six
25
24
from pkg_resources import resource_stream
42
41
from .utils import aslist , get_feature , copytree_with_merge , onWindows
43
42
44
43
45
- # if six.PY3:
46
- # AvroSchemaFromJSONData = avro.schema.SchemaFromJSONData
47
- # else:
48
- AvroSchemaFromJSONData = avro .schema .make_avsc_object
49
-
50
44
class LogAsDebugFilter (logging .Filter ):
51
45
def __init__ (self , name , parent ): # type: (Text, logging.Logger) -> None
52
46
name = str (name )
@@ -108,7 +102,7 @@ def filter(self, record):
108
102
'vocab_res_src.yml' ,
109
103
'vocab_res_proc.yml' )
110
104
111
- SCHEMA_CACHE = {} # type: Dict[Text, Tuple[Loader, Union[avro. schema.Names, avro. schema.SchemaParseException], Dict[Text, Any], Loader]]
105
+ SCHEMA_CACHE = {} # type: Dict[Text, Tuple[Loader, Union[schema.Names, schema.SchemaParseException], Dict[Text, Any], Loader]]
112
106
SCHEMA_FILE = None # type: Dict[Text, Any]
113
107
SCHEMA_DIR = None # type: Dict[Text, Any]
114
108
SCHEMA_ANY = None # type: Dict[Text, Any]
@@ -129,7 +123,7 @@ def use_custom_schema(version, name, text):
129
123
del SCHEMA_CACHE [version ]
130
124
131
125
def get_schema (version ):
132
- # type: (Text) -> Tuple[Loader, Union[avro. schema.Names, avro. schema.SchemaParseException], Dict[Text,Any], Loader]
126
+ # type: (Text) -> Tuple[Loader, Union[schema.Names, schema.SchemaParseException], Dict[Text,Any], Loader]
133
127
134
128
if version in SCHEMA_CACHE :
135
129
return SCHEMA_CACHE [version ]
@@ -159,10 +153,10 @@ def get_schema(version):
159
153
160
154
if version in custom_schemas :
161
155
cache [custom_schemas [version ][0 ]] = custom_schemas [version ][1 ]
162
- SCHEMA_CACHE [version ] = schema_salad . schema .load_schema (
156
+ SCHEMA_CACHE [version ] = schema .load_schema (
163
157
custom_schemas [version ][0 ], cache = cache )
164
158
else :
165
- SCHEMA_CACHE [version ] = schema_salad . schema .load_schema (
159
+ SCHEMA_CACHE [version ] = schema .load_schema (
166
160
"https://w3id.org/cwl/CommonWorkflowLanguage.yml" , cache = cache )
167
161
168
162
return SCHEMA_CACHE [version ]
@@ -409,7 +403,7 @@ def __init__(self, toolpath_object, **kwargs):
409
403
"""
410
404
411
405
self .metadata = kwargs .get ("metadata" , {}) # type: Dict[Text,Any]
412
- self .names = None # type: avro. schema.Names
406
+ self .names = None # type: schema.Names
413
407
414
408
global SCHEMA_FILE , SCHEMA_DIR , SCHEMA_ANY # pylint: disable=global-statement
415
409
if SCHEMA_FILE is None :
@@ -421,9 +415,9 @@ def __init__(self, toolpath_object, **kwargs):
421
415
SCHEMA_DIR = cast (Dict [Text , Any ],
422
416
SCHEMA_CACHE ["v1.0" ][3 ].idx ["https://w3id.org/cwl/cwl#Directory" ])
423
417
424
- names = schema_salad . schema .make_avro_schema ([SCHEMA_FILE , SCHEMA_DIR , SCHEMA_ANY ],
425
- schema_salad . ref_resolver . Loader ({}))[0 ]
426
- if isinstance (names , avro . schema .SchemaParseException ):
418
+ names = schema .make_avro_schema ([SCHEMA_FILE , SCHEMA_DIR , SCHEMA_ANY ],
419
+ Loader ({}))[0 ]
420
+ if isinstance (names , schema .SchemaParseException ):
427
421
raise names
428
422
else :
429
423
self .names = names
@@ -449,10 +443,10 @@ def __init__(self, toolpath_object, **kwargs):
449
443
450
444
if sd :
451
445
sdtypes = sd ["types" ]
452
- av = schema_salad . schema .make_valid_avro (sdtypes , {t ["name" ]: t for t in avroize_type (sdtypes )}, set ())
446
+ av = schema .make_valid_avro (sdtypes , {t ["name" ]: t for t in avroize_type (sdtypes )}, set ())
453
447
for i in av :
454
448
self .schemaDefs [i ["name" ]] = i # type: ignore
455
- AvroSchemaFromJSONData (av , self .names ) # type: ignore
449
+ schema . AvroSchemaFromJSONData (av , self .names ) # type: ignore
456
450
457
451
# Build record schema from inputs
458
452
self .inputs_record_schema = {
@@ -484,14 +478,13 @@ def __init__(self, toolpath_object, **kwargs):
484
478
485
479
with SourceLine (toolpath_object , "inputs" , validate .ValidationException ):
486
480
self .inputs_record_schema = cast (
487
- Dict [six .text_type , Any ], schema_salad . schema .make_valid_avro (
481
+ Dict [six .text_type , Any ], schema .make_valid_avro (
488
482
self .inputs_record_schema , {}, set ()))
489
- AvroSchemaFromJSONData (self .inputs_record_schema , self .names )
483
+ schema . AvroSchemaFromJSONData (self .inputs_record_schema , self .names )
490
484
with SourceLine (toolpath_object , "outputs" , validate .ValidationException ):
491
485
self .outputs_record_schema = cast (Dict [six .text_type , Any ],
492
- schema_salad .schema .make_valid_avro (
493
- self .outputs_record_schema , {}, set ()))
494
- AvroSchemaFromJSONData (self .outputs_record_schema , self .names )
486
+ schema .make_valid_avro (self .outputs_record_schema , {}, set ()))
487
+ schema .AvroSchemaFromJSONData (self .outputs_record_schema , self .names )
495
488
496
489
if toolpath_object .get ("class" ) is not None and not kwargs .get ("disable_js_validation" , False ):
497
490
if kwargs .get ("js_hint_options_file" ) is not None :
0 commit comments