Group tasks in task suites

Create tasks and group them into task suites.

Steps to follow

1. Import Toloka-Kit

Connect the Toloka-Kit library to your script.

import toloka.client as toloka

2. Instantiate TolokaClient

Replace the sample API key with your own one.

toloka_client = toloka.
TolokaClient
('PlaceYourRealApiKey_Here', 'PRODUCTION');

3. Create tasks

First, create one or several tasks. In this example, we create three simple tasks with the following settings:

  • specify input_values as links to images

You can choose your own values for tasks. Refer to the Task class page for more details.

tasks = [
toloka.task.
Task
(input_values={'image': 'https://example.com/image_1.png'}),
toloka.task.
Task
(input_values={'image': 'https://example.com/image_2.png'}),
toloka.task.
Task
(input_values={'image': 'https://example.com/image_3.png'})
]
Important

All the code manipulations at steps 3–4 occur in your device memory. The data will only be sent to the server after calling the create_task_suite() method at step 5.

4. Create task suite object

Specify the ID of the pool where the task suite will be created, tasks included into the task suite, and overlap.

new_task_suite = toloka.task_suite.
TaskSuite
(pool_id='1442472', tasks=tasks, overlap=3)

5. Create task suite on platform

This actually creates a task suite in Toloka.

new_task_suite = toloka_client.
create_task_suite
(new_task_suite)

6. Print created task suite ID

The create_task_suite() request will return the TaskSuite class object. You can use its attributes to print the information you need.

print(new_task_suite.id)

You should get an output with the created task suite ID which looks like this.

00001602a8--63c18a66ed43982367a7acc8

Complete code: Group tasks in task suites

import toloka.client as toloka
from toloka.client.task import Task
from toloka.client.task_suite import TaskSuite
toloka_client = toloka.TolokaClient('PlaceYourRealApiKey_Here', 'PRODUCTION')
tasks = [
toloka.task.Task(input_values={'image': 'https://example.com/image_1.png'}),
toloka.task.Task(input_values={'image': 'https://example.com/image_2.png'}),
toloka.task.Task(input_values={'image': 'https://example.com/image_3.png'})
]
new_task_suite = toloka.task_suite.TaskSuite(pool_id='1442472', tasks=tasks, overlap=3)
new_task_suite = toloka_client.create_task_suite(new_task_suite)
print(new_task_suite.id)
List of classes and methods used in this recipe

See also

Last updated: February 7, 2023

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