get_analytics

toloka.client.TolokaClient.get_analytics | Source code

get_analytics(self, stats: List[AnalyticsRequest])

Sends analytics requests to Toloka.

You can request up to 10 metrics at a time.

The values of different analytical metrics are returned in the details field of the operation when it is completed.

Parameters description

ParametersTypeDescription
statsList[AnalyticsRequest]

A list of analytics requests.

  • Returns:

    An object to track the progress of the operation.

  • Return type:

    AnalyticsOperation

Examples:

The example shows how get the percentage of completed tasks in the pool.

from toloka.client.analytics_request import CompletionPercentagePoolAnalytics
operation = toloka_client.get_analytics([CompletionPercentagePoolAnalytics(subject_id='1080020')])
operation = toloka_client.wait_operation(operation)
print(operation.details['value'][0])
completed_task_percentage = operation.details['value'][0]['result']['value']

The example monitors the percentage of completed tasks in the pool every minute until the pool is closed.

from toloka.client.analytics_request import CompletionPercentagePoolAnalytics
pool = toloka_client.get_pool('1080020')
while not pool.is_closed():
op = toloka_client.get_analytics( [CompletionPercentagePoolAnalytics(subject_id=pool.id)] )
op = toloka_client.wait_operation(op)
percentage = op.details['value'][0]['result']['value']
print(f'{percentage}%')
time.sleep(60)
pool = toloka_client.get_pool(pool.id)
print('The pool is closed.')

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