Adapter¶
Base class for adapters
- class BuildResult(schemas: ~typing.List[~linkml_runtime.linkml_model.meta.SchemaDefinition] = <factory>, classes: ~typing.List[~linkml_runtime.linkml_model.meta.ClassDefinition] = <factory>, slots: ~typing.List[~linkml_runtime.linkml_model.meta.SlotDefinition] = <factory>, types: ~typing.List[~linkml_runtime.linkml_model.meta.TypeDefinition] = <factory>, **_kwargs)¶
Container class for propagating nested build results back up to caller
- schemas: List[SchemaDefinition]¶
- classes: List[ClassDefinition]¶
- slots: List[SlotDefinition]¶
- types: List[TypeDefinition]¶
- class Adapter¶
Abstract base class for adapters
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.
- property debug: bool¶
Whether we are in debug mode, which adds extra metadata in generated elements.
Set explicitly via
_debug, or else checks for the truthiness of the environment variableNWB_LINKML_DEBUG
- abstract build() BuildResult¶
Generate the corresponding linkML element for this adapter
- get(name: str) Group | Dataset¶
Get the first item whose
neurodata_type_defmatchesnameConvenience wrapper around
walk_field_values()
- get_model_with_field(field: str) Generator[Group | Dataset, None, None]¶
Yield models that have a non-None value in the given field.
Useful during development to find all the ways that a given field is used.
- Parameters:
field (str) – Field to search for
- walk(input: BaseModel | dict | list) Generator[BaseModel | Any | None, None, None]¶
Iterate through all items in the given model.
Could be a staticmethod or a function, but bound to adapters to make it available to them :)
- walk_fields(input: BaseModel | dict | list, field: str | Tuple[str, ...]) Generator[Any, None, None]¶
Recursively walk input for fields that match
field- Parameters:
input (
pydantic.BaseModel) – Model to walk (or a list or dictionary to walk too)
Returns:
- walk_field_values(input: BaseModel | dict | list, field: Literal['neurodata_type_def'], value: Any | None = None) Generator[Group | Dataset, None, None]¶
Recursively walk input for models that contain a
fieldas a direct child with a value matchingvalue- Parameters:
input (
pydantic.BaseModel) – Model to walkfield (str) – Name of field - unlike
walk_fields(), only one field can be givenvalue (Any) – Value to match for given field. If
None, return models that have the field
- Returns:
pydantic.BaseModelthe matching model
- walk_types(input: BaseModel | dict | list, get_type: Type[T] | Tuple[Type[T], Type[Unpack[Ts]]]) Generator[T | Ts, None, None]¶
Walk a model, yielding items that are the same type as the given type
- Parameters:
input (
pydantic.BaseModel, list, dict) – Object to yield from
- 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].
- class Map¶
The generic top-level mapping class is just a classmethod for checking if the map applies and a method for applying the check if it does
- is_1d(cls: Dataset | Attribute) bool¶
Check if the values of a dataset are 1-dimensional.
Specifically: * a single-layer dim/shape list of length 1, or * a nested dim/shape list where every nested spec is of length 1
- defaults(cls: Dataset | Attribute) dict¶
Handle default values -
If
valueis present, yield equals_string or equals_number depending on dtype as well as anifabsentvalue - we both constrain the possible values to 1 and also supply it as the defaultelse, if
default_valueis present, yield an appropriateifabsentvalueIf neither, yield an empty dict
Unlike nwb_schema_language, when
valueis set, we yield both aequals_*constraint and anifabsentconstraint, because anequals_*can be declared without a default in order to validate that a value is correctly set as the constrained value, and fail if a value isn’t provided.
- is_container(group: Group) bool¶
Check if a group is a container group.
i.e. a group that… * has no name * multivalued quantity * has a
neurodata_type_inc* has noneurodata_type_def* has no sub-groups * has no datasets * has no attributesExamples
- name: templates groups: - neurodata_type_inc: TimeSeries doc: TimeSeries objects containing template data of presented stimuli. quantity: '*' - neurodata_type_inc: Images doc: Images objects containing images of presented stimuli. quantity: '*'