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]
as_linkml() str

Print build results as linkml-style YAML.

Note that only non-schema results will be included, as a schema usually contains all the other types.

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.

abstract build() BuildResult

Generate the corresponding linkML element for this adapter

get(name: str) Group | Dataset

Get the first item whose neurodata_type_def matches name

Convenience 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:

Returns:

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]] = {}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

walk_field_values(input: BaseModel | dict | list, field: str, value: Any | None = None) Generator[BaseModel, None, None]

Recursively walk input for models that contain a field as a direct child with a value matching value

Parameters:
  • input (pydantic.BaseModel) – Model to walk

  • field (str) – Name of field - unlike walk_fields(), only one field can be given

  • value (Any) – Value to match for given field. If None , return models that have the field

Returns:

pydantic.BaseModel the 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: