toloka.client.TolokaClient.create_tasks
| Source code
Creates several tasks in Toloka.
You can create general and control tasks together. Tasks can be added to different pools. Note that pools must be configured before accepting new tasks. For example, mixer configuration must be set.
If async_mode
is True
, create_tasks
starts asynchronous operation internally and waits for the completion of it.
It is recommended to create no more than 10,000 tasks per request in this mode.
If async_mode
is False
, no more than 5000 tasks can be created in a single request.
Do not change async_mode
to False
, if you don't understand clearly why you need it.
You can send no more than 100,000 requests per minute and no more than 2,000,000 requests per day.
Parameters | Type | Description |
---|---|---|
tasks | List[Task] | A list of tasks to be created. |
operation_id | Optional[UUID] | The UUID of the operation that conforms to the RFC4122 standard. The UUID is used if Specify UUID to avoid accidental errors like Toloka operation duplication caused by network problems. If you send several requests with the same |
async_mode | Optional[bool] | Request processing mode:
Default value: |
allow_defaults | Optional[bool] | Active overlap setting:
Default value: |
open_pool | Optional[bool] | Open the pool immediately after creating a task suite, if the pool is closed. Default value: |
skip_invalid_items | Optional[bool] | Task validation option:
Default value: |
Returns:
The result of the operation.
Return type:
Examples:
The first example shows how to create tasks using a TSV file.
import pandasdataset = pandas.read_csv('dataset.tsv', sep=';')tasks = [ toloka.client.Task(input_values={'image': url}, pool_id='1080020') 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.
import pandasdataset = 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='1080020', ) )result = toloka_client.create_tasks(golden_tasks, allow_defaults=True)print(len(result.items))
Last updated: August 28, 2023