create_tasks

toloka.client.TolokaClient.create_tasks | Source code

Creates several tasks in Toloka.

You can add together general and control tasks. Tasks can be added to different pools. Note that pools must be configured before accepting new tasks. For example, mixer configuration must be set.

You can send a maximum of 100,000 requests of this kind per minute and a maximum of 2,000,000 requests per day.

By default, create_tasks starts asynchronous operation internally and waits for the completion of it. Do not change async_mode to False, if you do not understand clearly why you need it.

Parameters Description

ParametersTypeDescription
tasksList[Task]

A list of tasks to be created.

allow_defaultsOptional[bool]

Active overlap setting:

  • True — Use the overlap that is set in the defaults.default_overlap_for_new_tasks pool parameter.
  • False — Use the overlap that is set in the overlap task parameter.

Default value: False.

open_poolOptional[bool]

Open the pool immediately after creating a task suite, if the pool is closed.

Default value: False.

operation_idOptional[UUID]

The ID of the operation conforming to the RFC4122 standard. Use it if the async_mode is set to True.

skip_invalid_itemsOptional[bool]

Task validation option:

  • True — All valid tasks are added. If a task does not pass validation, then it is not added to Toloka. All such tasks are listed in the response.
  • False — If any task does not pass validation, then the operation is cancelled and no tasks are added to Toloka.

Default value: False.

async_modeOptional[bool]

Request processing mode:

  • True — Asynchronous operation is started internally and create_tasks waits for the completion of it. It is recommended to create no more than 10,000 tasks per request in this mode.
  • False — The request is processed synchronously. A maximum of 5000 tasks can be added in a single request in this mode.

Default value: False.

Examples:

The first example shows how to create tasks using a TSV file.

dataset = pandas.read_csv('dataset.tsv', sep=';')
tasks = [
toloka.client.Task(input_values={'image': url}, pool_id=existing_pool_id)
for url in dataset['image'].values[:50]
]
result = toloka_client.create_tasks(tasks, allow_defaults=True)
print(len(result.items))

The second example shows how to add control tasks.

dataset = pandas.read_csv('labeled_dataset.tsv', sep=';')
golden_tasks = []
for _, row in dataset.iterrows():
golden_tasks.append(
toloka.client.Task(
input_values={'image': row['image']},
known_solutions = [toloka.client.BaseTask.KnownSolution(output_values={'animal': row['label']})],
pool_id = existing_pool_id,
)
)
result = toloka_client.create_tasks(golden_tasks, allow_defaults=True)
print(len(result.items))
Toloka-Kit
OverviewGetting OAuth tokenQuick start
Recipes
Reference
toloka.client
toloka.async_client
toloka.autoquality [autoquality]
toloka.metrics
toloka.streaming