Skip to content

Commit 70f9f91

Browse files
committed
adjust for AvroSchemaFromJSONData's absence
1 parent d20f8bd commit 70f9f91

File tree

4 files changed

+46
-41
lines changed

4 files changed

+46
-41
lines changed

cwltool/builder.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from rdflib.namespace import OWL, RDFS
1010
from ruamel.yaml.comments import CommentedMap
1111
from schema_salad import validate
12-
from schema_salad.schema import AvroSchemaFromJSONData, Names
12+
from schema_salad.schema import Names, convert_to_dict
13+
from schema_salad.avro.schema import make_avsc_object
1314
from schema_salad.sourceline import SourceLine
1415
from six import iteritems, string_types
1516
from typing_extensions import (TYPE_CHECKING, # pylint: disable=unused-import
@@ -109,27 +110,27 @@ def get_requirement(self,
109110

110111
class Builder(HasReqsHints):
111112
def __init__(self,
112-
job, # type: Dict[Text, Union[Dict[Text, Any], List, Text, None]]
113-
files, # type: List[Dict[Text, Text]]
114-
bindings, # type: List[Dict[Text, Any]]
115-
schemaDefs, # type: Dict[Text, Dict[Text, Any]]
116-
names, # type: Names
117-
requirements, # type: List[Dict[Text, Any]]
118-
hints, # type: List[Dict[Text, Any]]
119-
resources, # type: Dict[str, int]
120-
mutation_manager, # type: Optional[MutationManager]
121-
formatgraph, # type: Optional[Graph]
122-
make_fs_access, # type: Type[StdFsAccess]
123-
fs_access, # type: StdFsAccess
124-
job_script_provider, # type: Optional[Any]
125-
timeout, # type: float
126-
debug, # type: bool
127-
js_console, # type: bool
128-
force_docker_pull, # type: bool
129-
loadListing, # type: Text
130-
outdir, # type: Text
131-
tmpdir, # type: Text
132-
stagedir, # type: Text
113+
job, # type: Dict[Text, Union[Dict[Text, Any], List, Text, None]]
114+
files, # type: List[Dict[Text, Text]]
115+
bindings, # type: List[Dict[Text, Any]]
116+
schemaDefs, # type: Dict[Text, Dict[Text, Any]]
117+
names, # type: Names
118+
requirements, # type: List[Dict[Text, Any]]
119+
hints, # type: List[Dict[Text, Any]]
120+
resources, # type: Dict[str, int]
121+
mutation_manager, # type: Optional[MutationManager]
122+
formatgraph, # type: Optional[Graph]
123+
make_fs_access, # type: Type[StdFsAccess]
124+
fs_access, # type: StdFsAccess
125+
job_script_provider, # type: Optional[Any]
126+
timeout, # type: float
127+
debug, # type: bool
128+
js_console, # type: bool
129+
force_docker_pull, # type: bool
130+
loadListing, # type: Text
131+
outdir, # type: Text
132+
tmpdir, # type: Text
133+
stagedir, # type: Text
133134
): # type: (...) -> None
134135

135136
self.job = job
@@ -208,12 +209,14 @@ def bind_input(self,
208209
if isinstance(schema["type"], MutableSequence):
209210
bound_input = False
210211
for t in schema["type"]:
212+
avsc = None
211213
if isinstance(t, string_types) and self.names.has_name(t, ""):
212214
avsc = self.names.get_name(t, "")
213215
elif isinstance(t, MutableMapping) and "name" in t and self.names.has_name(t["name"], ""):
214216
avsc = self.names.get_name(t["name"], "")
215-
else:
216-
avsc = AvroSchemaFromJSONData(t, self.names)
217+
if not avsc:
218+
avsc = make_avsc_object(convert_to_dict(t), self.names)
219+
assert avsc is not None
217220
if validate.validate(avsc, datum):
218221
schema = copy.deepcopy(schema)
219222
schema["type"] = t

cwltool/process.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,8 @@ def __init__(self,
470470
SCHEMA_DIR = cast(Dict[Text, Any],
471471
SCHEMA_CACHE["v1.0"][3].idx["https://w3id.org/cwl/cwl#Directory"])
472472

473-
names = schema.make_avro_schema([SCHEMA_FILE, SCHEMA_DIR, SCHEMA_ANY],
474-
Loader({}))[0]
475-
if isinstance(names, schema.SchemaParseException):
476-
raise names
477-
else:
478-
self.names = names
473+
self.names = schema.make_avro_schema([SCHEMA_FILE, SCHEMA_DIR, SCHEMA_ANY],
474+
Loader({}))
479475
self.tool = toolpath_object
480476
self.requirements = copy.deepcopy(getdefault(loadingContext.requirements, []))
481477
self.requirements.extend(self.tool.get("requirements", []))
@@ -506,7 +502,7 @@ def __init__(self,
506502
av = schema.make_valid_avro(sdtypes, {t["name"]: t for t in avroize_type(sdtypes)}, set())
507503
for i in av:
508504
self.schemaDefs[i["name"]] = i # type: ignore
509-
schema.AvroSchemaFromJSONData(av, self.names) # type: ignore
505+
schema.make_avsc_object(schema.convert_to_dict(av), self.names)
510506

511507
# Build record schema from inputs
512508
self.inputs_record_schema = {
@@ -542,12 +538,14 @@ def __init__(self,
542538
self.inputs_record_schema = cast(
543539
Dict[Text, Any], schema.make_valid_avro(
544540
self.inputs_record_schema, {}, set()))
545-
schema.AvroSchemaFromJSONData(self.inputs_record_schema, self.names)
541+
schema.make_avsc_object(
542+
schema.convert_to_dict(self.inputs_record_schema), self.names)
546543
with SourceLine(toolpath_object, "outputs", validate.ValidationException):
547544
self.outputs_record_schema = cast(
548545
Dict[Text, Any],
549546
schema.make_valid_avro(self.outputs_record_schema, {}, set()))
550-
schema.AvroSchemaFromJSONData(self.outputs_record_schema, self.names)
547+
schema.make_avsc_object(
548+
schema.convert_to_dict(self.outputs_record_schema), self.names)
551549

552550
if toolpath_object.get("class") is not None \
553551
and not getdefault(loadingContext.disable_js_validation, False):
@@ -601,8 +599,12 @@ def _init_job(self, joborder, runtime_context):
601599
try:
602600
fill_in_defaults(self.tool[u"inputs"], job, fs_access)
603601
normalizeFilesDirs(job)
604-
validate.validate_ex(self.names.get_name("input_record_schema", ""),
605-
job, strict=False, logger=_logger_validation_warnings)
602+
schema = self.names.get_name("input_record_schema", "")
603+
if schema is None:
604+
raise WorkflowException("Missing input record schema: "
605+
"{}".format(self.names))
606+
validate.validate_ex(schema, job, strict=False,
607+
logger=_logger_validation_warnings)
606608
except (validate.ValidationException, WorkflowException) as err:
607609
raise WorkflowException("Invalid job input record:\n" + Text(err))
608610

@@ -643,10 +645,10 @@ def _init_job(self, joborder, runtime_context):
643645
prefix=getdefault(runtime_context.tmp_outdir_prefix,
644646
DEFAULT_TMP_PREFIX)))
645647
if self.tool[u"class"] != 'Workflow':
646-
tmpdir = fs_access.realpath(runtime_context.tmpdir or
647-
tempfile.mkdtemp())
648-
stagedir = fs_access.realpath(runtime_context.stagedir or
649-
tempfile.mkdtemp())
648+
tmpdir = fs_access.realpath(runtime_context.tmpdir
649+
or tempfile.mkdtemp())
650+
stagedir = fs_access.realpath(runtime_context.stagedir
651+
or tempfile.mkdtemp())
650652

651653
builder = Builder(job,
652654
files,

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ requests>=2.4.3
22
ruamel.yaml>=0.12.4,<=0.15.77
33
rdflib>=4.2.2,<4.3
44
shellescape>=3.4.1,<3.5
5-
schema-salad>=2.7.20181128093206,<3
5+
schema-salad>=2.8,<3
66
typing>=3.5.3; python_version<"3.6"
77
pathlib2==2.3.2; python_version<"3"
88
prov==1.5.1

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
'ruamel.yaml >= 0.12.4, <= 0.15.77',
5454
'rdflib >= 4.2.2, < 4.3.0',
5555
'shellescape >= 3.4.1, < 3.5',
56-
'schema-salad >= 2.7.20181128093206, < 3',
56+
'schema-salad >= 2.8, < 3',
5757
'mypy-extensions',
5858
'six >= 1.9.0', # >= 1.9.0 required by prov
5959
'psutil',

0 commit comments

Comments
 (0)