monkey_wrench.query._base module
- class monkey_wrench.query._base.LogMixin(log_context: str = '')[source]
Bases:
object- __init__(log_context: str = '') None[source]
Make an instance of the class.
- Parameters:
log_context – A string that will be used in log messages to determine the context. Defaults to an empty string.
- property log_context: str
Get the log context as a string.
- class monkey_wrench.query._base.Query(*args, **kwargs)[source]
Bases:
ABC,LogMixinAbstract base class for queries.
- abstractmethod static len(items: Any) Annotated[int, Ge(ge=0)][source]
Get the size (number) of items, e.g. the Python built-in
len()function in case of a list.
- query_in_batches(datetime_range_in_batches: DateTimeRangeInBatches, expected_total_count: Annotated[int, Ge(ge=0)] | None = None) Generator[tuple[T, int], None, None][source]
Divide the specified time range into smaller intervals (batches) and perform queries on them.
The arguments are the same as
DatetimeRangeInBatches. Ifexpected_total_countis given, it will be compared withtotal_retrieved_countand if they are not equal, a warning will be logged. It defaults toNonewhich means no comparison is made.- Yields:
The result of queries, in the form of 2-tuples in which the first element is the retrieved items from the
query()function in each batch and the second element is the size of the items in the batch.