Classes#

Adapters to linkML classes

pydantic model ClassAdapter#

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.

__init__ uses __pydantic_self__ instead of the more common self for the first arg to allow self as a field name.

Fields:
field cls: Dataset | Group [Required]#
field parent: ClassAdapter | None = 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_attrs(cls: Dataset | Group) List[SlotDefinition]#
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__TimeSeriesData

  • A slot will also be made and returned with the BuildResult, which the parent will then have as one of its attributes.

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

classmethod handle_dtype(dtype: List[CompoundDtype] | FlatDtype | ReferenceDtype | None) str#