Create tasks and group them into task suites.
Connect the Toloka-Kit library to your script.
import toloka.client as toloka
Replace the sample API key with your own one.
toloka_client = toloka.TolokaClient('PlaceYourRealApiKey_Here', 'PRODUCTION');
First, create one or several tasks. In this example, we create three simple tasks with the following settings:
input_values
as links to imagesYou 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'})]
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.
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)
This actually creates a task suite in Toloka.
new_task_suite = toloka_client.create_task_suite(new_task_suite)
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
import toloka.client as tolokafrom toloka.client.task import Taskfrom toloka.client.task_suite import TaskSuitetoloka_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)
Last updated: February 7, 2023