Cleaner code generation, npytyping type hints for arrays

- split off generated subclasses into "include" files, not sure if that's good, but in any case we have them separable now.
- more work on cleanly un-nesting scalar and 1D-vector data into attributes and lists, respectively
- brought the pydantic generator in-repo to do a bunch of overrides
This commit is contained in:
sneakers-the-rat 2023-08-30 20:56:30 -07:00
parent be21325123
commit fd9aef9531
15 changed files with 229 additions and 266 deletions

View file

@ -92,7 +92,6 @@ class NamespacesAdapter(Adapter):
all_matches = [*internal_matches, *import_matches] all_matches = [*internal_matches, *import_matches]
if len(all_matches)>1: if len(all_matches)>1:
pdb.set_trace()
raise KeyError(f"Found multiple schemas in namespace that define {name}:\ninternal: {pformat(internal_matches)}\nimported:{pformat(import_matches)}") raise KeyError(f"Found multiple schemas in namespace that define {name}:\ninternal: {pformat(internal_matches)}\nimported:{pformat(import_matches)}")
elif len(all_matches) == 1: elif len(all_matches) == 1:
return all_matches[0] return all_matches[0]

View file

@ -1,4 +1,4 @@
/docs/
/project/docs/ /project/docs/
/tmp/ /tmp/

View file

@ -110,11 +110,6 @@ gen-pydantic: $(PYMODEL)
$(RUN) gen-pydantic $(SOURCE_SCHEMA_PATH) --pydantic_version 1 > $(PYMODEL)/nwb_schema_pydantic.py $(RUN) gen-pydantic $(SOURCE_SCHEMA_PATH) --pydantic_version 1 > $(PYMODEL)/nwb_schema_pydantic.py
$(RUN) run_patches --phase post_generation_pydantic $(RUN) run_patches --phase post_generation_pydantic
gen-pydantic-test: $(PYMODEL)
$(RUN) gen-pydantic src/nwb_schema_language/schema/test_multival.yml --pydantic_version 1 > $(PYMODEL)/test_multival_pydantic.py
# $(RUN) run_patches --phase post_generation
test: test-schema test-python test-examples test: test-schema test-python test-examples
test-schema: test-schema:

View file

@ -11,17 +11,17 @@ type Attribute implements DtypeMixin
defaultValue: AnyType defaultValue: AnyType
doc: String! doc: String!
required: Boolean required: Boolean
dtype: String dtype: [String]
} }
type CompoundDtype type CompoundDtype
{ {
name: String! name: String!
doc: String! doc: String!
dtype: FlatDtype! dtype: [String]!
} }
type Dataset implements DtypeMixin, NamingMixin type Dataset implements DtypeMixin
{ {
neurodataTypeDef: String neurodataTypeDef: String
neurodataTypeInc: String neurodataTypeInc: String
@ -35,7 +35,7 @@ type Dataset implements DtypeMixin, NamingMixin
quantity: String quantity: String
linkable: Boolean linkable: Boolean
attributes: [Attribute] attributes: [Attribute]
dtype: String dtype: [String]
} }
type Datasets type Datasets
@ -45,10 +45,10 @@ type Datasets
interface DtypeMixin interface DtypeMixin
{ {
dtype: String dtype: [String]
} }
type Group implements NamingMixin type Group
{ {
neurodataTypeDef: String neurodataTypeDef: String
neurodataTypeInc: String neurodataTypeInc: String
@ -93,10 +93,6 @@ type Namespaces
namespaces: [Namespace] namespaces: [Namespace]
} }
interface NamingMixin
{
}
type ReferenceDtype type ReferenceDtype
{ {
targetType: String! targetType: String!

View file

@ -1,15 +1,13 @@
{ {
"comments": { "comments": {
"description": "Auto generated by LinkML jsonld context generator", "description": "Auto generated by LinkML jsonld context generator",
"generation_date": "2023-08-18T00:36:53", "generation_date": "2023-08-30T20:53:58",
"source": "nwb_schema_language.yaml" "source": "nwb_schema_language.yaml"
}, },
"@context": { "@context": {
"linkml": "https://w3id.org/linkml/", "linkml": "https://w3id.org/linkml/",
"nwb_schema_language": "https://w3id.org/p2p_ld/nwb-schema-language/", "nwb_schema_language": "https://w3id.org/p2p_ld/nwb-schema-language/",
"schema": { "schema": "http://schema.org/",
"@type": "@id"
},
"skos": "http://www.w3.org/2004/02/skos/core#", "skos": "http://www.w3.org/2004/02/skos/core#",
"@vocab": "https://w3id.org/p2p_ld/nwb-schema-language/", "@vocab": "https://w3id.org/p2p_ld/nwb-schema-language/",
"attributes": { "attributes": {
@ -54,6 +52,9 @@
"required": { "required": {
"@type": "xsd:boolean" "@type": "xsd:boolean"
}, },
"schema_": {
"@type": "@id"
},
"value": { "value": {
"@type": "@id" "@type": "@id"
}, },

View file

@ -31,6 +31,9 @@
"name": "string", "name": "string",
"definition_uri": "https://w3id.org/linkml/String", "definition_uri": "https://w3id.org/linkml/String",
"description": "A character string", "description": "A character string",
"notes": [
"In RDF serializations, a slot with range of string is treated as a literal or type xsd:string. If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"string\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"exact_mappings": [ "exact_mappings": [
@ -44,6 +47,9 @@
"name": "integer", "name": "integer",
"definition_uri": "https://w3id.org/linkml/Integer", "definition_uri": "https://w3id.org/linkml/Integer",
"description": "An integer", "description": "An integer",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"integer\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"exact_mappings": [ "exact_mappings": [
@ -57,6 +63,9 @@
"name": "boolean", "name": "boolean",
"definition_uri": "https://w3id.org/linkml/Boolean", "definition_uri": "https://w3id.org/linkml/Boolean",
"description": "A binary (true or false) value", "description": "A binary (true or false) value",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"boolean\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"exact_mappings": [ "exact_mappings": [
@ -71,6 +80,9 @@
"name": "float", "name": "float",
"definition_uri": "https://w3id.org/linkml/Float", "definition_uri": "https://w3id.org/linkml/Float",
"description": "A real number that conforms to the xsd:float specification", "description": "A real number that conforms to the xsd:float specification",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"float\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"exact_mappings": [ "exact_mappings": [
@ -84,6 +96,9 @@
"name": "double", "name": "double",
"definition_uri": "https://w3id.org/linkml/Double", "definition_uri": "https://w3id.org/linkml/Double",
"description": "A real number that conforms to the xsd:double specification", "description": "A real number that conforms to the xsd:double specification",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"double\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"close_mappings": [ "close_mappings": [
@ -97,6 +112,9 @@
"name": "decimal", "name": "decimal",
"definition_uri": "https://w3id.org/linkml/Decimal", "definition_uri": "https://w3id.org/linkml/Decimal",
"description": "A real number with arbitrary precision that conforms to the xsd:decimal specification", "description": "A real number with arbitrary precision that conforms to the xsd:decimal specification",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"decimal\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"broad_mappings": [ "broad_mappings": [
@ -111,7 +129,8 @@
"definition_uri": "https://w3id.org/linkml/Time", "definition_uri": "https://w3id.org/linkml/Time",
"description": "A time object represents a (local) time of day, independent of any particular day", "description": "A time object represents a (local) time of day, independent of any particular day",
"notes": [ "notes": [
"URI is dateTime because OWL reasoners do not work with straight date or time" "URI is dateTime because OWL reasoners do not work with straight date or time",
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"time\"."
], ],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
@ -128,7 +147,8 @@
"definition_uri": "https://w3id.org/linkml/Date", "definition_uri": "https://w3id.org/linkml/Date",
"description": "a date (year, month and day) in an idealized calendar", "description": "a date (year, month and day) in an idealized calendar",
"notes": [ "notes": [
"URI is dateTime because OWL reasoners don't work with straight date or time" "URI is dateTime because OWL reasoners don't work with straight date or time",
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"date\"."
], ],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
@ -144,6 +164,9 @@
"name": "datetime", "name": "datetime",
"definition_uri": "https://w3id.org/linkml/Datetime", "definition_uri": "https://w3id.org/linkml/Datetime",
"description": "The combination of a date and time", "description": "The combination of a date and time",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"datetime\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"exact_mappings": [ "exact_mappings": [
@ -158,6 +181,9 @@
"name": "date_or_datetime", "name": "date_or_datetime",
"definition_uri": "https://w3id.org/linkml/DateOrDatetime", "definition_uri": "https://w3id.org/linkml/DateOrDatetime",
"description": "Either a date or a datetime", "description": "Either a date or a datetime",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"date_or_datetime\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"base": "str", "base": "str",
@ -169,6 +195,9 @@
"name": "uriorcurie", "name": "uriorcurie",
"definition_uri": "https://w3id.org/linkml/Uriorcurie", "definition_uri": "https://w3id.org/linkml/Uriorcurie",
"description": "a URI or a CURIE", "description": "a URI or a CURIE",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"uriorcurie\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"base": "URIorCURIE", "base": "URIorCURIE",
@ -181,6 +210,9 @@
"definition_uri": "https://w3id.org/linkml/Curie", "definition_uri": "https://w3id.org/linkml/Curie",
"conforms_to": "https://www.w3.org/TR/curie/", "conforms_to": "https://www.w3.org/TR/curie/",
"description": "a compact URI", "description": "a compact URI",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"curie\"."
],
"comments": [ "comments": [
"in RDF serializations this MUST be expanded to a URI", "in RDF serializations this MUST be expanded to a URI",
"in non-RDF serializations MAY be serialized as the compact representation" "in non-RDF serializations MAY be serialized as the compact representation"
@ -197,6 +229,9 @@
"definition_uri": "https://w3id.org/linkml/Uri", "definition_uri": "https://w3id.org/linkml/Uri",
"conforms_to": "https://www.ietf.org/rfc/rfc3987.txt", "conforms_to": "https://www.ietf.org/rfc/rfc3987.txt",
"description": "a complete URI", "description": "a complete URI",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"uri\"."
],
"comments": [ "comments": [
"in RDF serializations a slot with range of uri is treated as a literal or type xsd:anyURI unless it is an identifier or a reference to an identifier, in which case it is translated directly to a node" "in RDF serializations a slot with range of uri is treated as a literal or type xsd:anyURI unless it is an identifier or a reference to an identifier, in which case it is translated directly to a node"
], ],
@ -214,6 +249,9 @@
"name": "ncname", "name": "ncname",
"definition_uri": "https://w3id.org/linkml/Ncname", "definition_uri": "https://w3id.org/linkml/Ncname",
"description": "Prefix part of CURIE", "description": "Prefix part of CURIE",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"ncname\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"base": "NCName", "base": "NCName",
@ -225,6 +263,9 @@
"name": "objectidentifier", "name": "objectidentifier",
"definition_uri": "https://w3id.org/linkml/Objectidentifier", "definition_uri": "https://w3id.org/linkml/Objectidentifier",
"description": "A URI or CURIE that represents an object in the model.", "description": "A URI or CURIE that represents an object in the model.",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"objectidentifier\"."
],
"comments": [ "comments": [
"Used for inheritance and type checking" "Used for inheritance and type checking"
], ],
@ -239,6 +280,9 @@
"name": "nodeidentifier", "name": "nodeidentifier",
"definition_uri": "https://w3id.org/linkml/Nodeidentifier", "definition_uri": "https://w3id.org/linkml/Nodeidentifier",
"description": "A URI, CURIE or BNODE that represents a node in a model.", "description": "A URI, CURIE or BNODE that represents a node in a model.",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"nodeidentifier\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"base": "NodeIdentifier", "base": "NodeIdentifier",
@ -251,6 +295,9 @@
"definition_uri": "https://w3id.org/linkml/Jsonpointer", "definition_uri": "https://w3id.org/linkml/Jsonpointer",
"conforms_to": "https://datatracker.ietf.org/doc/html/rfc6901", "conforms_to": "https://datatracker.ietf.org/doc/html/rfc6901",
"description": "A string encoding a JSON Pointer. The value of the string MUST conform to JSON Point syntax and SHOULD dereference to a valid object within the current instance document when encoded in tree form.", "description": "A string encoding a JSON Pointer. The value of the string MUST conform to JSON Point syntax and SHOULD dereference to a valid object within the current instance document when encoded in tree form.",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"jsonpointer\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"base": "str", "base": "str",
@ -263,6 +310,9 @@
"definition_uri": "https://w3id.org/linkml/Jsonpath", "definition_uri": "https://w3id.org/linkml/Jsonpath",
"conforms_to": "https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html", "conforms_to": "https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html",
"description": "A string encoding a JSON Path. The value of the string MUST conform to JSON Point syntax and SHOULD dereference to zero or more valid objects within the current instance document when encoded in tree form.", "description": "A string encoding a JSON Path. The value of the string MUST conform to JSON Point syntax and SHOULD dereference to zero or more valid objects within the current instance document when encoded in tree form.",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"jsonpath\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"base": "str", "base": "str",
@ -275,6 +325,9 @@
"definition_uri": "https://w3id.org/linkml/Sparqlpath", "definition_uri": "https://w3id.org/linkml/Sparqlpath",
"conforms_to": "https://www.w3.org/TR/sparql11-query/#propertypaths", "conforms_to": "https://www.w3.org/TR/sparql11-query/#propertypaths",
"description": "A string encoding a SPARQL Property Path. The value of the string MUST conform to SPARQL syntax and SHOULD dereference to zero or more valid objects within the current instance document when encoded as RDF.", "description": "A string encoding a SPARQL Property Path. The value of the string MUST conform to SPARQL syntax and SHOULD dereference to zero or more valid objects within the current instance document when encoded as RDF.",
"notes": [
"If you are authoring schemas in LinkML YAML, the type is referenced with the lower case \"sparqlpath\"."
],
"from_schema": "https://w3id.org/linkml/types", "from_schema": "https://w3id.org/linkml/types",
"imported_from": "linkml:types", "imported_from": "linkml:types",
"base": "str", "base": "str",
@ -584,8 +637,9 @@
"definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/schema", "definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/schema",
"description": "List of the schema to be included in this namespace.", "description": "List of the schema to be included in this namespace.",
"from_schema": "https://w3id.org/p2p_ld/nwb-schema-language", "from_schema": "https://w3id.org/p2p_ld/nwb-schema-language",
"slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/schema", "slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/schema_",
"multivalued": true, "multivalued": true,
"alias": "schema_",
"owner": "Namespace", "owner": "Namespace",
"domain_of": [ "domain_of": [
"Namespace" "Namespace"
@ -677,6 +731,7 @@
{ {
"name": "neurodata_type_def", "name": "neurodata_type_def",
"definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/neurodata_type_def", "definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/neurodata_type_def",
"description": "Used alongside neurodata_type_inc to indicate inheritance, naming, and mixins",
"from_schema": "https://w3id.org/p2p_ld/nwb-schema-language", "from_schema": "https://w3id.org/p2p_ld/nwb-schema-language",
"slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/neurodata_type_def", "slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/neurodata_type_def",
"owner": "Dataset", "owner": "Dataset",
@ -695,6 +750,7 @@
{ {
"name": "neurodata_type_inc", "name": "neurodata_type_inc",
"definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/neurodata_type_inc", "definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/neurodata_type_inc",
"description": "Used alongside neurodata_type_def to indicate inheritance, naming, and mixins",
"from_schema": "https://w3id.org/p2p_ld/nwb-schema-language", "from_schema": "https://w3id.org/p2p_ld/nwb-schema-language",
"slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/neurodata_type_inc", "slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/neurodata_type_inc",
"owner": "Dataset", "owner": "Dataset",
@ -836,6 +892,7 @@
"definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/dtype", "definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/dtype",
"from_schema": "https://w3id.org/p2p_ld/nwb-schema-language", "from_schema": "https://w3id.org/p2p_ld/nwb-schema-language",
"slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/dtype", "slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/dtype",
"multivalued": true,
"owner": "DtypeMixin", "owner": "DtypeMixin",
"domain_of": [ "domain_of": [
"CompoundDtype", "CompoundDtype",
@ -862,7 +919,7 @@
"name": "dims", "name": "dims",
"definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/dims", "definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/dims",
"todos": [ "todos": [
"Can't quite figure out how to allow an array of arrays" "Can't quite figure out how to allow an array of arrays - see https://github.com/linkml/linkml/issues/895"
], ],
"from_schema": "https://w3id.org/p2p_ld/nwb-schema-language", "from_schema": "https://w3id.org/p2p_ld/nwb-schema-language",
"slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/dims", "slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/dims",
@ -873,13 +930,23 @@
"Dataset" "Dataset"
], ],
"range": "string", "range": "string",
"any_of": [
{
"range": "string",
"@type": "AnonymousSlotExpression"
},
{
"range": "AnyType",
"@type": "AnonymousSlotExpression"
}
],
"@type": "SlotDefinition" "@type": "SlotDefinition"
}, },
{ {
"name": "shape", "name": "shape",
"definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/shape", "definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/shape",
"todos": [ "todos": [
"Can't quite figure out how to allow an array of arrays" "Can't quite figure out how to allow an array of arrays - see https://github.com/linkml/linkml/issues/895"
], ],
"from_schema": "https://w3id.org/p2p_ld/nwb-schema-language", "from_schema": "https://w3id.org/p2p_ld/nwb-schema-language",
"slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/shape", "slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/shape",
@ -890,15 +957,20 @@
"Dataset" "Dataset"
], ],
"range": "string", "range": "string",
"exactly_one_of": [ "any_of": [
{ {
"range": "integer", "range": "integer",
"minimum_value": 1, "minimum_value": 1,
"@type": "AnonymousSlotExpression" "@type": "AnonymousSlotExpression"
}, },
{ {
"range": "string",
"equals_string": "null", "equals_string": "null",
"@type": "AnonymousSlotExpression" "@type": "AnonymousSlotExpression"
},
{
"range": "AnyType",
"@type": "AnonymousSlotExpression"
} }
], ],
"@type": "SlotDefinition" "@type": "SlotDefinition"
@ -960,16 +1032,6 @@
], ],
"range": "string", "range": "string",
"required": true, "required": true,
"any_of": [
{
"range": "Dataset",
"@type": "AnonymousSlotExpression"
},
{
"range": "Group",
"@type": "AnonymousSlotExpression"
}
],
"@type": "SlotDefinition" "@type": "SlotDefinition"
}, },
{ {
@ -1073,6 +1135,7 @@
"is_a": "dtype", "is_a": "dtype",
"domain": "CompoundDtype", "domain": "CompoundDtype",
"slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/dtype", "slot_uri": "https://w3id.org/p2p_ld/nwb-schema-language/dtype",
"multivalued": true,
"alias": "dtype", "alias": "dtype",
"owner": "CompoundDtype", "owner": "CompoundDtype",
"domain_of": [ "domain_of": [
@ -1080,20 +1143,16 @@
], ],
"is_usage_slot": true, "is_usage_slot": true,
"usage_slot_name": "dtype", "usage_slot_name": "dtype",
"range": "FlatDtype", "range": "string",
"required": true, "required": true,
"any_of": [ "any_of": [
{
"range": "FlatDtype",
"@type": "AnonymousSlotExpression"
},
{
"range": "CompoundDtype",
"@type": "AnonymousSlotExpression"
},
{ {
"range": "ReferenceDtype", "range": "ReferenceDtype",
"@type": "AnonymousSlotExpression" "@type": "AnonymousSlotExpression"
},
{
"range": "FlatDtype",
"@type": "AnonymousSlotExpression"
} }
], ],
"@type": "SlotDefinition" "@type": "SlotDefinition"
@ -1270,9 +1329,6 @@
"name": "Group", "name": "Group",
"definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/Group", "definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/Group",
"from_schema": "https://w3id.org/p2p_ld/nwb-schema-language", "from_schema": "https://w3id.org/p2p_ld/nwb-schema-language",
"mixins": [
"NamingMixin"
],
"slots": [ "slots": [
"neurodata_type_def", "neurodata_type_def",
"neurodata_type_inc", "neurodata_type_inc",
@ -1341,8 +1397,7 @@
"definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/Dataset", "definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/Dataset",
"from_schema": "https://w3id.org/p2p_ld/nwb-schema-language", "from_schema": "https://w3id.org/p2p_ld/nwb-schema-language",
"mixins": [ "mixins": [
"DtypeMixin", "DtypeMixin"
"NamingMixin"
], ],
"slots": [ "slots": [
"neurodata_type_def", "neurodata_type_def",
@ -1415,7 +1470,7 @@
"slot_conditions": [ "slot_conditions": [
{ {
"name": "dtype", "name": "dtype",
"range": "CompoundDtype", "range": "FlatDtype",
"@type": "SlotDefinition" "@type": "SlotDefinition"
} }
], ],
@ -1425,7 +1480,6 @@
"slot_conditions": [ "slot_conditions": [
{ {
"name": "dtype", "name": "dtype",
"multivalued": true,
"@type": "SlotDefinition" "@type": "SlotDefinition"
} }
], ],
@ -1436,72 +1490,6 @@
], ],
"@type": "ClassDefinition" "@type": "ClassDefinition"
}, },
{
"name": "NamingMixin",
"definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/NamingMixin",
"description": "require either neurodata_type_def or name to be present",
"from_schema": "https://w3id.org/p2p_ld/nwb-schema-language",
"mixin": true,
"slot_usage": {},
"class_uri": "https://w3id.org/p2p_ld/nwb-schema-language/NamingMixin",
"rules": [
{
"preconditions": {
"slot_conditions": [
{
"name": "neurodata_type_def",
"value_presence": {
"text": "ABSENT",
"@type": "PermissibleValue"
},
"@type": "SlotDefinition"
}
],
"@type": "AnonymousClassExpression"
},
"postconditions": {
"slot_conditions": [
{
"name": "name",
"required": true,
"@type": "SlotDefinition"
}
],
"@type": "AnonymousClassExpression"
},
"description": "If not defining a new type, a name is required",
"@type": "ClassRule"
},
{
"preconditions": {
"slot_conditions": [
{
"name": "name",
"value_presence": {
"text": "ABSENT",
"@type": "PermissibleValue"
},
"@type": "SlotDefinition"
}
],
"@type": "AnonymousClassExpression"
},
"postconditions": {
"slot_conditions": [
{
"name": "neurodata_type_def",
"required": true,
"@type": "SlotDefinition"
}
],
"@type": "AnonymousClassExpression"
},
"description": "If a name is not given, must be defining a new type",
"@type": "ClassRule"
}
],
"@type": "ClassDefinition"
},
{ {
"name": "AnyType", "name": "AnyType",
"definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/AnyType", "definition_uri": "https://w3id.org/p2p_ld/nwb-schema-language/AnyType",
@ -1516,9 +1504,9 @@
], ],
"metamodel_version": "1.7.0", "metamodel_version": "1.7.0",
"source_file": "nwb_schema_language.yaml", "source_file": "nwb_schema_language.yaml",
"source_file_date": "2023-08-18T00:28:45", "source_file_date": "2023-08-30T20:53:55",
"source_file_size": 10952, "source_file_size": 10793,
"generation_date": "2023-08-18T00:36:53", "generation_date": "2023-08-30T20:53:59",
"settings": [ "settings": [
{ {
"setting_key": "email", "setting_key": "email",

View file

@ -16,6 +16,14 @@
}, },
"dims": { "dims": {
"items": { "items": {
"anyOf": [
{
"type": "string"
},
{
"$ref": "#/$defs/AnyType"
}
],
"type": "string" "type": "string"
}, },
"type": "array" "type": "array"
@ -25,18 +33,21 @@
"type": "string" "type": "string"
}, },
"dtype": { "dtype": {
"anyOf": [ "items": {
{ "anyOf": [
"$ref": "#/$defs/FlatDtype" {
}, "$ref": "#/$defs/FlatDtype"
{ },
"$ref": "#/$defs/CompoundDtype" {
}, "$ref": "#/$defs/CompoundDtype"
{ },
"$ref": "#/$defs/ReferenceDtype" {
} "$ref": "#/$defs/ReferenceDtype"
], }
"type": "string" ],
"type": "string"
},
"type": "array"
}, },
"name": { "name": {
"type": "string" "type": "string"
@ -47,13 +58,17 @@
}, },
"shape": { "shape": {
"items": { "items": {
"oneOf": [ "anyOf": [
{ {
"minimum": 1, "minimum": 1,
"type": "integer" "type": "integer"
}, },
{ {
"const": "null" "const": "null",
"type": "string"
},
{
"$ref": "#/$defs/AnyType"
} }
], ],
"type": "string" "type": "string"
@ -81,7 +96,15 @@
"type": "string" "type": "string"
}, },
"dtype": { "dtype": {
"$ref": "#/$defs/FlatDtype" "anyOf": [
{
"$ref": "#/$defs/ReferenceDtype"
},
{
"$ref": "#/$defs/FlatDtype"
}
],
"type": "string"
}, },
"name": { "name": {
"type": "string" "type": "string"
@ -114,6 +137,14 @@
}, },
"dims": { "dims": {
"items": { "items": {
"anyOf": [
{
"type": "string"
},
{
"$ref": "#/$defs/AnyType"
}
],
"type": "string" "type": "string"
}, },
"type": "array" "type": "array"
@ -123,18 +154,21 @@
"type": "string" "type": "string"
}, },
"dtype": { "dtype": {
"anyOf": [ "items": {
{ "anyOf": [
"$ref": "#/$defs/FlatDtype" {
}, "$ref": "#/$defs/FlatDtype"
{ },
"$ref": "#/$defs/CompoundDtype" {
}, "$ref": "#/$defs/CompoundDtype"
{ },
"$ref": "#/$defs/ReferenceDtype" {
} "$ref": "#/$defs/ReferenceDtype"
], }
"type": "string" ],
"type": "string"
},
"type": "array"
}, },
"linkable": { "linkable": {
"type": "boolean" "type": "boolean"
@ -143,9 +177,11 @@
"type": "string" "type": "string"
}, },
"neurodata_type_def": { "neurodata_type_def": {
"description": "Used alongside neurodata_type_inc to indicate inheritance, naming, and mixins",
"type": "string" "type": "string"
}, },
"neurodata_type_inc": { "neurodata_type_inc": {
"description": "Used alongside neurodata_type_def to indicate inheritance, naming, and mixins",
"type": "string" "type": "string"
}, },
"quantity": { "quantity": {
@ -162,13 +198,17 @@
}, },
"shape": { "shape": {
"items": { "items": {
"oneOf": [ "anyOf": [
{ {
"minimum": 1, "minimum": 1,
"type": "integer" "type": "integer"
}, },
{ {
"const": "null" "const": "null",
"type": "string"
},
{
"$ref": "#/$defs/AnyType"
} }
], ],
"type": "string" "type": "string"
@ -273,9 +313,11 @@
"type": "string" "type": "string"
}, },
"neurodata_type_def": { "neurodata_type_def": {
"description": "Used alongside neurodata_type_inc to indicate inheritance, naming, and mixins",
"type": "string" "type": "string"
}, },
"neurodata_type_inc": { "neurodata_type_inc": {
"description": "Used alongside neurodata_type_def to indicate inheritance, naming, and mixins",
"type": "string" "type": "string"
}, },
"quantity": { "quantity": {
@ -335,14 +377,6 @@
"type": "string" "type": "string"
}, },
"target_type": { "target_type": {
"anyOf": [
{
"$ref": "#/$defs/Dataset"
},
{
"$ref": "#/$defs/Group"
}
],
"description": "Describes the neurodata_type of the target that the reference points to", "description": "Describes the neurodata_type of the target that the reference points to",
"type": "string" "type": "string"
} }
@ -388,7 +422,7 @@
"name": { "name": {
"type": "string" "type": "string"
}, },
"schema": { "schema_": {
"description": "List of the schema to be included in this namespace.", "description": "List of the schema to be included in this namespace.",
"items": { "items": {
"$ref": "#/$defs/Schema" "$ref": "#/$defs/Schema"
@ -446,14 +480,6 @@
"description": "describes the kind of reference" "description": "describes the kind of reference"
}, },
"target_type": { "target_type": {
"anyOf": [
{
"$ref": "#/$defs/Dataset"
},
{
"$ref": "#/$defs/Group"
}
],
"description": "Describes the neurodata_type of the target that the reference points to", "description": "Describes the neurodata_type of the target that the reference points to",
"type": "string" "type": "string"
} }

View file

@ -7,13 +7,13 @@ message Attribute
anyType defaultValue = 0 anyType defaultValue = 0
string doc = 0 string doc = 0
boolean required = 0 boolean required = 0
string dtype = 0 repeated string dtype = 0
} }
message CompoundDtype message CompoundDtype
{ {
string name = 0 string name = 0
string doc = 0 string doc = 0
flatDtype dtype = 0 repeated string dtype = 0
} }
message Dataset message Dataset
{ {
@ -29,7 +29,7 @@ message Dataset
string quantity = 0 string quantity = 0
boolean linkable = 0 boolean linkable = 0
repeated attribute attributes = 0 repeated attribute attributes = 0
string dtype = 0 repeated string dtype = 0
} }
message Datasets message Datasets
{ {

View file

@ -59,7 +59,7 @@ linkml:Sparqlpath xsd:string
<default_value> @<AnyType> ? ; <default_value> @<AnyType> ? ;
<doc> @linkml:String ; <doc> @linkml:String ;
<required> @linkml:Boolean ? ; <required> @linkml:Boolean ? ;
<dtype> @linkml:String ? <dtype> @linkml:String *
) ; ) ;
rdf:type [ <Attribute> ] ? rdf:type [ <Attribute> ] ?
) )
@ -68,7 +68,7 @@ linkml:Sparqlpath xsd:string
<CompoundDtype> CLOSED { <CompoundDtype> CLOSED {
( $<CompoundDtype_tes> ( <name> @linkml:String ; ( $<CompoundDtype_tes> ( <name> @linkml:String ;
<doc> @linkml:String ; <doc> @linkml:String ;
<dtype> @<FlatDtype> <dtype> @linkml:String +
) ; ) ;
rdf:type [ <CompoundDtype> ] ? rdf:type [ <CompoundDtype> ] ?
) )
@ -77,8 +77,6 @@ linkml:Sparqlpath xsd:string
<Dataset> CLOSED { <Dataset> CLOSED {
( $<Dataset_tes> ( &<DtypeMixin_tes> ; ( $<Dataset_tes> ( &<DtypeMixin_tes> ;
rdf:type [ <DtypeMixin> ] ? ; rdf:type [ <DtypeMixin> ] ? ;
&<NamingMixin_tes> ;
rdf:type [ <NamingMixin> ] ? ;
<neurodata_type_def> @linkml:String ? ; <neurodata_type_def> @linkml:String ? ;
<neurodata_type_inc> @linkml:String ? ; <neurodata_type_inc> @linkml:String ? ;
<name> @linkml:String ? ; <name> @linkml:String ? ;
@ -91,7 +89,7 @@ linkml:Sparqlpath xsd:string
<quantity> @linkml:String ? ; <quantity> @linkml:String ? ;
<linkable> @linkml:Boolean ? ; <linkable> @linkml:Boolean ? ;
<attributes> @<Attribute> * ; <attributes> @<Attribute> * ;
<dtype> @linkml:String ? <dtype> @linkml:String *
) ; ) ;
rdf:type [ <Dataset> ] ? rdf:type [ <Dataset> ] ?
) )
@ -104,15 +102,13 @@ linkml:Sparqlpath xsd:string
} }
<DtypeMixin> { <DtypeMixin> {
( $<DtypeMixin_tes> <dtype> @linkml:String ? ; ( $<DtypeMixin_tes> <dtype> @linkml:String * ;
rdf:type [ <DtypeMixin> ] ? rdf:type [ <DtypeMixin> ] ?
) )
} }
<Group> CLOSED { <Group> CLOSED {
( $<Group_tes> ( &<NamingMixin_tes> ; ( $<Group_tes> ( <neurodata_type_def> @linkml:String ? ;
rdf:type [ <NamingMixin> ] ? ;
<neurodata_type_def> @linkml:String ? ;
<neurodata_type_inc> @linkml:String ? ; <neurodata_type_inc> @linkml:String ? ;
<name> @linkml:String ? ; <name> @linkml:String ? ;
<default_name> @linkml:String ? ; <default_name> @linkml:String ? ;
@ -152,7 +148,7 @@ linkml:Sparqlpath xsd:string
schema1:dateModified @linkml:Date ? ; schema1:dateModified @linkml:Date ? ;
schema1:author @linkml:String + ; schema1:author @linkml:String + ;
schema1:email @linkml:String + ; schema1:email @linkml:String + ;
<schema> @<Schema> * <schema_> @<Schema> *
) ; ) ;
rdf:type [ <Namespace> ] ? rdf:type [ <Namespace> ] ?
) )
@ -164,12 +160,6 @@ linkml:Sparqlpath xsd:string
) )
} }
<NamingMixin> {
( $<NamingMixin_tes> rdf:type . * ;
rdf:type [ <NamingMixin> ] ?
)
}
<ReferenceDtype> CLOSED { <ReferenceDtype> CLOSED {
( $<ReferenceDtype_tes> ( <target_type> @linkml:String ; ( $<ReferenceDtype_tes> ( <target_type> @linkml:String ;
<reftype> @<ReftypeOptions> ? <reftype> @<ReftypeOptions> ?

View file

@ -15,7 +15,7 @@ CREATE TABLE "Attribute" (
CREATE TABLE "CompoundDtype" ( CREATE TABLE "CompoundDtype" (
name TEXT NOT NULL, name TEXT NOT NULL,
doc TEXT NOT NULL, doc TEXT NOT NULL,
dtype VARCHAR(11) NOT NULL, dtype TEXT NOT NULL,
PRIMARY KEY (name, doc, dtype) PRIMARY KEY (name, doc, dtype)
); );
@ -77,8 +77,8 @@ CREATE TABLE "Namespace" (
date DATE, date DATE,
author TEXT NOT NULL, author TEXT NOT NULL,
contact TEXT NOT NULL, contact TEXT NOT NULL,
schema TEXT, schema_ TEXT,
PRIMARY KEY (doc, name, full_name, version, date, author, contact, schema) PRIMARY KEY (doc, name, full_name, version, date, author, contact, schema_)
); );
CREATE TABLE "Namespaces" ( CREATE TABLE "Namespaces" (

View file

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "nwb_schema_language" name = "nwb_schema_language"
version = "0.1.0" version = "0.1.1"
description = "Translation of the nwb-schema-language to LinkML" description = "Translation of the nwb-schema-language to LinkML"
authors = ["Jonny Saunders <j@nny.fyi>"] authors = ["Jonny Saunders <j@nny.fyi>"]
license = "GNU GPL v3.0" license = "GNU GPL v3.0"

View file

@ -1,9 +1,9 @@
# Auto generated from nwb_schema_language.yaml by pythongen.py version: 0.0.1 # Auto generated from nwb_schema_language.yaml by pythongen.py version: 0.0.1
# Generation date: 2023-08-18T00:36:55 # Generation date: 2023-08-30T20:54:02
# Schema: nwb_schema_language # Schema: nwb-schema-language
# #
# id: https://w3id.org/p2p_ld/nwb-schema-language # id: https://w3id.org/p2p_ld/nwb-schema-language
# description: Translation of the nwb_schema_language to LinkML # description: Translation of the nwb-schema-language to LinkML
# license: GNU GPL v3.0 # license: GNU GPL v3.0
import dataclasses import dataclasses
@ -59,7 +59,7 @@ class Namespace(YAMLRoot):
contact: Union[str, List[str]] = None contact: Union[str, List[str]] = None
full_name: Optional[str] = None full_name: Optional[str] = None
date: Optional[Union[str, XSDDate]] = None date: Optional[Union[str, XSDDate]] = None
schema: Optional[Union[Union[dict, "Schema"], List[Union[dict, "Schema"]]]] = empty_list() schema_: Optional[Union[Union[dict, "Schema"], List[Union[dict, "Schema"]]]] = empty_list()
def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]): def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
if self._is_empty(self.doc): if self._is_empty(self.doc):
@ -95,9 +95,9 @@ class Namespace(YAMLRoot):
if self.date is not None and not isinstance(self.date, XSDDate): if self.date is not None and not isinstance(self.date, XSDDate):
self.date = XSDDate(self.date) self.date = XSDDate(self.date)
if not isinstance(self.schema, list): if not isinstance(self.schema_, list):
self.schema = [self.schema] if self.schema is not None else [] self.schema_ = [self.schema_] if self.schema_ is not None else []
self.schema = [v if isinstance(v, Schema) else Schema(**as_dict(v)) for v in self.schema] self.schema_ = [v if isinstance(v, Schema) else Schema(**as_dict(v)) for v in self.schema_]
super().__post_init__(**kwargs) super().__post_init__(**kwargs)
@ -251,7 +251,7 @@ class Attribute(YAMLRoot):
value: Optional[Union[dict, "AnyType"]] = None value: Optional[Union[dict, "AnyType"]] = None
default_value: Optional[Union[dict, "AnyType"]] = None default_value: Optional[Union[dict, "AnyType"]] = None
required: Optional[Union[bool, Bool]] = True required: Optional[Union[bool, Bool]] = True
dtype: Optional[str] = None dtype: Optional[Union[str, List[str]]] = empty_list()
def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]): def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
if self._is_empty(self.name): if self._is_empty(self.name):
@ -275,8 +275,9 @@ class Attribute(YAMLRoot):
if self.required is not None and not isinstance(self.required, Bool): if self.required is not None and not isinstance(self.required, Bool):
self.required = Bool(self.required) self.required = Bool(self.required)
if self.dtype is not None and not isinstance(self.dtype, str): if not isinstance(self.dtype, list):
self.dtype = str(self.dtype) self.dtype = [self.dtype] if self.dtype is not None else []
self.dtype = [v if isinstance(v, str) else str(v) for v in self.dtype]
super().__post_init__(**kwargs) super().__post_init__(**kwargs)
@ -336,7 +337,7 @@ class Dataset(YAMLRoot):
quantity: Optional[str] = 1 quantity: Optional[str] = 1
linkable: Optional[Union[bool, Bool]] = None linkable: Optional[Union[bool, Bool]] = None
attributes: Optional[Union[Union[dict, Attribute], List[Union[dict, Attribute]]]] = empty_list() attributes: Optional[Union[Union[dict, Attribute], List[Union[dict, Attribute]]]] = empty_list()
dtype: Optional[str] = None dtype: Optional[Union[str, List[str]]] = empty_list()
def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]): def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
if self._is_empty(self.doc): if self._is_empty(self.doc):
@ -372,8 +373,9 @@ class Dataset(YAMLRoot):
self._normalize_inlined_as_dict(slot_name="attributes", slot_type=Attribute, key_name="name", keyed=False) self._normalize_inlined_as_dict(slot_name="attributes", slot_type=Attribute, key_name="name", keyed=False)
if self.dtype is not None and not isinstance(self.dtype, str): if not isinstance(self.dtype, list):
self.dtype = str(self.dtype) self.dtype = [self.dtype] if self.dtype is not None else []
self.dtype = [v if isinstance(v, str) else str(v) for v in self.dtype]
super().__post_init__(**kwargs) super().__post_init__(**kwargs)
@ -432,7 +434,7 @@ class CompoundDtype(YAMLRoot):
name: str = None name: str = None
doc: str = None doc: str = None
dtype: Union[str, "FlatDtype"] = None dtype: Union[str, List[str]] = None
def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]): def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
if self._is_empty(self.name): if self._is_empty(self.name):
@ -447,8 +449,9 @@ class CompoundDtype(YAMLRoot):
if self._is_empty(self.dtype): if self._is_empty(self.dtype):
self.MissingRequiredField("dtype") self.MissingRequiredField("dtype")
if not isinstance(self.dtype, FlatDtype): if not isinstance(self.dtype, list):
self.dtype = FlatDtype(self.dtype) self.dtype = [self.dtype] if self.dtype is not None else []
self.dtype = [v if isinstance(v, str) else str(v) for v in self.dtype]
super().__post_init__(**kwargs) super().__post_init__(**kwargs)
@ -462,27 +465,16 @@ class DtypeMixin(YAMLRoot):
class_name: ClassVar[str] = "DtypeMixin" class_name: ClassVar[str] = "DtypeMixin"
class_model_uri: ClassVar[URIRef] = NWB_SCHEMA_LANGUAGE.DtypeMixin class_model_uri: ClassVar[URIRef] = NWB_SCHEMA_LANGUAGE.DtypeMixin
dtype: Optional[str] = None dtype: Optional[Union[str, List[str]]] = empty_list()
def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]): def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
if self.dtype is not None and not isinstance(self.dtype, str): if not isinstance(self.dtype, list):
self.dtype = str(self.dtype) self.dtype = [self.dtype] if self.dtype is not None else []
self.dtype = [v if isinstance(v, str) else str(v) for v in self.dtype]
super().__post_init__(**kwargs) super().__post_init__(**kwargs)
class NamingMixin(YAMLRoot):
"""
require either neurodata_type_def or name to be present
"""
_inherited_slots: ClassVar[List[str]] = []
class_class_uri: ClassVar[URIRef] = NWB_SCHEMA_LANGUAGE.NamingMixin
class_class_curie: ClassVar[str] = "nwb_schema_language:NamingMixin"
class_name: ClassVar[str] = "NamingMixin"
class_model_uri: ClassVar[URIRef] = NWB_SCHEMA_LANGUAGE.NamingMixin
AnyType = Any AnyType = Any
# Enumerations # Enumerations
@ -645,7 +637,7 @@ slots.author = Slot(uri=SCHEMA.author, name="author", curie=SCHEMA.curie('author
slots.contact = Slot(uri=SCHEMA.email, name="contact", curie=SCHEMA.curie('email'), slots.contact = Slot(uri=SCHEMA.email, name="contact", curie=SCHEMA.curie('email'),
model_uri=NWB_SCHEMA_LANGUAGE.contact, domain=None, range=Union[str, List[str]]) model_uri=NWB_SCHEMA_LANGUAGE.contact, domain=None, range=Union[str, List[str]])
slots.schema = Slot(uri=NWB_SCHEMA_LANGUAGE.schema, name="schema", curie=NWB_SCHEMA_LANGUAGE.curie('schema'), slots.schema = Slot(uri=NWB_SCHEMA_LANGUAGE.schema_, name="schema", curie=NWB_SCHEMA_LANGUAGE.curie('schema_'),
model_uri=NWB_SCHEMA_LANGUAGE.schema, domain=None, range=Optional[Union[Union[dict, Schema], List[Union[dict, Schema]]]]) model_uri=NWB_SCHEMA_LANGUAGE.schema, domain=None, range=Optional[Union[Union[dict, Schema], List[Union[dict, Schema]]]])
slots.source = Slot(uri=NWB_SCHEMA_LANGUAGE.source, name="source", curie=NWB_SCHEMA_LANGUAGE.curie('source'), slots.source = Slot(uri=NWB_SCHEMA_LANGUAGE.source, name="source", curie=NWB_SCHEMA_LANGUAGE.curie('source'),
@ -692,7 +684,7 @@ slots.links = Slot(uri=NWB_SCHEMA_LANGUAGE.links, name="links", curie=NWB_SCHEMA
model_uri=NWB_SCHEMA_LANGUAGE.links, domain=None, range=Optional[Union[Union[dict, Link], List[Union[dict, Link]]]]) model_uri=NWB_SCHEMA_LANGUAGE.links, domain=None, range=Optional[Union[Union[dict, Link], List[Union[dict, Link]]]])
slots.dtype = Slot(uri=NWB_SCHEMA_LANGUAGE.dtype, name="dtype", curie=NWB_SCHEMA_LANGUAGE.curie('dtype'), slots.dtype = Slot(uri=NWB_SCHEMA_LANGUAGE.dtype, name="dtype", curie=NWB_SCHEMA_LANGUAGE.curie('dtype'),
model_uri=NWB_SCHEMA_LANGUAGE.dtype, domain=None, range=Optional[str]) model_uri=NWB_SCHEMA_LANGUAGE.dtype, domain=None, range=Optional[Union[str, List[str]]])
slots.dims = Slot(uri=NWB_SCHEMA_LANGUAGE.dims, name="dims", curie=NWB_SCHEMA_LANGUAGE.curie('dims'), slots.dims = Slot(uri=NWB_SCHEMA_LANGUAGE.dims, name="dims", curie=NWB_SCHEMA_LANGUAGE.curie('dims'),
model_uri=NWB_SCHEMA_LANGUAGE.dims, domain=None, range=Optional[Union[str, List[str]]]) model_uri=NWB_SCHEMA_LANGUAGE.dims, domain=None, range=Optional[Union[str, List[str]]])
@ -728,4 +720,4 @@ slots.CompoundDtype_name = Slot(uri=NWB_SCHEMA_LANGUAGE.name, name="CompoundDtyp
model_uri=NWB_SCHEMA_LANGUAGE.CompoundDtype_name, domain=CompoundDtype, range=str) model_uri=NWB_SCHEMA_LANGUAGE.CompoundDtype_name, domain=CompoundDtype, range=str)
slots.CompoundDtype_dtype = Slot(uri=NWB_SCHEMA_LANGUAGE.dtype, name="CompoundDtype_dtype", curie=NWB_SCHEMA_LANGUAGE.curie('dtype'), slots.CompoundDtype_dtype = Slot(uri=NWB_SCHEMA_LANGUAGE.dtype, name="CompoundDtype_dtype", curie=NWB_SCHEMA_LANGUAGE.curie('dtype'),
model_uri=NWB_SCHEMA_LANGUAGE.CompoundDtype_dtype, domain=CompoundDtype, range=Union[str, "FlatDtype"]) model_uri=NWB_SCHEMA_LANGUAGE.CompoundDtype_dtype, domain=CompoundDtype, range=Union[str, List[str]])

View file

@ -135,6 +135,21 @@ class Schema(ConfiguredBaseModel):
doc: Optional[str] = Field(None) doc: Optional[str] = Field(None)
class Group(ConfiguredBaseModel):
neurodata_type_def: Optional[str] = Field(None, description="""Used alongside neurodata_type_inc to indicate inheritance, naming, and mixins""")
neurodata_type_inc: Optional[str] = Field(None, description="""Used alongside neurodata_type_def to indicate inheritance, naming, and mixins""")
name: Optional[str] = Field(None)
default_name: Optional[str] = Field(None)
doc: str = Field(..., description="""Description of corresponding object.""")
quantity: Optional[Union[QuantityEnum, int]] = Field(1)
linkable: Optional[bool] = Field(None)
attributes: Optional[List[Attribute]] = Field(default_factory=list)
datasets: Optional[List[Dataset]] = Field(default_factory=list)
groups: Optional[List[Group]] = Field(default_factory=list)
links: Optional[List[Link]] = Field(default_factory=list)
class Groups(ConfiguredBaseModel): class Groups(ConfiguredBaseModel):
groups: Optional[List[Group]] = Field(default_factory=list) groups: Optional[List[Group]] = Field(default_factory=list)
@ -183,29 +198,7 @@ class Attribute(DtypeMixin):
dtype: Optional[Union[List[CompoundDtype], FlatDtype, ReferenceDtype]] = Field(default_factory=list) dtype: Optional[Union[List[CompoundDtype], FlatDtype, ReferenceDtype]] = Field(default_factory=list)
class NamingMixin(ConfiguredBaseModel): class Dataset(DtypeMixin):
"""
require either neurodata_type_def or name to be present
"""
None
class Group(NamingMixin):
neurodata_type_def: Optional[str] = Field(None, description="""Used alongside neurodata_type_inc to indicate inheritance, naming, and mixins""")
neurodata_type_inc: Optional[str] = Field(None, description="""Used alongside neurodata_type_def to indicate inheritance, naming, and mixins""")
name: Optional[str] = Field(None)
default_name: Optional[str] = Field(None)
doc: str = Field(..., description="""Description of corresponding object.""")
quantity: Optional[Union[QuantityEnum, int]] = Field(1)
linkable: Optional[bool] = Field(None)
attributes: Optional[List[Attribute]] = Field(default_factory=list)
datasets: Optional[List[Dataset]] = Field(default_factory=list)
groups: Optional[List[Group]] = Field(default_factory=list)
links: Optional[List[Link]] = Field(default_factory=list)
class Dataset(NamingMixin, DtypeMixin):
neurodata_type_def: Optional[str] = Field(None, description="""Used alongside neurodata_type_inc to indicate inheritance, naming, and mixins""") neurodata_type_def: Optional[str] = Field(None, description="""Used alongside neurodata_type_inc to indicate inheritance, naming, and mixins""")
neurodata_type_inc: Optional[str] = Field(None, description="""Used alongside neurodata_type_def to indicate inheritance, naming, and mixins""") neurodata_type_inc: Optional[str] = Field(None, description="""Used alongside neurodata_type_def to indicate inheritance, naming, and mixins""")
@ -219,7 +212,6 @@ class Dataset(NamingMixin, DtypeMixin):
quantity: Optional[Union[QuantityEnum, int]] = Field(1) quantity: Optional[Union[QuantityEnum, int]] = Field(1)
linkable: Optional[bool] = Field(None) linkable: Optional[bool] = Field(None)
attributes: Optional[List[Attribute]] = Field(default_factory=list) attributes: Optional[List[Attribute]] = Field(default_factory=list)
datasets: Optional[List[Dataset]] = Field(default_factory=list)
dtype: Optional[Union[List[CompoundDtype], FlatDtype, ReferenceDtype]] = Field(default_factory=list) dtype: Optional[Union[List[CompoundDtype], FlatDtype, ReferenceDtype]] = Field(default_factory=list)
@ -229,6 +221,7 @@ class Dataset(NamingMixin, DtypeMixin):
Namespace.update_forward_refs() Namespace.update_forward_refs()
Namespaces.update_forward_refs() Namespaces.update_forward_refs()
Schema.update_forward_refs() Schema.update_forward_refs()
Group.update_forward_refs()
Groups.update_forward_refs() Groups.update_forward_refs()
Link.update_forward_refs() Link.update_forward_refs()
Datasets.update_forward_refs() Datasets.update_forward_refs()
@ -236,7 +229,5 @@ ReferenceDtype.update_forward_refs()
CompoundDtype.update_forward_refs() CompoundDtype.update_forward_refs()
DtypeMixin.update_forward_refs() DtypeMixin.update_forward_refs()
Attribute.update_forward_refs() Attribute.update_forward_refs()
NamingMixin.update_forward_refs()
Group.update_forward_refs()
Dataset.update_forward_refs() Dataset.update_forward_refs()

View file

@ -66,8 +66,6 @@ classes:
description: If source is present, namespace cannot be. description: If source is present, namespace cannot be.
Group: Group:
mixins:
- NamingMixin
slots: slots:
- neurodata_type_def - neurodata_type_def
- neurodata_type_inc - neurodata_type_inc
@ -110,7 +108,6 @@ classes:
Dataset: Dataset:
mixins: mixins:
- DtypeMixin - DtypeMixin
- NamingMixin
slots: slots:
- neurodata_type_def - neurodata_type_def
- neurodata_type_inc - neurodata_type_inc
@ -124,7 +121,6 @@ classes:
- quantity - quantity
- linkable - linkable
- attributes - attributes
- groups
Datasets: Datasets:
slots: slots:
@ -164,17 +160,6 @@ classes:
dtype: dtype:
multivalued: false multivalued: false
NamingMixin:
mixin: true
description: require either neurodata_type_def or name to be present
rules:
- preconditions: { slot_conditions: { neurodata_type_def: { value_presence: ABSENT } } }
postconditions: { slot_conditions: { name: { required: true } } }
description: If not defining a new type, a name is required
- preconditions: { slot_conditions: { name: { value_presence: ABSENT } } }
postconditions: { slot_conditions: { neurodata_type_def: { required: true } } }
description: If a name is not given, must be defining a new type
AnyType: AnyType:
class_uri: linkml:Any class_uri: linkml:Any