getting started doing hdmf mixins but am tired

This commit is contained in:
sneakers-the-rat 2024-07-26 21:58:07 -07:00
parent c98f25f973
commit baa5471af7
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
5 changed files with 38 additions and 10 deletions

View file

@ -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\.]*)\]")

View 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

View file

@ -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"],