Toloka documentation

RestrictionV2

toloka.client.actions.RestrictionV2 | Source code

RestrictionV2(
    self,
    *,
    scope: Union[UserRestriction.Scope, str, None] = None,
    duration: Optional[int] = None,
    duration_unit: Union[DurationUnit, str, None] = None,
    private_comment: Optional[str] = None
)

Block access to projects or pools

Parameters Description

Parameters Type Description
scope Union[UserRestriction.Scope, str, None]

  • POOL - Current pool where this rule was triggered. Does not affect the user's rating.
  • PROJECT - Current project where this rule was triggered. Affects the user's rating.
  • ALL_PROJECTS - All customer's projects.

duration Optional[int]

Blocking period in duration_unit.

duration_unit Union[DurationUnit, str, None]

In what units the restriction duration is measured:

  • MINUTES
  • HOURS
  • DAYS
  • PERMANENT

private_comment Optional[str]

Comment (reason for blocking). Available only to the customer.

Examples:

How to ban performers who answers too fast.

new_pool = toloka.pool.Pool(....)
new_pool.quality_control.add_action(
    collector=toloka.collectors.AssignmentSubmitTime(history_size=5, fast_submit_threshold_seconds=20),
    conditions=[toloka.conditions.FastSubmittedCount > 1],
    action=toloka.actions.RestrictionV2(
        scope=toloka.user_restriction.UserRestriction.PROJECT,
        duration=10,
        duration_unit='DAYS',
        private_comment='Fast responses',
    )
)