mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2024-11-10 00:34:29 +00:00
getting started doing hdmf mixins but am tired
This commit is contained in:
parent
c98f25f973
commit
baa5471af7
5 changed files with 38 additions and 10 deletions
|
@ -62,7 +62,7 @@ from pydantic import BaseModel
|
||||||
|
|
||||||
from nwb_linkml.maps import flat_to_nptyping
|
from nwb_linkml.maps import flat_to_nptyping
|
||||||
from nwb_linkml.maps.naming import module_case, version_module_case
|
from nwb_linkml.maps.naming import module_case, version_module_case
|
||||||
from nwb_linkml.includes import ModelTypeString, _get_name, NamedString, NamedImports
|
from nwb_linkml.includes.types import ModelTypeString, _get_name, NamedString, NamedImports
|
||||||
|
|
||||||
OPTIONAL_PATTERN = re.compile(r"Optional\[([\w\.]*)\]")
|
OPTIONAL_PATTERN = re.compile(r"Optional\[([\w\.]*)\]")
|
||||||
|
|
||||||
|
|
0
nwb_linkml/src/nwb_linkml/includes/__init__.py
Normal file
0
nwb_linkml/src/nwb_linkml/includes/__init__.py
Normal file
37
nwb_linkml/src/nwb_linkml/includes/hdmf.py
Normal file
37
nwb_linkml/src/nwb_linkml/includes/hdmf.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
"""
|
||||||
|
Special types for mimicking HDMF special case behavior
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
from pydantic import BaseModel, field_validator, ConfigDict, model_validator
|
||||||
|
|
||||||
|
|
||||||
|
class DynamicTableMixin(BaseModel):
|
||||||
|
model_config = ConfigDict(extra='allow')
|
||||||
|
|
||||||
|
@model_validator(mode='after')
|
||||||
|
def ensure_equal_length(cls, model: 'DynamicTableMixin') -> 'DynamicTableMixin':
|
||||||
|
"""
|
||||||
|
Ensure all vectors are of equal length
|
||||||
|
"""
|
||||||
|
raise NotImplementedError('TODO')
|
||||||
|
|
||||||
|
@model_validator(mode="after")
|
||||||
|
def create_index_backrefs(cls, model: 'DynamicTableMixin') -> 'DynamicTableMixin':
|
||||||
|
"""
|
||||||
|
Ensure that vectordata with vectorindexes know about them
|
||||||
|
"""
|
||||||
|
raise NotImplementedError('TODO')
|
||||||
|
|
||||||
|
def __getitem__(self, item):
|
||||||
|
raise NotImplementedError('TODO')
|
||||||
|
|
||||||
|
def __setitem__(self, key, value):
|
||||||
|
raise NotImplementedError('TODO')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class VectorDataMixin(BaseModel):
|
||||||
|
index: Optional[BaseModel] = None
|
||||||
|
|
||||||
|
|
|
@ -7,20 +7,12 @@ from typing import List
|
||||||
|
|
||||||
from linkml_runtime.linkml_model import (
|
from linkml_runtime.linkml_model import (
|
||||||
ClassDefinition,
|
ClassDefinition,
|
||||||
EnumDefinition,
|
|
||||||
PermissibleValue,
|
|
||||||
Prefix,
|
Prefix,
|
||||||
SchemaDefinition,
|
SchemaDefinition,
|
||||||
TypeDefinition,
|
TypeDefinition,
|
||||||
)
|
)
|
||||||
|
|
||||||
from nwb_linkml.maps import flat_to_linkml, flat_to_np
|
from nwb_linkml.maps import flat_to_linkml, flat_to_np
|
||||||
from nwb_schema_language.datamodel.nwb_schema_pydantic import FlatDtype as FlatDtype_source
|
|
||||||
|
|
||||||
FlatDType = EnumDefinition(
|
|
||||||
name="FlatDType",
|
|
||||||
permissible_values=[PermissibleValue(p) for p in FlatDtype_source.__members__],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _make_dtypes() -> List[TypeDefinition]:
|
def _make_dtypes() -> List[TypeDefinition]:
|
||||||
|
@ -59,7 +51,6 @@ NwbLangSchema = SchemaDefinition(
|
||||||
name="nwb.language",
|
name="nwb.language",
|
||||||
id="nwb.language",
|
id="nwb.language",
|
||||||
description="Adapter objects to mimic the behavior of elements in the nwb-schema-language",
|
description="Adapter objects to mimic the behavior of elements in the nwb-schema-language",
|
||||||
enums=[FlatDType],
|
|
||||||
classes=[AnyType],
|
classes=[AnyType],
|
||||||
types=DTypeTypes,
|
types=DTypeTypes,
|
||||||
imports=["linkml:types"],
|
imports=["linkml:types"],
|
||||||
|
|
Loading…
Reference in a new issue