Use pool filters to specify the Toloker groups you want to pick your tasks.
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, specify the parameters you want your pool to have. You can choose your own values or have your own set of the pool parameters. Refer to the Pool class page for more details.
new_pool = toloka.pool.Pool(
# The ID of the project in which the pool is created
project_id='133047',
# The pool name you will see in the list and use to distinguish the pool from other ones
private_name='Pool with filters',
# The date when the pool is going to expire and will be closed
will_expire=datetime(2030, 1, 1),
# The reward for the task suite specified in U.S. dollars
reward_per_assignment=0.05,
# The maximum duration of the task suite completion available to Tolokers
assignment_max_duration_seconds=60*5,
# The filters used to select Tolokers
filter=(
(toloka.filter.AdultAllowed==True) &
(toloka.filter.Citizenship=='US') &
(toloka.filter.ClientType=='TOLOKA_APP') &
(toloka.filter.DeviceCategory=='SMARTPHONE') &
(toloka.filter.Gender=='MALE') &
(toloka.filter.Languages.in_(['EN','DE','FR'])) &
(toloka.filter.OSFamily=='IOS') &
(toloka.filter.Skill('12648')>70)
)
)
This actually creates a pool in Toloka.
new_pool = toloka_client.create_pool(new_pool)
The create_pool()
request will return the Pool class object. You can use its attributes to print the information you need.
print(new_pool.id)
You should get an output with the created pool ID which looks like this.
1443815
import toloka.client as tolokatoloka_client = toloka.TolokaClient('PlaceYourRealApiKey_Here', 'PRODUCTION')new_pool = toloka.pool.Pool( project_id='133047', private_name='Pool with filters', will_expire=datetime(2030, 1, 1), reward_per_assignment=0.05, assignment_max_duration_seconds=60*5, filter=( (toloka.filter.AdultAllowed==True) & (toloka.filter.Citizenship=='US') & (toloka.filter.ClientType=='TOLOKA_APP') & (toloka.filter.DeviceCategory=='SMARTPHONE') & (toloka.filter.Gender=='MALE') & (toloka.filter.Languages.in_(['EN','DE','FR'])) & (toloka.filter.OSFamily=='IOS') & (toloka.filter.Skill('12648')>70) ))new_pool = toloka_client.create_pool(new_pool)print(new_pool.id)
Last updated: August 24, 2023