Classes¶
Adapters to linkML classes
- class ClassAdapter(*, TYPE: T, cls: TI, parent: ClassAdapter | None = None)¶
Abstract adapter to class-like things in linkml, holds methods common to both DatasetAdapter and GroupAdapter
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- TYPE: T¶
The type that this adapter class handles
- cls: TI¶
- parent: ClassAdapter | None¶
- abstract build() BuildResult¶
Make this abstract so it can’t be instantiated directly.
Subclasses call
build_base()to get the basics true of both groups and datasets
- build_base(extra_attrs: List[SlotDefinition] | None = None) BuildResult¶
Build the basic class and attributes before adding any specific modifications for groups or datasets.
The main distinction in behavior for this method is whether this class has a parent class - ie this is one of the anonymous nested child datasets or groups within another group.
If the class has no parent, then…
Its name is inferred from its neurodata_type_def, fixed name, or neurodata_type_inc in that order
It is just built as normal class!
It will be indicated as a
tree_root(which will primarily be used to invert the translation for write operations)
If the class has a parent, then…
If it has a neurodata_type_def or inc, that will be used as its name, otherwise concatenate parent__child, eg.
TimeSeries__TimeSeriesDataA slot will also be made and returned with the BuildResult, which the parent will then have as one of its attributes.
- build_attrs(cls: Dataset | Group) List[SlotDefinition]¶
Pack the class attributes into a list of SlotDefinitions
- classmethod handle_dtype(dtype: List[CompoundDtype] | FlatDtype | ReferenceDtype | None) str¶
Get the string form of a dtype
- Parameters:
dtype (
DTypeType) – Dtype to stringify- Returns:
str
- build_name_slot() SlotDefinition¶
If a class has a name, then that name should be a slot with a fixed value.
If a class does not have a name, then name should be a required attribute
References
https://github.com/NeurodataWithoutBorders/nwb-schema/issues/552#issuecomment-1700319001
Returns:
- build_self_slot() SlotDefinition¶
If we are a child class, we make a slot so our parent can refer to us
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'TYPE': FieldInfo(annotation=~T, required=True), 'cls': FieldInfo(annotation=~TI, required=True), 'parent': FieldInfo(annotation=Union[ClassAdapter, NoneType], required=False, default=None)}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.