Skip to content

Commit

Permalink
Merge pull request #145 from Toloka/stubs
Browse files Browse the repository at this point in the history
Autogenerated stubs
  • Loading branch information
DrhF authored Jan 20, 2023
2 parents 7b2291d + ef84325 commit 14ae1fc
Show file tree
Hide file tree
Showing 21 changed files with 1,015 additions and 698 deletions.
591 changes: 370 additions & 221 deletions src/async_client/client.pyi

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/autoquality/optimizer.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ __all__ = [
'AutoQuality',
'DEFAULT_DISTRIBUTIONS',
]
import attr._make
import pandas
import toloka.autoquality.scoring
import toloka.client
Expand Down Expand Up @@ -85,7 +86,7 @@ class AutoQuality:
exam_skill_id: typing.Optional[str] = None,
label_field: str = 'label',
n_iter: int = 10,
parameter_distributions: typing.Dict = ...,
parameter_distributions: typing.Dict = attr._make._Nothing.NOTHING,
score_func: typing.Callable = toloka.autoquality.scoring.default_calc_scores,
ranking_func: typing.Callable = toloka.autoquality.scoring.default_calc_ranks,
create_autoquality_pool_func: typing.Callable = _create_autoquality_pool_default
Expand Down
587 changes: 366 additions & 221 deletions src/client/__init__.pyi

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/client/assignment.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ __all__ = [
'AssignmentPatch',
'GetAssignmentsTsvParameters',
]
import attr._make
import datetime
import decimal
import toloka.client.owner
Expand Down Expand Up @@ -200,11 +201,11 @@ class GetAssignmentsTsvParameters(toloka.client.primitives.parameter.Parameters)
def __init__(
self,
*,
status: typing.Optional[typing.List[Status]] = ...,
status: typing.Optional[typing.List[Status]] = attr._make._Nothing.NOTHING,
start_time_from: typing.Optional[datetime.datetime] = None,
start_time_to: typing.Optional[datetime.datetime] = None,
exclude_banned: typing.Optional[bool] = None,
field: typing.Optional[typing.List[Field]] = ...
field: typing.Optional[typing.List[Field]] = attr._make._Nothing.NOTHING
) -> None:
"""Method generated by attrs for class GetAssignmentsTsvParameters.
"""
Expand Down
7 changes: 6 additions & 1 deletion src/client/collectors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import typing
import uuid


def _captcha_deprecation_warning(*args, **kwargs): ...


class CollectorConfig(toloka.client.primitives.base.BaseParameters):
"""Base class for all collectors.
Expand Down Expand Up @@ -325,7 +328,7 @@ class AssignmentSubmitTime(CollectorConfig):


class Captcha(CollectorConfig):
"""Collects captcha statistics for every Toloker.
"""Deprecated. Collects captcha statistics for every Toloker.
Captcha provides an advanced protection against robots. It is used with conditions:
* [StoredResultsCount](toloka.client.conditions.StoredResultsCount.md) — How many times the Toloker entered a captcha.
Expand Down Expand Up @@ -377,6 +380,8 @@ class Captcha(CollectorConfig):
_unexpected: typing.Optional[typing.Dict[str, typing.Any]]
history_size: typing.Optional[int]

def __attrs_post_init__(*args, **kwargs): ...

@typing.overload
def __init__(
self,
Expand Down
6 changes: 3 additions & 3 deletions src/client/conditions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class CorrectAnswersRate(ComparableRuleCondition):


class FailRate(ComparableRuleCondition):
"""The percentage of unsolved captchas.
"""Deprecated. The percentage of unsolved captchas.
`FailRate` is used with collectors:
- [Captcha](toloka.client.collectors.Captcha.md)
Expand Down Expand Up @@ -558,7 +558,7 @@ class SkippedInRowCount(ComparableRuleCondition):


class StoredResultsCount(ComparableRuleCondition):
"""The number of times a Toloker entered captcha.
"""Deprecated. The number of times a Toloker entered captcha.
`StoredResultsCount` is used with collectors:
- [Captcha](toloka.client.collectors.Captcha.md)
Expand Down Expand Up @@ -594,7 +594,7 @@ class SubmittedAssignmentsCount(ComparableRuleCondition):


class SuccessRate(ComparableRuleCondition):
"""A percentage of solved captchas out of all entered captchas.
"""Deprecated. A percentage of solved captchas out of all entered captchas.
`SuccessRate` is used with collectors:
- [Captcha](toloka.client.collectors.Captcha.md)
Expand Down
190 changes: 89 additions & 101 deletions src/client/pool/__init__.pyi

Large diffs are not rendered by default.

44 changes: 23 additions & 21 deletions src/client/pool/dynamic_overlap_config.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,44 @@ import typing


class DynamicOverlapConfig(toloka.client.primitives.base.BaseTolokaObject):
"""Dynamic overlap setting.
"""Dynamic overlap settings.
Toloka can automatically increase an overlap of tasks if the confidence level of aggregated responses is not high enough.
Dynamic overlap uses the `BASIC` algorithm.
Each response is assigned a weight depending on the Toloker's skill value.
The aggregated response confidence is calculated based on the probability algorithm.
The task overlap increases until it reaches `max_overlap` or until the confidence of the aggregated response exceeds `min_confidence`.
Note, that if you use dynamic overlap, then set the `auto_close_after_complete_delay_seconds` pool parameter to a non zero value.
Learn more about the [Dynamic overlap](https://toloka.ai/en/docs/guide/concepts/dynamic-overlap) in the guide.
Allows you to change the overlap depending on how well Tolokers handle the task.
Set the closing interval (auto_close_after_complete_delay_seconds). It should be enough to complete tasks
with an overlap higher than the minimum.
When all pool tasks are completed, aggregate the responses.
Attributes:
type: The algorithm for dynamic overlap.
max_overlap: Maximum overlap. Must be higher than the values in defaults. Minimum — 1. Maximum — 30000.
min_confidence: Minimum confidence of the aggregated response. Values from 0 to 1.
answer_weight_skill_id: A skill that determines the weight of the Toloker's response. For best results, use
a skill calculated as percentage of correct responses in control tasks.
fields: Output data fields to use for aggregating responses.
type: The dynamic overlap algorithm.
max_overlap: Maximum overlap. The value must be higher than the default overlap value. Allowed range: from 1 to 30,000.
min_confidence: Minimum required confidence of the aggregated response. Allowed range: from 0 to 1.
answer_weight_skill_id: A skill that determines the weight of the Toloker's responses.
For the best results, use a skill calculated as a percentage of correct responses in control tasks.
fields: A list of output data fields used for aggregating responses.
For the best results, each field must have a limited number of response options.
Don't specify fields in the list together if they depend on each other.
"""

class Type(toloka.util._extendable_enum.ExtendableStrEnum):
"""The algorithm for dynamic overlap.
Attributes:
BASIC: Each response is assigned a weight depending on the Toloker's skill value.
The aggregated response confidence is calculated based on the probability algorithm. The task overlap
increases until it reaches max_overlap or until the confidence of the aggregated response
exceeds min_confidence.
You have to specify max_overlap, min_confidence, answer_weight_skill_id and fields.
BASIC: The algorithm based on a Toloker's skill value.
"""

BASIC = 'BASIC'

class Field(toloka.client.primitives.base.BaseTolokaObject):
"""Output data fields to use for aggregating responses.
"""An output data field used for aggregating responses.
For best results, each of these fields must
have a limited number of response options.
Don't specify several fields if their values depend on each other.
Attributes:
name: The output data field name.
name: The name of the output field.
"""

def __init__(self, name: typing.Optional[str] = None) -> None:
Expand Down
24 changes: 14 additions & 10 deletions src/client/pool/dynamic_pricing_config.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,31 @@ import typing
class DynamicPricingConfig(toloka.client.primitives.base.BaseTolokaObject):
"""The dynamic pricing settings.
A price per task suite can be variable depending on a Toloker's skill.
If a Toloker is not covered by dynamic pricing settings then the default price is used. It is set in the `reward_per_assignment` pool parameter.
Attributes:
type: Parameter type for calculating dynamic pricing. The SKILL value.
skill_id: ID of the skill that the task price is based on
intervals: Skill level intervals. Must not overlap.
A Toloker with a skill level that is not included in any interval will receive the basic
price for a task suite.
type: The dynamic pricing type. Only `SKILL` type is supported now.
skill_id: The ID of the skill that dynamic pricing is based on.
intervals: A list of skill intervals and prices.
The intervals must not overlap.
"""

class Type(toloka.util._extendable_enum.ExtendableStrEnum):
"""Dynamic pricing type
"""Dynamic pricing type.
"""

SKILL = 'SKILL'

class Interval(toloka.client.primitives.base.BaseTolokaObject):
"""Skill level interval
"""Skill level interval with the associated price per task suite.
The lower and upper skill bounds are included in the interval.
Attributes:
from_: Lower bound of the interval.
to: dynamic_pricing_config.intervals.to
reward_per_assignment: The price per task page for a Toloker with the specified skill level.
from_: The lower bound of the interval.
to: The upper bound of the interval.
reward_per_assignment: The price per task suite for a Toloker with the specified skill level.
"""

def __init__(
Expand Down
75 changes: 37 additions & 38 deletions src/client/pool/mixer_config.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,46 @@ import typing


class MixerConfig(toloka.client.primitives.base.BaseTolokaObject):
"""Parameters for automatically creating a task suite ("smart mixing").
"""Settings for automatically grouping tasks into suites (smart mixing).
For more information about creating task see Toloka Requester's guide.
You can set the number of general, training and control tasks in a task suite. Also, you control task shuffling and other settings.
Attributes:
real_tasks_count: The number of main tasks to put in a task suite.
The maximum number of tasks in a task suite if training_task_distribution_function or
golden_task_distribution_function are used.
golden_tasks_count: The number of control ("golden set") tasks to put in a task suite.
training_tasks_count: The number of training tasks to put in a task suite.
min_real_tasks_count: Minimum number of main tasks in a task suite (if the number of assignments left is less
than the one specified in real_tasks_count). Minimum — 0. By default, the value is the same as in
real_tasks_count.
min_golden_tasks_count: Minimum number of control tasks in a task suite (if the number of assignments left is
less than the one specified in golden_tasks_count). Minimum — 0. By default, the value is the same as
in golden_tasks_count.
min_training_tasks_count: Minimum number of training tasks in a task suite (if the number of assignments left is
less than the one specified in golden_tasks_count). Minimum — 0. By default, the value is the same
as in training_tasks_count.
force_last_assignment: Setup for the last set of tasks in the pool, if less than the minimum remaining number of
tasks are not completed (mixer_config.min_real_tasks_count). Values:
* true - issue an incomplete task set.
* false - don't issue tasks. This option can be used if you are adding tasks after the pool is started.
This parameter only applies to main tasks. The number of control and training tasks in the last set must be
complete (golden_tasks_count, training_tasks_count).
force_last_assignment_delay_seconds: Waiting time (in seconds) since the addition of the task, or increase in
the overlap, prior to the issuance of the last set of tasks in the pool. The minimum is 0, the maximum is
86,400 seconds (one day).
This parameter can be used if the pool has force_last_assignment: True.
mix_tasks_in_creation_order: The order for including tasks in suites:
* True — Add tasks to suites in the order in which they were uploaded. For example, in a pool with an
overlap of 5, the first uploaded task will be included in the first 5 task suites. They will be
assigned to 5 Tolokers.
* False — Add tasks to suites in random order.
shuffle_tasks_in_task_suite: The order of tasks within a suite:
* True — Random.
* False — The order in which tasks were uploaded.
golden_task_distribution_function: Issue of control tasks with uneven frequency. The option allows you to change
the frequency of checking as the Toloker completes more tasks.
training_task_distribution_function: Issue of training tasks with uneven frequency. The option allows you to
change the frequency of training tasks as the Toloker completes more tasks.
real_tasks_count: The number of general tasks in a task suite.
If `training_task_distribution_function` or `golden_task_distribution_function` are used then `real_tasks_count` denotes the maximum number of tasks in a task suite.
golden_tasks_count: The number of control tasks in a task suite.
training_tasks_count: The number of training tasks in a task suite.
min_real_tasks_count: The minimum number of general tasks in a task suite if there are not enough tasks left to create a full task suite.
Allowed range: from 0 to `real_tasks_count`.
By default, the `min_real_tasks_count` value equals to the `real_tasks_count` value.
min_golden_tasks_count: The minimum number of control tasks in a task suite if there are not enough control tasks left to create a full task suite.
Allowed range: from 0 to `golden_tasks_count`.
By default, the `min_golden_tasks_count` value equals to the `golden_tasks_count` value.
min_training_tasks_count: The minimum number of training tasks in a task suite if there are not enough training tasks left to create a full task suite.
Allowed range: from 0 to `training_tasks_count`.
By default, the `min_training_tasks_count` value equals to the `training_tasks_count` value.
force_last_assignment: A setting used when the number of remaining general tasks in the pool is less than the `min_real_tasks_count` value.
Note, that there must be enough control and training tasks to create a task suite.
* True — An incomplete task suite is assigned.
* False — An incomplete task suite is not assigned. It is useful if you add tasks to an open pool.
Default: `True`.
force_last_assignment_delay_seconds: Time in seconds before assigning the last task suite. This parameter is used if `force_last_assignment` is set to `True`.
Allowed range: from 0 to 86,400 seconds (one day).
mix_tasks_in_creation_order:
* True — Tasks are grouped in task suites in the order they were created.
* False — Tasks are chosen for a task suite in a random order.
shuffle_tasks_in_task_suite:
* True — Tasks in a task suite are shuffled on the page.
* False — Tasks in a task suite are placed on the page in the order they were created.
golden_task_distribution_function: Customizing the number of control tasks in a task suite depending on completed tasks by a Toloker.
training_task_distribution_function: Customizing the number of training tasks in a task suite depending on completed tasks by a Toloker.
"""

def __init__(
Expand Down
17 changes: 11 additions & 6 deletions src/client/pool/speed_quality_balance_config.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ import typing


class SpeedQualityBalanceConfig(toloka.client.primitives.base.BaseTolokaObject):
"""Adjust balance between speed and quality.
"""A configuration of selecting Tolokers based on a personalized quality forecast.
Tolokers are sorted by their quality forecast. You can limit the number of the best Tolokers who have access to your tasks.
It influences quality of results and speed of getting results.
Learn more about [Speed/quality balance](https://toloka.ai/en/docs/guide/concepts/adjust).
"""

class Type(toloka.util._extendable_enum.ExtendableStrEnum):
"""The type of speed quality balance:
"""The type of the filter used in [SpeedQualityBalanceConfig](toloka.client.pool.speed_quality_balance_config.SpeedQualityBalanceConfig.md).
Attributes:
TOP_PERCENTAGE_BY_QUALITY: get top XX% Tolokers by quality.
BEST_CONCURRENT_USERS_BY_QUALITY: get top x Tolokers by quality.
TOP_PERCENTAGE_BY_QUALITY: A percentage of the best Tolokers is configured.
BEST_CONCURRENT_USERS_BY_QUALITY: A maximum number of the best Tolokers is configured.
"""

TOP_PERCENTAGE_BY_QUALITY = 'TOP_PERCENTAGE_BY_QUALITY'
Expand All @@ -32,7 +37,7 @@ class SpeedQualityBalanceConfig(toloka.client.primitives.base.BaseTolokaObject):


class TopPercentageByQuality(SpeedQualityBalanceConfig):
"""The percentage of Tolokers ordered by quality that will work on pool.
"""`SpeedQualityBalanceConfig` that uses percentage of Tolokers.
"""

def __init__(self, *, percent: typing.Optional[int] = None) -> None:
Expand All @@ -45,7 +50,7 @@ class TopPercentageByQuality(SpeedQualityBalanceConfig):


class BestConcurrentUsersByQuality(SpeedQualityBalanceConfig):
"""How many concurrent Tolokers ordered by quality will work on pool.
"""`SpeedQualityBalanceConfig` that uses a maximum number of Tolokers.
"""

def __init__(self, *, count: typing.Optional[int] = None) -> None:
Expand Down
5 changes: 3 additions & 2 deletions src/client/project/localization.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ __all__ = [
'AdditionalLanguage',
'LocalizationConfig',
]
import attr._make
import enum
import toloka.client.primitives.base
import typing
Expand Down Expand Up @@ -37,7 +38,7 @@ class AdditionalLanguage(toloka.client.primitives.base.BaseTolokaObject):
self,
*,
value: typing.Optional[str] = None,
source: typing.Union[Source, str, None] = ...
source: typing.Union[Source, str, None] = attr._make._Nothing.NOTHING
) -> None:
"""Method generated by attrs for class AdditionalLanguage.FieldTranslation.
"""
Expand Down Expand Up @@ -82,7 +83,7 @@ class LocalizationConfig(toloka.client.primitives.base.BaseTolokaObject):
self,
*,
default_language: typing.Optional[str] = None,
additional_languages: typing.Optional[typing.List[AdditionalLanguage]] = ...
additional_languages: typing.Optional[typing.List[AdditionalLanguage]] = attr._make._Nothing.NOTHING
) -> None:
"""Method generated by attrs for class LocalizationConfig.
"""
Expand Down
3 changes: 2 additions & 1 deletion src/client/project/template_builder/plugins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ __all__ = [
'TriggerPluginV1',
'TolokaPluginV1',
]
import attr._make
import toloka.client.project.template_builder.base
import toloka.util._extendable_enum
import typing
Expand Down Expand Up @@ -337,7 +338,7 @@ class TolokaPluginV1(BasePluginV1):
@typing.overload
def __init__(
self,
layout: typing.Optional[typing.Union[toloka.client.project.template_builder.base.BaseComponent, TolokaPluginLayout]] = ...,
layout: typing.Optional[typing.Union[toloka.client.project.template_builder.base.BaseComponent, TolokaPluginLayout]] = attr._make._Nothing.NOTHING,
*,
notifications: typing.Optional[typing.Union[toloka.client.project.template_builder.base.BaseComponent, typing.List[toloka.client.project.template_builder.base.BaseComponent]]] = None,
version: typing.Optional[str] = '1.0.0'
Expand Down
Loading

0 comments on commit 14ae1fc

Please sign in to comment.