instancelib.instances.combination module

class instancelib.instances.combination.CombinationProvider(read_only, writeable, new_data, index_map)[source]

Bases: InstanceProvider[IT, KT, DT, VT, RT], Generic[IT, KT, DT, VT, RT]

Parameters:
combined: Mapping[UUID, ROInstanceProvider[TypeVar(IT, bound= UpdateHookInstance[Any, Any, Any, Any]), TypeVar(KT), TypeVar(DT), TypeVar(VT), TypeVar(RT)]]
create(*args, **kwargs)[source]

Create a new instance of type InstanceType. The created instance is subsequently added to the provider.

Note: The number of arguments and keyword arguments may differ in actual implementation, so there are no standard arguments.

Returns:

The new instance Type

Return type:

InstanceType

Parameters:
  • args (Any) –

  • kwargs (Any) –

classmethod createprovider(read_only, writeable, new_data)[source]
Parameters:
Return type:

CombinationProvider[TypeVar(IT, bound= UpdateHookInstance[Any, Any, Any, Any]), TypeVar(KT), TypeVar(DT), TypeVar(VT), TypeVar(RT)]

data_chunker(batch_size=200)[source]

Iterate over all instances data parts in this provider

Parameters:

batch_size (int) – The batch size, the generator will return lists with size batch_size

Yields:

Sequence[Tuple[KT,DT]] – A sequence of instances with length batch_size. The last list may have a shorter length.

Return type:

Iterator[Sequence[Tuple[TypeVar(KT), TypeVar(DT)]]]

data_chunker_selector(keys, batch_size=200)[source]
Parameters:
Return type:

Iterator[Sequence[Tuple[TypeVar(KT), TypeVar(DT)]]]

index_map: MutableMapping[TypeVar(KT), UUID]
property key_list: Sequence[KT]

Return a list of all instance keys in this provider

Returns:

A list of instance keys

Return type:

List[KT]

new_data: Mapping[UUID, InstanceProvider[TypeVar(IT, bound= UpdateHookInstance[Any, Any, Any, Any]), TypeVar(KT), TypeVar(DT), TypeVar(VT), TypeVar(RT)]]
read_only: Mapping[UUID, ROInstanceProvider[TypeVar(IT, bound= UpdateHookInstance[Any, Any, Any, Any]), TypeVar(KT), TypeVar(DT), TypeVar(VT), TypeVar(RT)]]
vector_chunker(batch_size=200)[source]

Iterate over all pairs of keys and vectors in this provider

Parameters:

batch_size (int) – The batch size, the generator will return lists with size batch_size

Returns:

An iterator over sequences of key vector tuples

Return type:

Iterator[Sequence[Tuple[KT, VT]]]

Yields:

Sequence[Tuple[KT, VT]] – Sequences of key vector tuples

vector_chunker_selector(keys, batch_size=200)[source]

Iterate over all instances (with or without vectors) in belonging the identifier Iterable in the keys parameter.

Parameters:
  • keys (Iterable[KT]) – The keys that should should be chunked

  • batch_size (int) – The batch size, the generator will return lists with size batch_size

Yields:

Sequence[Instance[KT, DT, VT, RT]]] – A sequence of instances with length batch_size. The last list may have a shorter length.

Returns:

An iterator over sequences of key vector tuples

Return type:

Iterator[Sequence[Tuple[KT, VT]]]

writeable: Mapping[UUID, InstanceProvider[TypeVar(IT, bound= UpdateHookInstance[Any, Any, Any, Any]), TypeVar(KT), TypeVar(DT), TypeVar(VT), TypeVar(RT)]]
class instancelib.instances.combination.UpdateHookInstance(*args, **kwds)[source]

Bases: Instance[KT, DT, VT, RT], ABC, Generic[KT, DT, VT, RT]

register_hook(update_hook)[source]
Parameters:

update_hook (Callable[[UpdateHookInstance[KT, DT, VT, RT]], Any]) –

Return type:

None

update_hook()[source]
Return type:

None