Skip to content

Commit

Permalink
In vocab flag (#97)
Browse files Browse the repository at this point in the history
* Mark named items as "not in vocabulary" so that they can only be referenced by
fully qualified URI and not by short name.  Enables adding validated spec
extensions without adding new keywords.
  • Loading branch information
tetron authored Mar 8, 2017
1 parent 39516e5 commit 0114153
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
21 changes: 8 additions & 13 deletions schema_salad/jsonld_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ def pred(datatype, # type: Dict[str, Union[Dict, str]]
"Dictionaries")
else:
raise Exception("jsonldPredicate must be a List of Dictionaries.")
# if not v:
# if field and "jsonldPrefix" in field:
# defaultBase = field["jsonldPrefix"]
# elif "jsonldPrefix" in datatype:
# defaultBase = datatype["jsonldPrefix"]

ret = v or vee

Expand Down Expand Up @@ -108,14 +103,14 @@ def process_type(t, # type: Dict[str, Any]
g.add((classnode, RDF.type, RDFS.Class))

split = urlparse.urlsplit(recordname)
if "jsonldPrefix" in t:
predicate = "%s:%s" % (t["jsonldPrefix"], recordname)
elif split.scheme:
(ns, ln) = rdflib.namespace.split_uri(unicode(recordname))
predicate = recordname
recordname = ln
else:
predicate = "%s:%s" % (defaultPrefix, recordname)
predicate = recordname
if t.get("inVocab", True):
if split.scheme:
(ns, ln) = rdflib.namespace.split_uri(unicode(recordname))
predicate = recordname
recordname = ln
else:
predicate = "%s:%s" % (defaultPrefix, recordname)

if context.get(recordname, predicate) != predicate:
raise Exception("Predicate collision on '%s', '%s' != '%s'" % (
Expand Down
6 changes: 6 additions & 0 deletions schema_salad/metaschema/metaschema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ $graph:
type: string
jsonldPredicate: "@id"
doc: "The identifier for this type"
- name: inVocab
type: boolean?
doc: |
By default or if "true", include the short name of this type in the
vocabulary (the keys of the JSON-LD context). If false, do not include
the short name in the vocabulary.
- name: DocType
Expand Down
3 changes: 2 additions & 1 deletion schema_salad/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ def make_valid_avro(items, # type: Avro
if isinstance(items, dict):
items = copy.copy(items)
if items.get("name"):
items["name"] = avro_name(items["name"])
if items.get("inVocab", True):
items["name"] = avro_name(items["name"])

if "type" in items and items["type"] in ("https://w3id.org/cwl/salad#record", "https://w3id.org/cwl/salad#enum", "record", "enum"):
if (hasattr(items, "get") and items.get("abstract")) or ("abstract"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
extras_require = {} # TODO: to be removed when the above is added

setup(name='schema-salad',
version='2.3',
version='2.4',
description='Schema Annotations for Linked Avro Data (SALAD)',
long_description=open(README).read(),
author='Common workflow language working group',
Expand Down

0 comments on commit 0114153

Please sign in to comment.