mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2025-01-09 21:54:27 +00:00
regenerate models
This commit is contained in:
parent
f9f1d49fca
commit
7a0da1528c
223 changed files with 5337 additions and 1113 deletions
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...hdmf_common.v1_1_0.hdmf_common_table import Container, Data, DynamicTable
|
from ...hdmf_common.v1_1_0.hdmf_common_table import Container, Data, DynamicTable
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_0.core_nwb_base import (
|
from ...core.v2_2_0.core_nwb_base import (
|
||||||
NWBDataInterface,
|
NWBDataInterface,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_0.core_nwb_base import NWBContainer
|
from ...core.v2_2_0.core_nwb_base import NWBContainer
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -86,6 +86,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_0.core_nwb_base import (
|
from ...core.v2_2_0.core_nwb_base import (
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_0.core_nwb_base import TimeSeries
|
from ...core.v2_2_0.core_nwb_base import TimeSeries
|
||||||
|
@ -46,7 +47,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -101,6 +102,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_0.core_nwb_base import (
|
from ...core.v2_2_0.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -50,7 +50,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -105,6 +105,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_0.core_nwb_base import (
|
from ...core.v2_2_0.core_nwb_base import (
|
||||||
|
@ -52,7 +53,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -107,6 +108,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_0.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_2_0.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_0.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_2_0.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_0.core_nwb_base import (
|
from ...core.v2_2_0.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_0.core_nwb_base import (
|
from ...core.v2_2_0.core_nwb_base import (
|
||||||
|
@ -49,7 +50,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -104,6 +105,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_0.core_nwb_base import NWBData, NWBDataInterface
|
from ...core.v2_2_0.core_nwb_base import NWBData, NWBDataInterface
|
||||||
|
@ -41,7 +42,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -96,6 +97,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_0.core_nwb_base import (
|
from ...core.v2_2_0.core_nwb_base import (
|
||||||
Image,
|
Image,
|
||||||
|
@ -159,7 +159,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -214,6 +214,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...hdmf_common.v1_1_2.hdmf_common_table import Container, Data, DynamicTable
|
from ...hdmf_common.v1_1_2.hdmf_common_table import Container, Data, DynamicTable
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_1.core_nwb_base import (
|
from ...core.v2_2_1.core_nwb_base import (
|
||||||
NWBDataInterface,
|
NWBDataInterface,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_1.core_nwb_base import NWBContainer
|
from ...core.v2_2_1.core_nwb_base import NWBContainer
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -86,6 +86,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_1.core_nwb_base import (
|
from ...core.v2_2_1.core_nwb_base import (
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_1.core_nwb_base import TimeSeries
|
from ...core.v2_2_1.core_nwb_base import TimeSeries
|
||||||
|
@ -46,7 +47,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -101,6 +102,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_1.core_nwb_base import (
|
from ...core.v2_2_1.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -50,7 +50,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -105,6 +105,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_1.core_nwb_base import (
|
from ...core.v2_2_1.core_nwb_base import (
|
||||||
|
@ -52,7 +53,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -107,6 +108,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_1.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_2_1.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_1.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_2_1.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_1.core_nwb_base import (
|
from ...core.v2_2_1.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_1.core_nwb_base import (
|
from ...core.v2_2_1.core_nwb_base import (
|
||||||
|
@ -49,7 +50,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -104,6 +105,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_1.core_nwb_base import NWBData, NWBDataInterface
|
from ...core.v2_2_1.core_nwb_base import NWBData, NWBDataInterface
|
||||||
|
@ -41,7 +42,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -96,6 +97,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_1.core_nwb_base import (
|
from ...core.v2_2_1.core_nwb_base import (
|
||||||
Image,
|
Image,
|
||||||
|
@ -159,7 +159,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -214,6 +214,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...hdmf_common.v1_1_3.hdmf_common_table import Container, Data, DynamicTable
|
from ...hdmf_common.v1_1_3.hdmf_common_table import Container, Data, DynamicTable
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_2.core_nwb_base import (
|
from ...core.v2_2_2.core_nwb_base import (
|
||||||
NWBDataInterface,
|
NWBDataInterface,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_2.core_nwb_base import NWBContainer
|
from ...core.v2_2_2.core_nwb_base import NWBContainer
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -86,6 +86,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_2.core_nwb_base import (
|
from ...core.v2_2_2.core_nwb_base import (
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_2.core_nwb_base import TimeSeries
|
from ...core.v2_2_2.core_nwb_base import TimeSeries
|
||||||
|
@ -46,7 +47,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -101,6 +102,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_2.core_nwb_base import (
|
from ...core.v2_2_2.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -50,7 +50,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -105,6 +105,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_2.core_nwb_base import (
|
from ...core.v2_2_2.core_nwb_base import (
|
||||||
|
@ -52,7 +53,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -107,6 +108,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_2.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_2_2.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_2.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_2_2.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_2.core_nwb_base import (
|
from ...core.v2_2_2.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_2.core_nwb_base import (
|
from ...core.v2_2_2.core_nwb_base import (
|
||||||
|
@ -49,7 +50,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -104,6 +105,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_2.core_nwb_base import NWBDataInterface
|
from ...core.v2_2_2.core_nwb_base import NWBDataInterface
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_2.core_nwb_base import (
|
from ...core.v2_2_2.core_nwb_base import (
|
||||||
Image,
|
Image,
|
||||||
|
@ -162,7 +162,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -217,6 +217,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...hdmf_common.v1_1_3.hdmf_common_table import Container, Data, DynamicTable
|
from ...hdmf_common.v1_1_3.hdmf_common_table import Container, Data, DynamicTable
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_4.core_nwb_base import (
|
from ...core.v2_2_4.core_nwb_base import (
|
||||||
NWBDataInterface,
|
NWBDataInterface,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_4.core_nwb_base import NWBContainer
|
from ...core.v2_2_4.core_nwb_base import NWBContainer
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -86,6 +86,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_4.core_nwb_base import (
|
from ...core.v2_2_4.core_nwb_base import (
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_4.core_nwb_base import TimeSeries
|
from ...core.v2_2_4.core_nwb_base import TimeSeries
|
||||||
|
@ -46,7 +47,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -101,6 +102,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_4.core_nwb_base import (
|
from ...core.v2_2_4.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -51,7 +51,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -106,6 +106,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_4.core_nwb_base import (
|
from ...core.v2_2_4.core_nwb_base import (
|
||||||
|
@ -52,7 +53,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -107,6 +108,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_4.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_2_4.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_4.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_2_4.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_4.core_nwb_base import (
|
from ...core.v2_2_4.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_4.core_nwb_base import (
|
from ...core.v2_2_4.core_nwb_base import (
|
||||||
|
@ -55,7 +56,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -110,6 +111,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_4.core_nwb_base import NWBDataInterface
|
from ...core.v2_2_4.core_nwb_base import NWBDataInterface
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_4.core_nwb_base import (
|
from ...core.v2_2_4.core_nwb_base import (
|
||||||
Image,
|
Image,
|
||||||
|
@ -169,7 +169,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -224,6 +224,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...hdmf_common.v1_1_3.hdmf_common_table import Container, Data, DynamicTable
|
from ...hdmf_common.v1_1_3.hdmf_common_table import Container, Data, DynamicTable
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_5.core_nwb_base import (
|
from ...core.v2_2_5.core_nwb_base import (
|
||||||
NWBDataInterface,
|
NWBDataInterface,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_5.core_nwb_base import NWBContainer
|
from ...core.v2_2_5.core_nwb_base import NWBContainer
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -86,6 +86,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_5.core_nwb_base import (
|
from ...core.v2_2_5.core_nwb_base import (
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_5.core_nwb_base import TimeSeries
|
from ...core.v2_2_5.core_nwb_base import TimeSeries
|
||||||
|
@ -46,7 +47,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -101,6 +102,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_5.core_nwb_base import (
|
from ...core.v2_2_5.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -51,7 +51,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -106,6 +106,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_5.core_nwb_base import (
|
from ...core.v2_2_5.core_nwb_base import (
|
||||||
|
@ -52,7 +53,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -107,6 +108,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_5.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_2_5.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_5.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_2_5.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_5.core_nwb_base import (
|
from ...core.v2_2_5.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_2_5.core_nwb_base import (
|
from ...core.v2_2_5.core_nwb_base import (
|
||||||
|
@ -55,7 +56,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -110,6 +111,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_5.core_nwb_base import NWBDataInterface
|
from ...core.v2_2_5.core_nwb_base import NWBDataInterface
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_2_5.core_nwb_base import (
|
from ...core.v2_2_5.core_nwb_base import (
|
||||||
Image,
|
Image,
|
||||||
|
@ -169,7 +169,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -224,6 +224,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...hdmf_common.v1_5_0.hdmf_common_base import Container, Data
|
from ...hdmf_common.v1_5_0.hdmf_common_base import Container, Data
|
||||||
from ...hdmf_common.v1_5_0.hdmf_common_table import DynamicTable
|
from ...hdmf_common.v1_5_0.hdmf_common_table import DynamicTable
|
||||||
|
@ -33,7 +33,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -88,6 +88,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_3_0.core_nwb_base import (
|
from ...core.v2_3_0.core_nwb_base import (
|
||||||
NWBDataInterface,
|
NWBDataInterface,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_3_0.core_nwb_base import NWBContainer
|
from ...core.v2_3_0.core_nwb_base import NWBContainer
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -86,6 +86,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_3_0.core_nwb_base import (
|
from ...core.v2_3_0.core_nwb_base import (
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_3_0.core_nwb_base import TimeSeries
|
from ...core.v2_3_0.core_nwb_base import TimeSeries
|
||||||
|
@ -46,7 +47,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -101,6 +102,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_3_0.core_nwb_base import (
|
from ...core.v2_3_0.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -51,7 +51,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -106,6 +106,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
@ -242,6 +264,9 @@ class NWBFile(NWBContainer):
|
||||||
description="""Experimental intervals, whether that be logically distinct sub-experiments having a particular scientific goal, trials (see trials subgroup) during an experiment, or epochs (see epochs subgroup) deriving from analysis of data.""",
|
description="""Experimental intervals, whether that be logically distinct sub-experiments having a particular scientific goal, trials (see trials subgroup) during an experiment, or epochs (see epochs subgroup) deriving from analysis of data.""",
|
||||||
)
|
)
|
||||||
units: Optional[Units] = Field(None, description="""Data about sorted spike units.""")
|
units: Optional[Units] = Field(None, description="""Data about sorted spike units.""")
|
||||||
|
specifications: Optional[dict] = Field(
|
||||||
|
None, description="""Nested dictionary of schema specifications"""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NWBFileStimulus(ConfiguredBaseModel):
|
class NWBFileStimulus(ConfiguredBaseModel):
|
||||||
|
@ -340,10 +365,6 @@ class NWBFileGeneral(ConfiguredBaseModel):
|
||||||
None,
|
None,
|
||||||
description="""Information about virus(es) used in experiments, including virus ID, source, date made, injection location, volume, etc.""",
|
description="""Information about virus(es) used in experiments, including virus ID, source, date made, injection location, volume, etc.""",
|
||||||
)
|
)
|
||||||
lab_meta_data: Optional[Dict[str, LabMetaData]] = Field(
|
|
||||||
None,
|
|
||||||
description="""Place-holder than can be extended so that lab-specific meta-data can be placed in /general.""",
|
|
||||||
)
|
|
||||||
devices: Optional[Dict[str, Device]] = Field(
|
devices: Optional[Dict[str, Device]] = Field(
|
||||||
None,
|
None,
|
||||||
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
|
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
|
||||||
|
@ -369,6 +390,10 @@ class NWBFileGeneral(ConfiguredBaseModel):
|
||||||
description="""Metadata related to optophysiology.""",
|
description="""Metadata related to optophysiology.""",
|
||||||
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImagingPlane"}]}},
|
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImagingPlane"}]}},
|
||||||
)
|
)
|
||||||
|
value: Optional[Dict[str, LabMetaData]] = Field(
|
||||||
|
None,
|
||||||
|
description="""Place-holder than can be extended so that lab-specific meta-data can be placed in /general.""",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class GeneralSourceScript(ConfiguredBaseModel):
|
class GeneralSourceScript(ConfiguredBaseModel):
|
||||||
|
@ -404,12 +429,12 @@ class GeneralExtracellularEphys(ConfiguredBaseModel):
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
electrode_group: Optional[Dict[str, ElectrodeGroup]] = Field(
|
|
||||||
None, description="""Physical group of electrodes."""
|
|
||||||
)
|
|
||||||
electrodes: Optional[ExtracellularEphysElectrodes] = Field(
|
electrodes: Optional[ExtracellularEphysElectrodes] = Field(
|
||||||
None, description="""A table of all electrodes (i.e. channels) used for recording."""
|
None, description="""A table of all electrodes (i.e. channels) used for recording."""
|
||||||
)
|
)
|
||||||
|
value: Optional[Dict[str, ElectrodeGroup]] = Field(
|
||||||
|
None, description="""Physical group of electrodes."""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ExtracellularEphysElectrodes(DynamicTable):
|
class ExtracellularEphysElectrodes(DynamicTable):
|
||||||
|
@ -565,12 +590,12 @@ class GeneralIntracellularEphys(ConfiguredBaseModel):
|
||||||
None,
|
None,
|
||||||
description="""Description of filtering used. Includes filtering type and parameters, frequency fall-off, etc. If this changes between TimeSeries, filter description should be stored as a text attribute for each TimeSeries.""",
|
description="""Description of filtering used. Includes filtering type and parameters, frequency fall-off, etc. If this changes between TimeSeries, filter description should be stored as a text attribute for each TimeSeries.""",
|
||||||
)
|
)
|
||||||
intracellular_electrode: Optional[Dict[str, IntracellularElectrode]] = Field(
|
|
||||||
None, description="""An intracellular electrode."""
|
|
||||||
)
|
|
||||||
sweep_table: Optional[SweepTable] = Field(
|
sweep_table: Optional[SweepTable] = Field(
|
||||||
None, description="""The table which groups different PatchClampSeries together."""
|
None, description="""The table which groups different PatchClampSeries together."""
|
||||||
)
|
)
|
||||||
|
value: Optional[Dict[str, IntracellularElectrode]] = Field(
|
||||||
|
None, description="""An intracellular electrode."""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NWBFileIntervals(ConfiguredBaseModel):
|
class NWBFileIntervals(ConfiguredBaseModel):
|
||||||
|
@ -596,7 +621,7 @@ class NWBFileIntervals(ConfiguredBaseModel):
|
||||||
invalid_times: Optional[TimeIntervals] = Field(
|
invalid_times: Optional[TimeIntervals] = Field(
|
||||||
None, description="""Time intervals that should be removed from analysis."""
|
None, description="""Time intervals that should be removed from analysis."""
|
||||||
)
|
)
|
||||||
time_intervals: Optional[Dict[str, TimeIntervals]] = Field(
|
value: Optional[Dict[str, TimeIntervals]] = Field(
|
||||||
None,
|
None,
|
||||||
description="""Optional additional table(s) for describing other experimental time intervals.""",
|
description="""Optional additional table(s) for describing other experimental time intervals.""",
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_3_0.core_nwb_base import (
|
from ...core.v2_3_0.core_nwb_base import (
|
||||||
|
@ -52,7 +53,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -107,6 +108,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_3_0.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_3_0.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
from ...core.v2_3_0.core_nwb_device import Device
|
from ...core.v2_3_0.core_nwb_device import Device
|
||||||
|
@ -33,7 +33,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -88,6 +88,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_3_0.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_3_0.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_3_0.core_nwb_base import (
|
from ...core.v2_3_0.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_3_0.core_nwb_base import (
|
from ...core.v2_3_0.core_nwb_base import (
|
||||||
|
@ -55,7 +56,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -110,6 +111,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_3_0.core_nwb_base import NWBDataInterface
|
from ...core.v2_3_0.core_nwb_base import NWBDataInterface
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_3_0.core_nwb_base import (
|
from ...core.v2_3_0.core_nwb_base import (
|
||||||
Image,
|
Image,
|
||||||
|
@ -186,7 +186,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -241,6 +241,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -46,7 +46,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -101,6 +101,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_4_0.core_nwb_base import (
|
from ...core.v2_4_0.core_nwb_base import (
|
||||||
NWBDataInterface,
|
NWBDataInterface,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_4_0.core_nwb_base import NWBContainer
|
from ...core.v2_4_0.core_nwb_base import NWBContainer
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -86,6 +86,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_4_0.core_nwb_base import (
|
from ...core.v2_4_0.core_nwb_base import (
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_4_0.core_nwb_base import TimeSeries
|
from ...core.v2_4_0.core_nwb_base import TimeSeries
|
||||||
|
@ -46,7 +47,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -101,6 +102,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_4_0.core_nwb_base import (
|
from ...core.v2_4_0.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -59,7 +59,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -114,6 +114,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
@ -250,6 +272,9 @@ class NWBFile(NWBContainer):
|
||||||
description="""Experimental intervals, whether that be logically distinct sub-experiments having a particular scientific goal, trials (see trials subgroup) during an experiment, or epochs (see epochs subgroup) deriving from analysis of data.""",
|
description="""Experimental intervals, whether that be logically distinct sub-experiments having a particular scientific goal, trials (see trials subgroup) during an experiment, or epochs (see epochs subgroup) deriving from analysis of data.""",
|
||||||
)
|
)
|
||||||
units: Optional[Units] = Field(None, description="""Data about sorted spike units.""")
|
units: Optional[Units] = Field(None, description="""Data about sorted spike units.""")
|
||||||
|
specifications: Optional[dict] = Field(
|
||||||
|
None, description="""Nested dictionary of schema specifications"""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NWBFileStimulus(ConfiguredBaseModel):
|
class NWBFileStimulus(ConfiguredBaseModel):
|
||||||
|
@ -348,10 +373,6 @@ class NWBFileGeneral(ConfiguredBaseModel):
|
||||||
None,
|
None,
|
||||||
description="""Information about virus(es) used in experiments, including virus ID, source, date made, injection location, volume, etc.""",
|
description="""Information about virus(es) used in experiments, including virus ID, source, date made, injection location, volume, etc.""",
|
||||||
)
|
)
|
||||||
lab_meta_data: Optional[Dict[str, LabMetaData]] = Field(
|
|
||||||
None,
|
|
||||||
description="""Place-holder than can be extended so that lab-specific meta-data can be placed in /general.""",
|
|
||||||
)
|
|
||||||
devices: Optional[Dict[str, Device]] = Field(
|
devices: Optional[Dict[str, Device]] = Field(
|
||||||
None,
|
None,
|
||||||
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
|
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
|
||||||
|
@ -377,6 +398,10 @@ class NWBFileGeneral(ConfiguredBaseModel):
|
||||||
description="""Metadata related to optophysiology.""",
|
description="""Metadata related to optophysiology.""",
|
||||||
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImagingPlane"}]}},
|
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImagingPlane"}]}},
|
||||||
)
|
)
|
||||||
|
value: Optional[Dict[str, LabMetaData]] = Field(
|
||||||
|
None,
|
||||||
|
description="""Place-holder than can be extended so that lab-specific meta-data can be placed in /general.""",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class GeneralSourceScript(ConfiguredBaseModel):
|
class GeneralSourceScript(ConfiguredBaseModel):
|
||||||
|
@ -412,12 +437,12 @@ class GeneralExtracellularEphys(ConfiguredBaseModel):
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
electrode_group: Optional[Dict[str, ElectrodeGroup]] = Field(
|
|
||||||
None, description="""Physical group of electrodes."""
|
|
||||||
)
|
|
||||||
electrodes: Optional[ExtracellularEphysElectrodes] = Field(
|
electrodes: Optional[ExtracellularEphysElectrodes] = Field(
|
||||||
None, description="""A table of all electrodes (i.e. channels) used for recording."""
|
None, description="""A table of all electrodes (i.e. channels) used for recording."""
|
||||||
)
|
)
|
||||||
|
value: Optional[Dict[str, ElectrodeGroup]] = Field(
|
||||||
|
None, description="""Physical group of electrodes."""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ExtracellularEphysElectrodes(DynamicTable):
|
class ExtracellularEphysElectrodes(DynamicTable):
|
||||||
|
@ -573,9 +598,6 @@ class GeneralIntracellularEphys(ConfiguredBaseModel):
|
||||||
None,
|
None,
|
||||||
description="""[DEPRECATED] Use IntracellularElectrode.filtering instead. Description of filtering used. Includes filtering type and parameters, frequency fall-off, etc. If this changes between TimeSeries, filter description should be stored as a text attribute for each TimeSeries.""",
|
description="""[DEPRECATED] Use IntracellularElectrode.filtering instead. Description of filtering used. Includes filtering type and parameters, frequency fall-off, etc. If this changes between TimeSeries, filter description should be stored as a text attribute for each TimeSeries.""",
|
||||||
)
|
)
|
||||||
intracellular_electrode: Optional[Dict[str, IntracellularElectrode]] = Field(
|
|
||||||
None, description="""An intracellular electrode."""
|
|
||||||
)
|
|
||||||
sweep_table: Optional[SweepTable] = Field(
|
sweep_table: Optional[SweepTable] = Field(
|
||||||
None,
|
None,
|
||||||
description="""[DEPRECATED] Table used to group different PatchClampSeries. SweepTable is being replaced by IntracellularRecordingsTable and SimultaneousRecordingsTable tabels. Additional SequentialRecordingsTable, RepetitionsTable and ExperimentalConditions tables provide enhanced support for experiment metadata.""",
|
description="""[DEPRECATED] Table used to group different PatchClampSeries. SweepTable is being replaced by IntracellularRecordingsTable and SimultaneousRecordingsTable tabels. Additional SequentialRecordingsTable, RepetitionsTable and ExperimentalConditions tables provide enhanced support for experiment metadata.""",
|
||||||
|
@ -600,6 +622,9 @@ class GeneralIntracellularEphys(ConfiguredBaseModel):
|
||||||
None,
|
None,
|
||||||
description="""A table for grouping different intracellular recording repetitions together that belong to the same experimental experimental_conditions.""",
|
description="""A table for grouping different intracellular recording repetitions together that belong to the same experimental experimental_conditions.""",
|
||||||
)
|
)
|
||||||
|
value: Optional[Dict[str, IntracellularElectrode]] = Field(
|
||||||
|
None, description="""An intracellular electrode."""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NWBFileIntervals(ConfiguredBaseModel):
|
class NWBFileIntervals(ConfiguredBaseModel):
|
||||||
|
@ -625,7 +650,7 @@ class NWBFileIntervals(ConfiguredBaseModel):
|
||||||
invalid_times: Optional[TimeIntervals] = Field(
|
invalid_times: Optional[TimeIntervals] = Field(
|
||||||
None, description="""Time intervals that should be removed from analysis."""
|
None, description="""Time intervals that should be removed from analysis."""
|
||||||
)
|
)
|
||||||
time_intervals: Optional[Dict[str, TimeIntervals]] = Field(
|
value: Optional[Dict[str, TimeIntervals]] = Field(
|
||||||
None,
|
None,
|
||||||
description="""Optional additional table(s) for describing other experimental time intervals.""",
|
description="""Optional additional table(s) for describing other experimental time intervals.""",
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_4_0.core_nwb_base import (
|
from ...core.v2_4_0.core_nwb_base import (
|
||||||
|
@ -55,7 +56,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -110,6 +111,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_4_0.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_4_0.core_nwb_base import Image, TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
from ...core.v2_4_0.core_nwb_device import Device
|
from ...core.v2_4_0.core_nwb_device import Device
|
||||||
|
@ -33,7 +33,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -88,6 +88,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_4_0.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_4_0.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_4_0.core_nwb_base import (
|
from ...core.v2_4_0.core_nwb_base import (
|
||||||
NWBContainer,
|
NWBContainer,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_4_0.core_nwb_base import (
|
from ...core.v2_4_0.core_nwb_base import (
|
||||||
|
@ -55,7 +56,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -110,6 +111,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_4_0.core_nwb_base import NWBDataInterface
|
from ...core.v2_4_0.core_nwb_base import NWBDataInterface
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -87,6 +87,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_4_0.core_nwb_base import (
|
from ...core.v2_4_0.core_nwb_base import (
|
||||||
Image,
|
Image,
|
||||||
|
@ -199,7 +199,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -254,6 +254,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -57,7 +57,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -112,6 +112,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_5_0.core_nwb_base import (
|
from ...core.v2_5_0.core_nwb_base import (
|
||||||
NWBDataInterface,
|
NWBDataInterface,
|
||||||
|
@ -38,7 +38,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -93,6 +93,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ from enum import Enum
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_5_0.core_nwb_base import NWBContainer
|
from ...core.v2_5_0.core_nwb_base import NWBContainer
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -86,6 +86,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_5_0.core_nwb_base import (
|
from ...core.v2_5_0.core_nwb_base import (
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_5_0.core_nwb_base import TimeSeriesReferenceVectorData
|
from ...core.v2_5_0.core_nwb_base import TimeSeriesReferenceVectorData
|
||||||
|
@ -46,7 +47,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -101,6 +102,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_5_0.core_nwb_base import (
|
from ...core.v2_5_0.core_nwb_base import (
|
||||||
Images,
|
Images,
|
||||||
|
@ -60,7 +60,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -115,6 +115,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
@ -251,6 +273,9 @@ class NWBFile(NWBContainer):
|
||||||
description="""Experimental intervals, whether that be logically distinct sub-experiments having a particular scientific goal, trials (see trials subgroup) during an experiment, or epochs (see epochs subgroup) deriving from analysis of data.""",
|
description="""Experimental intervals, whether that be logically distinct sub-experiments having a particular scientific goal, trials (see trials subgroup) during an experiment, or epochs (see epochs subgroup) deriving from analysis of data.""",
|
||||||
)
|
)
|
||||||
units: Optional[Units] = Field(None, description="""Data about sorted spike units.""")
|
units: Optional[Units] = Field(None, description="""Data about sorted spike units.""")
|
||||||
|
specifications: Optional[dict] = Field(
|
||||||
|
None, description="""Nested dictionary of schema specifications"""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NWBFileStimulus(ConfiguredBaseModel):
|
class NWBFileStimulus(ConfiguredBaseModel):
|
||||||
|
@ -351,10 +376,6 @@ class NWBFileGeneral(ConfiguredBaseModel):
|
||||||
None,
|
None,
|
||||||
description="""Information about virus(es) used in experiments, including virus ID, source, date made, injection location, volume, etc.""",
|
description="""Information about virus(es) used in experiments, including virus ID, source, date made, injection location, volume, etc.""",
|
||||||
)
|
)
|
||||||
lab_meta_data: Optional[Dict[str, LabMetaData]] = Field(
|
|
||||||
None,
|
|
||||||
description="""Place-holder than can be extended so that lab-specific meta-data can be placed in /general.""",
|
|
||||||
)
|
|
||||||
devices: Optional[Dict[str, Device]] = Field(
|
devices: Optional[Dict[str, Device]] = Field(
|
||||||
None,
|
None,
|
||||||
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
|
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
|
||||||
|
@ -380,6 +401,10 @@ class NWBFileGeneral(ConfiguredBaseModel):
|
||||||
description="""Metadata related to optophysiology.""",
|
description="""Metadata related to optophysiology.""",
|
||||||
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImagingPlane"}]}},
|
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImagingPlane"}]}},
|
||||||
)
|
)
|
||||||
|
value: Optional[Dict[str, LabMetaData]] = Field(
|
||||||
|
None,
|
||||||
|
description="""Place-holder than can be extended so that lab-specific meta-data can be placed in /general.""",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class GeneralSourceScript(ConfiguredBaseModel):
|
class GeneralSourceScript(ConfiguredBaseModel):
|
||||||
|
@ -415,12 +440,12 @@ class GeneralExtracellularEphys(ConfiguredBaseModel):
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
electrode_group: Optional[Dict[str, ElectrodeGroup]] = Field(
|
|
||||||
None, description="""Physical group of electrodes."""
|
|
||||||
)
|
|
||||||
electrodes: Optional[ExtracellularEphysElectrodes] = Field(
|
electrodes: Optional[ExtracellularEphysElectrodes] = Field(
|
||||||
None, description="""A table of all electrodes (i.e. channels) used for recording."""
|
None, description="""A table of all electrodes (i.e. channels) used for recording."""
|
||||||
)
|
)
|
||||||
|
value: Optional[Dict[str, ElectrodeGroup]] = Field(
|
||||||
|
None, description="""Physical group of electrodes."""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ExtracellularEphysElectrodes(DynamicTable):
|
class ExtracellularEphysElectrodes(DynamicTable):
|
||||||
|
@ -576,9 +601,6 @@ class GeneralIntracellularEphys(ConfiguredBaseModel):
|
||||||
None,
|
None,
|
||||||
description="""[DEPRECATED] Use IntracellularElectrode.filtering instead. Description of filtering used. Includes filtering type and parameters, frequency fall-off, etc. If this changes between TimeSeries, filter description should be stored as a text attribute for each TimeSeries.""",
|
description="""[DEPRECATED] Use IntracellularElectrode.filtering instead. Description of filtering used. Includes filtering type and parameters, frequency fall-off, etc. If this changes between TimeSeries, filter description should be stored as a text attribute for each TimeSeries.""",
|
||||||
)
|
)
|
||||||
intracellular_electrode: Optional[Dict[str, IntracellularElectrode]] = Field(
|
|
||||||
None, description="""An intracellular electrode."""
|
|
||||||
)
|
|
||||||
sweep_table: Optional[SweepTable] = Field(
|
sweep_table: Optional[SweepTable] = Field(
|
||||||
None,
|
None,
|
||||||
description="""[DEPRECATED] Table used to group different PatchClampSeries. SweepTable is being replaced by IntracellularRecordingsTable and SimultaneousRecordingsTable tabels. Additional SequentialRecordingsTable, RepetitionsTable and ExperimentalConditions tables provide enhanced support for experiment metadata.""",
|
description="""[DEPRECATED] Table used to group different PatchClampSeries. SweepTable is being replaced by IntracellularRecordingsTable and SimultaneousRecordingsTable tabels. Additional SequentialRecordingsTable, RepetitionsTable and ExperimentalConditions tables provide enhanced support for experiment metadata.""",
|
||||||
|
@ -603,6 +625,9 @@ class GeneralIntracellularEphys(ConfiguredBaseModel):
|
||||||
None,
|
None,
|
||||||
description="""A table for grouping different intracellular recording repetitions together that belong to the same experimental experimental_conditions.""",
|
description="""A table for grouping different intracellular recording repetitions together that belong to the same experimental experimental_conditions.""",
|
||||||
)
|
)
|
||||||
|
value: Optional[Dict[str, IntracellularElectrode]] = Field(
|
||||||
|
None, description="""An intracellular electrode."""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NWBFileIntervals(ConfiguredBaseModel):
|
class NWBFileIntervals(ConfiguredBaseModel):
|
||||||
|
@ -628,7 +653,7 @@ class NWBFileIntervals(ConfiguredBaseModel):
|
||||||
invalid_times: Optional[TimeIntervals] = Field(
|
invalid_times: Optional[TimeIntervals] = Field(
|
||||||
None, description="""Time intervals that should be removed from analysis."""
|
None, description="""Time intervals that should be removed from analysis."""
|
||||||
)
|
)
|
||||||
time_intervals: Optional[Dict[str, TimeIntervals]] = Field(
|
value: Optional[Dict[str, TimeIntervals]] = Field(
|
||||||
None,
|
None,
|
||||||
description="""Optional additional table(s) for describing other experimental time intervals.""",
|
description="""Optional additional table(s) for describing other experimental time intervals.""",
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_5_0.core_nwb_base import (
|
from ...core.v2_5_0.core_nwb_base import (
|
||||||
|
@ -55,7 +56,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -110,6 +111,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -9,7 +9,7 @@ from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpydantic import NDArray, Shape
|
from numpydantic import NDArray, Shape
|
||||||
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
|
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, model_validator
|
||||||
|
|
||||||
from ...core.v2_5_0.core_nwb_base import (
|
from ...core.v2_5_0.core_nwb_base import (
|
||||||
Image,
|
Image,
|
||||||
|
@ -39,7 +39,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -94,6 +94,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
|
@ -17,6 +17,7 @@ from pydantic import (
|
||||||
RootModel,
|
RootModel,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
|
model_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ...core.v2_5_0.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
from ...core.v2_5_0.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
|
||||||
|
@ -48,7 +49,7 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
)
|
)
|
||||||
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
|
||||||
|
|
||||||
def __getitem__(self, val: Union[int, slice]) -> Any:
|
def __getitem__(self, val: Union[int, slice, str]) -> Any:
|
||||||
"""Try and get a value from value or "data" if we have it"""
|
"""Try and get a value from value or "data" if we have it"""
|
||||||
if hasattr(self, "value") and self.value is not None:
|
if hasattr(self, "value") and self.value is not None:
|
||||||
return self.value[val]
|
return self.value[val]
|
||||||
|
@ -103,6 +104,28 @@ class ConfiguredBaseModel(BaseModel):
|
||||||
pass
|
pass
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def gather_extra_to_value(cls, v: Any, handler) -> Any:
|
||||||
|
"""
|
||||||
|
For classes that don't allow extra fields and have a value slot,
|
||||||
|
pack those extra kwargs into ``value``
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
cls.model_config["extra"] == "forbid"
|
||||||
|
and "value" in cls.model_fields
|
||||||
|
and isinstance(v, dict)
|
||||||
|
):
|
||||||
|
extras = {key: val for key, val in v.items() if key not in cls.model_fields}
|
||||||
|
if extras:
|
||||||
|
for k in extras:
|
||||||
|
del v[k]
|
||||||
|
if "value" in v:
|
||||||
|
v["value"].update(extras)
|
||||||
|
else:
|
||||||
|
v["value"] = extras
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LinkMLMeta(RootModel):
|
class LinkMLMeta(RootModel):
|
||||||
root: Dict[str, Any] = {}
|
root: Dict[str, Any] = {}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue