BansInPool

toloka.metrics.pool_metrics.BansInPool | Source code

BansInPool(
self,
pool_id: str,
count_name: Optional[str] = None,
filter_by_comment: Optional[Dict[str, str]] = None,
cursor_time_lag: timedelta = ...,
join_events: bool = False,
*,
toloka_client: Optional[TolokaClient] = None,
atoloka_client: Optional[AsyncTolokaClient] = None,
timeout: timedelta = ...
)

Tracking Toloker restrictions in a pool.

Be careful: if you set in quality controls to ban Tolokers 'on project', bans 'on pool' will never happen.

Parameters description

ParametersTypeDescription
pool_idstr

From which pool track metrics.

count_nameOptional[str]

Metric name for a count of bans.

filter_by_commentOptional[Dict[str, str]]

Allow to split Toloker restriction into several lines based on comment. Dictionary where, key - comment string, and value - name for line in which will be aggregated bans with this comments.

cursor_time_lagtimedelta

Time lag for cursor. This controls time lag between user restrictions being added and this metric being updated. See BaseCursor.time_lag for details and reasoning behind this.

join_eventsbool

Count all events in one point. Default False.

Examples:

How to collect this metrics:

def print_metric(metric_dict):
print(metric_dict)
collector = MetricCollector([BansInPool(pool_id, toloka_client=toloka_client)], print_metric)
asyncio.run(collector.run())
{
'bans_count': [(datetime.datetime(2021, 11, 18, 13, 30, 11, 522000), 1)],
}

How to split bans onto several metrics.

collector = MetricCollector(
[
BansInPool(
pool_id,
toloka_client=toloka_client,
filter_by_comment={'fast answers': 'fast', 'bad quality on honeypots': 'honeypots'}
),
],
print_metric
)
asyncio.run(collector.run())
{
'honeypots': [(datetime.datetime(2021, 11, 18, 13, 32, 52, 475000), 1)],
'fast': [(datetime.datetime(2021, 11, 18, 13, 32, 50, 453000), 1)],
}

Methods summary

MethodDescription
get_line_namesReturns a list of metric names that can be generated by this class instance.

Last updated: August 28, 2023

Toloka-Kit
OverviewGetting API keyQuick start
Recipes
Reference
toloka.client
toloka.async_client
toloka.autoquality [autoquality]
toloka.metrics
toloka.streaming