Closed wdduncan closed 3 years ago
Output:
==================== Python ====================
# Auto generated from issue_80.yaml by pythongen.py version: 0.3.0
# Generation date: 2019-12-09 10:51
# Schema: Issue 80 test case
#
# id: http://example.org/issues/80
# description: Example identifier
# license: https://creativecommons.org/publicdomain/zero/1.0/
from typing import Optional, List, Union, Dict, ClassVar
from dataclasses import dataclass
from biolinkml.utils.metamodelcore import empty_list, empty_dict, bnode
from biolinkml.utils.yamlutils import YAMLRoot
from biolinkml.utils.formatutils import camelcase, underscore, sfx
from rdflib import Namespace, URIRef
from biolinkml.utils.curienamespace import CurieNamespace
from biolinkml.utils.metamodelcore import ElementIdentifier
from includes.types import Integer, Objectidentifier, String
metamodel_version = "1.4.3"
# Namespaces
BIOLINK = CurieNamespace('biolink', 'https://w3id.org/biolink/vocab/')
BIOLINKML = CurieNamespace('biolinkml', 'https://w3id.org/biolink/biolinkml/')
EX = CurieNamespace('ex', 'http://example.org/')
MODEL = CurieNamespace('model', 'https://w3id.org/biolink/')
DEFAULT_ = BIOLINK
# Types
# Class references
class PersonId(ElementIdentifier):
pass
@dataclass
class Person(YAMLRoot):
"""
A person, living or dead
"""
_inherited_slots: ClassVar[List[str]] = []
class_class_uri: ClassVar[URIRef] = EX.PERSON
class_class_curie: ClassVar[str] = "ex:PERSON"
class_name: ClassVar[str] = "person"
class_model_uri: ClassVar[URIRef] = BIOLINK.Person
id: Union[str, PersonId]
name: str
age: Optional[int] = None
def __post_init__(self):
if self.id is None:
raise ValueError(f"id must be supplied")
if not isinstance(self.id, PersonId):
self.id = PersonId(self.id)
if self.name is None:
raise ValueError(f"name must be supplied")
super().__post_init__()
==================== JSON ====================
{
"id": "http://example.org/person/17",
"name": "Fred Jones",
"age": 43
}
==================== Context ====================
{
"_comments": "Auto generated from issue_80.yaml by jsonldcontextgen.py version: 0.1.1\nGeneration date: 2019-12-09 10:51\nSchema: Issue 80 test case\n\nid: http://example.org/issues/80\ndescription: Example identifier\nlicense: https://creativecommons.org/publicdomain/zero/1.0/\n",
"@context": {
"type": "@type",
"biolink": "https://w3id.org/biolink/vocab/",
"biolinkml": "https://w3id.org/biolink/biolinkml/",
"ex": "http://example.org/",
"model": "https://w3id.org/biolink/",
"@vocab": "https://w3id.org/biolink/vocab/",
"age": {
"@type": "xsd:integer"
},
"id": "@id",
"Person": {
"@id": "ex:PERSON"
}
}
}
==================== RDF ====================
@prefix : <https://w3id.org/biolink/vocab/> .
@prefix biolink: <https://w3id.org/biolink/vocab/> .
@prefix biolinkml: <https://w3id.org/biolink/biolinkml/> .
@prefix ex: <http://example.org/> .
@prefix model: <https://w3id.org/biolink/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://example.org/person/17> a ex:PERSON ;
biolink:age "43"^^biolink:xsdinteger ;
biolink:name "Fred Jones" .
Ignore the above commit -- it was an error in the commit text
@hsolbrig Not sure if the above comments meant that this was not an issue or that you were looking into it. The links you posted were broken.
@wdduncan can this be closed?
@cmungall @hsolbrig unfortunately I was not able to open the link Harold referred to above (404 error). I am still not able to specify a uri for a class. I apologize if this user error ... but I haven't been able to figure this out.
Here is my test yaml:
id: https://example.com/test-schema
name: testing_class_uri
prefixes:
wgs: http://www.w3.org/2003/01/geo/wgs84_pos
qud: http://qudt.org/1.1/schema/qudt#
dcterms: http://purl.org/dc/terms/
schema: http://schema.org/
biolinkml: https://w3id.org/biolink/biolinkml/
imports:
- biolinkml:types
classes:
person:
class_uri: http://example.com/person
slots:
- name
slots:
name:
range: string
Calling gen-json-schema
produces:
{
"$id": "https://example.com/test-schema",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Person": {
"additionalProperties": false,
"description": "",
"properties": {
"name": {
"type": "string"
}
},
"required": [],
"title": "Person",
"type": "object"
}
},
"properties": {},
"title": "testing_class_uri",
"type": "object"
}
Calling gen-rdf
produces an error:
(just showing the bottom)
File "/Users/wdduncan/temp/.env/lib/python3.7/site-packages/rdflib/parser.py", line 193, in create_input_source
input_source = URLInputSource(absolute_location, format)
File "/Users/wdduncan/temp/.env/lib/python3.7/site-packages/rdflib/parser.py", line 113, in __init__
file = urlopen(req)
File "/Users/wdduncan/opt/anaconda3/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Users/wdduncan/opt/anaconda3/lib/python3.7/urllib/request.py", line 523, in open
req = meth(req)
File "/Users/wdduncan/opt/anaconda3/lib/python3.7/urllib/request.py", line 1240, in do_request_
raise URLError('no host given')
urllib.error.URLError: <urlopen error no host given>
Calling gen-jsonld
produces:
{
"name": "testing_class_uri",
"id": "https://example.com/test-schema",
"imports": [
"biolinkml:types"
],
"license": "https://creativecommons.org/publicdomain/zero/1.0/",
"prefixes": [
{
"prefix_prefix": "wgs",
"prefix_reference": "http://www.w3.org/2003/01/geo/wgs84_pos"
},
{
"prefix_prefix": "qud",
"prefix_reference": "http://qudt.org/1.1/schema/qudt#"
},
{
"prefix_prefix": "dcterms",
"prefix_reference": "http://purl.org/dc/terms/"
},
{
"prefix_prefix": "schema",
"prefix_reference": "http://schema.org/"
},
{
"prefix_prefix": "biolinkml",
"prefix_reference": "https://w3id.org/biolink/biolinkml/"
}
],
"default_prefix": "https://example.com/test-schema/",
"default_range": "string",
"types": [
{
"name": "string",
"definition_uri": "https://w3id.org/biolink/biolinkml/meta/types/String",
"description": "A character string",
"from_schema": "https://w3id.org/biolink/biolinkml/types",
"imported_from": "biolinkml:types",
"base": "str",
"uri": "http://www.w3.org/2001/XMLSchema#string",
"type": "TypeDefinition"
},
{
"name": "integer",
"definition_uri": "https://w3id.org/biolink/biolinkml/meta/types/Integer",
"description": "An integer",
"from_schema": "https://w3id.org/biolink/biolinkml/types",
"imported_from": "biolinkml:types",
"base": "int",
"uri": "http://www.w3.org/2001/XMLSchema#integer",
"type": "TypeDefinition"
},
{
"name": "boolean",
"definition_uri": "https://w3id.org/biolink/biolinkml/meta/types/Boolean",
"description": "A binary (true or false) value",
"from_schema": "https://w3id.org/biolink/biolinkml/types",
"imported_from": "biolinkml:types",
"base": "Bool",
"uri": "http://www.w3.org/2001/XMLSchema#boolean",
"type": "TypeDefinition"
},
{
"name": "float",
"definition_uri": "https://w3id.org/biolink/biolinkml/meta/types/Float",
"description": "A real number that conforms to the xsd:float specification",
"from_schema": "https://w3id.org/biolink/biolinkml/types",
"imported_from": "biolinkml:types",
"base": "float",
"uri": "http://www.w3.org/2001/XMLSchema#float",
"type": "TypeDefinition"
},
{
"name": "double",
"definition_uri": "https://w3id.org/biolink/biolinkml/meta/types/Double",
"description": "A real number that conforms to the xsd:double specification",
"from_schema": "https://w3id.org/biolink/biolinkml/types",
"imported_from": "biolinkml:types",
"base": "float",
"uri": "http://www.w3.org/2001/XMLSchema#double",
"type": "TypeDefinition"
},
{
"name": "time",
"definition_uri": "https://w3id.org/biolink/biolinkml/meta/types/Time",
"description": "A time object represents a (local) time of day, independent of any particular day",
"notes": [
"URI is dateTime because OWL reasoners don't work with straight date or time"
],
"from_schema": "https://w3id.org/biolink/biolinkml/types",
"imported_from": "biolinkml:types",
"base": "XSDTime",
"uri": "http://www.w3.org/2001/XMLSchema#dateTime",
"repr": "str",
"type": "TypeDefinition"
},
{
"name": "date",
"definition_uri": "https://w3id.org/biolink/biolinkml/meta/types/Date",
"description": "a date (year, month and day) in an idealized calendar",
"notes": [
"URI is dateTime because OWL reasoners don't work with straight date or time"
],
"from_schema": "https://w3id.org/biolink/biolinkml/types",
"imported_from": "biolinkml:types",
"base": "XSDDate",
"uri": "http://www.w3.org/2001/XMLSchema#date",
"repr": "str",
"type": "TypeDefinition"
},
{
"name": "datetime",
"definition_uri": "https://w3id.org/biolink/biolinkml/meta/types/Datetime",
"description": "The combination of a date and time",
"from_schema": "https://w3id.org/biolink/biolinkml/types",
"imported_from": "biolinkml:types",
"base": "XSDDateTime",
"uri": "http://www.w3.org/2001/XMLSchema#dateTime",
"repr": "str",
"type": "TypeDefinition"
},
{
"name": "uriorcurie",
"definition_uri": "https://w3id.org/biolink/biolinkml/meta/types/Uriorcurie",
"description": "a URI or a CURIE",
"from_schema": "https://w3id.org/biolink/biolinkml/types",
"imported_from": "biolinkml:types",
"base": "URIorCURIE",
"uri": "http://www.w3.org/2001/XMLSchema#anyURI",
"repr": "str",
"type": "TypeDefinition"
},
{
"name": "uri",
"definition_uri": "https://w3id.org/biolink/biolinkml/meta/types/Uri",
"description": "a complete URI",
"from_schema": "https://w3id.org/biolink/biolinkml/types",
"imported_from": "biolinkml:types",
"base": "URI",
"uri": "http://www.w3.org/2001/XMLSchema#anyURI",
"repr": "str",
"type": "TypeDefinition"
},
{
"name": "ncname",
"definition_uri": "https://w3id.org/biolink/biolinkml/meta/types/Ncname",
"description": "Prefix part of CURIE",
"from_schema": "https://w3id.org/biolink/biolinkml/types",
"imported_from": "biolinkml:types",
"base": "NCName",
"uri": "http://www.w3.org/2001/XMLSchema#string",
"repr": "str",
"type": "TypeDefinition"
},
{
"name": "objectidentifier",
"definition_uri": "https://w3id.org/biolink/biolinkml/meta/types/Objectidentifier",
"description": "A URI or CURIE that represents an object in the model.",
"comments": [
"Used for inheritence and type checking"
],
"from_schema": "https://w3id.org/biolink/biolinkml/types",
"imported_from": "biolinkml:types",
"base": "ElementIdentifier",
"uri": "http://www.w3.org/ns/shex#iri",
"repr": "str",
"type": "TypeDefinition"
},
{
"name": "nodeidentifier",
"definition_uri": "https://w3id.org/biolink/biolinkml/meta/types/Nodeidentifier",
"description": "A URI, CURIE or BNODE that represents a node in a model.",
"from_schema": "https://w3id.org/biolink/biolinkml/types",
"imported_from": "biolinkml:types",
"base": "NodeIdentifier",
"uri": "http://www.w3.org/ns/shex#nonLiteral",
"repr": "str",
"type": "TypeDefinition"
}
],
"slots": [
{
"name": "name",
"definition_uri": "https://example.com/test-schema/name",
"from_schema": "https://example.com/test-schema",
"range": "string",
"slot_uri": "https://example.com/test-schema/name",
"owner": "Person",
"domain_of": [
"Person"
],
"type": "SlotDefinition"
}
],
"classes": [
{
"name": "Person",
"definition_uri": "https://example.com/test-schema/Person",
"mappings": [
"http://example.com/person"
],
"from_schema": "https://example.com/test-schema",
"slots": [
"name"
],
"class_uri": "http://example.com/person",
"type": "ClassDefinition"
}
],
"metamodel_version": "1.5.3",
"source_file": "test.yaml",
"source_file_date": "Wed Aug 19 13:59:01 2020",
"source_file_size": 440,
"generation_date": "2020-08-19 14:04",
"type": "SchemaDefinition",
"@context": [
"h",
"t",
"t",
"p",
"s",
":",
"/",
"/",
"w",
"3",
"i",
"d",
".",
"o",
"r",
"g",
"/",
"b",
"i",
"o",
"l",
"i",
"n",
"k",
"/",
"b",
"i",
"o",
"l",
"i",
"n",
"k",
"m",
"l",
"/",
"c",
"o",
"n",
"t",
"e",
"x",
"t",
".",
"j",
"s",
"o",
"n",
"l",
"d",
"https://w3id.org/biolink/biolinkml/types.context.jsonld",
{
"@base": "https://example.com/test-schema/"
}
]
}
Consider the following class defined in yaml:
How do I specify an IRI for the class person? I've tried this:
But I get an error:
File: None Class "person" - unknown slot: "{'id': 'http://example.com/10001'}"
I've also tried using
class_uri
like this:but the json-ld output is not quite right:
It should look something like: