Skip to content

Commit 4020d0f

Browse files
committed
bump schema-salad version, document narrowing types
1 parent 54f03fe commit 4020d0f

File tree

12 files changed

+137
-19
lines changed

12 files changed

+137
-19
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ COVBASE=coverage run --append
3434

3535
# Updating the Major & Minor version below?
3636
# Don't forget to update setup.py as well
37-
VERSION=8.2.$(shell date +%Y%m%d%H%M%S --utc --date=`git log --first-parent \
37+
VERSION=8.3.$(shell date +%Y%m%d%H%M%S --utc --date=`git log --first-parent \
3838
--max-count=1 --format=format:%cI`)
3939

4040
## all : default task

schema_salad/avro/schema.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def __init__(
303303
type_schema = make_avsc_object(atype, names)
304304
except Exception as e:
305305
raise SchemaParseException(
306-
f'Type property "{atype}" not a valid Avro schema.'
306+
f'Type property "{atype}" not a valid Avro schema: {e}'
307307
) from e
308308
self.set_prop("type", type_schema)
309309
self.set_prop("name", name)
@@ -409,8 +409,8 @@ def __init__(
409409
items_schema = make_avsc_object(items, names)
410410
except Exception as err:
411411
raise SchemaParseException(
412-
f"Items schema ({items}) not a valid Avro schema: (known "
413-
f"names: {list(names.names.keys())})."
412+
f"Items schema ({items}) not a valid Avro schema: {err}. "
413+
f"Known names: {list(names.names.keys())})."
414414
) from err
415415

416416
self.set_prop("items", items_schema)
@@ -451,7 +451,7 @@ def __init__(
451451
new_schema = make_avsc_object(schema, names)
452452
except Exception as err:
453453
raise SchemaParseException(
454-
f"Union item must be a valid Avro schema: {schema}"
454+
f"Union item must be a valid Avro schema: {err}; {schema},"
455455
) from err
456456
# check the new schema
457457
if (
@@ -506,10 +506,6 @@ def make_field_objects(field_data: List[PropsType], names: Names) -> List[Field]
506506
# make sure field name has not been used yet
507507
if new_field.name in parsed_fields:
508508
old_field = parsed_fields[new_field.name]
509-
if "inherited_from" not in old_field:
510-
raise SchemaParseException(
511-
f"Field name {new_field.name} already in use."
512-
)
513509
if not is_subtype(old_field["type"], field["type"]):
514510
raise SchemaParseException(
515511
f"Field name {new_field.name} already in use with "

schema_salad/metaschema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Type,
2323
Union,
2424
)
25-
from urllib.parse import quote, urlsplit, urlunsplit, urlparse
25+
from urllib.parse import quote, urlparse, urlsplit, urlunsplit
2626
from urllib.request import pathname2url
2727

2828
from ruamel.yaml.comments import CommentedMap

schema_salad/metaschema/metaschema.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ $graph:
309309
type: boolean?
310310
doc: |
311311
If true, this record is abstract and may be used as a base for other
312-
records, but is not valid on its own.
312+
records, but is not valid on its own. Inherited fields may be
313+
re-specified to narrow their type.
313314
314315
- name: extends
315316
type:
@@ -321,7 +322,7 @@ $graph:
321322
refScope: 1
322323
doc: |
323324
Indicates that this record inherits fields from one or more base records.
324-
325+
Inherited fields may be re-specified to narrow their type.
325326
- name: specialize
326327
type:
327328
- SpecializeDef[]?

schema_salad/metaschema/salad.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Contributors:
99
* The developers of Apache Avro
1010
* The developers of JSON-LD
1111
* Nebojša Tijanić <[email protected]>, Seven Bridges Genomics
12+
* Michael R. Crusoe, ELIXIR-DE
1213

1314
# Abstract
1415

@@ -86,6 +87,13 @@ specification, the following changes have been made:
8687
is poorly documented, not included in conformance testing,
8788
and not widely supported.
8889

90+
## Introduction to v1.2
91+
92+
This is the fourth version of the Schema Salad specification. It was created to
93+
ease the development of extensions to CWL v1.2. The only change is that
94+
inherited records can narrow the types of fields if those fields are re-specified
95+
with a matching jsonldPredicate.
96+
8997
## References to Other Specifications
9098

9199
**Javascript Object Notation (JSON)**: http://json.org

schema_salad/python_codegen_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Type,
2020
Union,
2121
)
22-
from urllib.parse import quote, urlsplit, urlunsplit, urlparse
22+
from urllib.parse import quote, urlparse, urlsplit, urlunsplit
2323
from urllib.request import pathname2url
2424

2525
from ruamel.yaml.comments import CommentedMap

schema_salad/tests/metaschema-pre.yml

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

schema_salad/tests/test_schema/avro_naming_base.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ $graph:
2020
doc: |
2121
This is an arbitrary abstract thing from a base schema that might
2222
be extended.
23+
fields:
24+
override_me:
25+
type: [ string, int ]
26+
jsonldPredicate: "bs:override_me"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
$base: "https://example.com/derived_schema#"
2+
3+
$namespaces:
4+
bs: "https://example.com/base_schema#"
5+
6+
$graph:
7+
8+
- $import: avro_naming_base.yml
9+
10+
- name: ExtendedThing
11+
type: record
12+
doc: |
13+
A refinement of the base schema's arbitrary abstract thing,
14+
that allows one of the base schema's types as a field.
15+
inVocab: false
16+
extends: bs:AbstractThing
17+
fields:
18+
field_one:
19+
type:
20+
type: array
21+
items: [string, bs:RealThing]
22+
override_me:
23+
type: string
24+
jsonldPredicate: "bs:override_me"
25+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
$base: "https://example.com/derived_schema#"
2+
3+
$namespaces:
4+
bs: "https://example.com/base_schema#"
5+
6+
$graph:
7+
8+
- $import: avro_naming_base.yml
9+
10+
- name: ExtendedThing
11+
type: record
12+
doc: |
13+
A refinement of the base schema's arbitrary abstract thing,
14+
that allows one of the base schema's types as a field.
15+
inVocab: false
16+
extends: bs:AbstractThing
17+
fields:
18+
field_one:
19+
type:
20+
type: array
21+
items: [string, bs:RealThing]
22+
override_me:
23+
type: Any
24+
jsonldPredicate: bs:override_me
25+

0 commit comments

Comments
 (0)