ahvn.adapter.base module¶

ahvn.adapter.base.parse_ukf_include(include=None, exclude=None, virtual_fields=None)[source]¶

Parse include parameter for engine initialization.

Parameters:
  • include (Optional[List[str]]) – List of BaseUKF field names to include. If None, includes all fields.

  • exclude (Optional[List[str]]) – List of BaseUKF field names to exclude. If None, excludes no fields. Notice that exclude is applied after include, so if a field is in both include and exclude, it will be excluded. It is recommended to use only one of include or exclude.

  • virtual_fields (Optional[Iterable[str]]) – Additional virtual fields to include.

Returns:

  • List of field names to include.

  • Boolean indicating if the included fields are sufficient to reconstruct a full BaseUKF object.

Return type:

A tuple containing

class ahvn.adapter.base.BaseUKFAdapter(name, include=None, exclude=None)[source]¶

Bases: ABC

Base adapter class for converting between UKF objects and backend representations.

This class should be extended to implement specific adapters for different backends.

Parameters:
virtual_fields = None¶
__init__(name, include=None, exclude=None)[source]¶

Initialize the adapter with specified field inclusion.

Parameters:
  • name – Name of the adapter instance.

  • include (Optional[List[str]]) – List of BaseUKF field names to include. If None, includes all fields. Default is None.

  • exclude (Optional[List[str]]) – List of BaseUKF field names to exclude. If None, excludes no fields. Default is None. Notice that exclude is applied after include, so if a field is in both include and exclude, it will be excluded. It is recommended to use only one of include or exclude.

abstractmethod from_ukf(ukf)[source]¶

Convert a BaseUKF object to a dictionary representation entity for backend.

Parameters:

ukf (BaseUKF) – BaseUKF object to convert.

Return type:

Any

Returns:

The converted entity that can be stored in the backend.

abstractmethod to_ukf_data(entity)[source]¶

Convert a backend entity representation to a dictionary suitable for BaseUKF initialization.

Parameters:

entity (Any) – The backend entity to convert.

Return type:

Dict[str, Any]

Returns:

A dictionary of field names and values for BaseUKF initialization.

to_ukf(entity)[source]¶

Convert a backend entity representation to a BaseUKF object.

Parameters:

entity (Any) – The backend entity to convert.

Return type:

BaseUKF

Returns:

The converted BaseUKF object.

abstractmethod from_result(result)[source]¶

Convert a query result from the backend to the appropriate entity representation.

Parameters:

result (Any) – The raw result from a backend query.

Return type:

Any

Returns:

The converted entity representation.