Adapter#

Base class for adapters

class BuildResult(schemas: List[linkml_runtime.linkml_model.meta.SchemaDefinition] = <factory>, classes: List[linkml_runtime.linkml_model.meta.ClassDefinition] = <factory>, slots: List[linkml_runtime.linkml_model.meta.SlotDefinition] = <factory>, types: List[linkml_runtime.linkml_model.meta.TypeDefinition] = <factory>, **_kwargs)#
schemas: List[SchemaDefinition]#
classes: List[ClassDefinition]#
slots: List[SlotDefinition]#
types: List[TypeDefinition]#
pydantic model Adapter#

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.

abstract build() BuildResult#

Generate the corresponding linkML element for this adapter

walk(input: BaseModel | list | dict) 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_field_values(input: BaseModel | list | dict, 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_fields(input: BaseModel | list | dict, field: str | Tuple[str, ...])#

Recursively walk input for fields that match field

Parameters:

Returns:

walk_types(input: BaseModel | list | dict, get_type: Type[T] | Tuple[Type[T], Type[Unpack[Ts]]]) Generator[T | Ts, None, None]#