From 196db193c0dd458bd56a58542fe00b2ff4b1e164 Mon Sep 17 00:00:00 2001 From: terehova Date: Mon, 12 Jul 2021 18:18:57 +0300 Subject: [PATCH 1/8] Docs - examples for TolokaClient methods Added examples for TolokaClient methods. In docstrings **** ![review](https://codereview.in.yandex-team.ru/badges/review-complete-green.svg) [![vlad--mois](https://codereview.in.yandex-team.ru/badges/vlad--mois-...-yellow.svg)](https://staff.yandex-team.ru/vlad-mois) [![sinosov](https://codereview.in.yandex-team.ru/badges/sinosov-ok-green.svg)](https://staff.yandex-team.ru/sinosov) ref:72d0c3b85fa1ac274cf1bcef80c749849b87a41f --- src/client/__init__.py | 641 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 589 insertions(+), 52 deletions(-) diff --git a/src/client/__init__.py b/src/client/__init__.py index 8d2b610b..f3a77a5a 100644 --- a/src/client/__init__.py +++ b/src/client/__init__.py @@ -157,13 +157,13 @@ class TolokaClient: * DAY - Retry daily quotas. We strongly not recommended retrying these quotas. Example: - How to create TolokaClient and make you first request to Toloka. + How to create TolokaClient instance and make your first request to Toloka. - >>> import toloka.client as toloka - >>> token = input("Enter your token:") - >>> toloka_client = toloka.TolokaClient(token, 'PRODUCTION') - >>> print(toloka_client.get_requester()) + >>> your_oauth_token = input('Enter your token:') + >>> toloka_client = toloka.TolokaClient(your_oauth_token, 'PRODUCTION') # Or switch to 'SANDBOX' environment ... + + **Note**: `toloka_client` instance will be used to pass all API calls later on. """ @unique @@ -318,7 +318,7 @@ def aggregate_solutions_by_pool(self, request: aggregation.PoolAggregatedSolutio Responses to all completed tasks will be aggregated. The method only starts the aggregation and returns the operation for further tracking. - Note: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation + **Note**: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation methods and can perform on your computers: https://github.com/Toloka/crowd-kit Args: @@ -379,7 +379,7 @@ def find_aggregated_solutions(self, operation_id: str, request: search_requests. """Gets aggregated responses after the AggregatedSolutionOperation completes. It is better to use the "get_aggregated_solutions" method, that allows to iterate through all results. - Note: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation + **Note**: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation methods and can perform on your computers: https://github.com/Toloka/crowd-kit Args: @@ -390,7 +390,7 @@ def find_aggregated_solutions(self, operation_id: str, request: search_requests. Defaults to None, in which case it returns first 50 results. Returns: - search_results.AggregatedSolutionSearchResult: The first "limit" solutions in "items". And a mark that there is more. + search_results.AggregatedSolutionSearchResult: The first `limit` solutions in `items`. And a mark that there is more. Example: How to get all aggregated solutions from pool. @@ -416,7 +416,7 @@ def find_aggregated_solutions(self, operation_id: str, request: search_requests. def get_aggregated_solutions(self, operation_id: str, request: search_requests.AggregatedSolutionSearchRequest) -> Generator[AggregatedSolution, None, None]: """Finds all aggregated responses after the AggregatedSolutionOperation completes - Note: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation + **Note**: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation methods and can perform on your computers: https://github.com/Toloka/crowd-kit Args: @@ -431,7 +431,6 @@ def get_aggregated_solutions(self, operation_id: str, request: search_requests.A >>> # run toloka_client.aggregate_solutions_by_pool and wait operation for closing. >>> aggregation_results = list(toloka_client.get_aggregated_solutions(aggregation_operation.id)) - >>> print(len(aggregation_results)) ... """ find_function = functools.partial(self.find_aggregated_solutions, operation_id) @@ -454,7 +453,8 @@ def accept_assignment(self, assignment_id: str, public_comment: str) -> Assignme Example: How to accept one assignment. - >>> toloka_client.accept_assignment(assignment_id, "Well done!") + >>> toloka_client.accept_assignment(assignment_id, 'Well done!') + ... """ return self.patch_assignment(assignment_id, public_comment=public_comment, status=Assignment.ACCEPTED) @@ -476,8 +476,15 @@ def find_assignments(self, request: search_requests.AssignmentSearchRequest, Defaults to None, in which case it returns first 50 results. Returns: - search_results.AssignmentSearchResult: The first "limit" assignments in "items". And a mark that there is more. + search_results.AssignmentSearchResult: The first `limit` assignments in `items`. And a mark that there is more. + + Example: + Search for `SKIPPED` or `EXPIRED` assignments in the specified pool. + >>> toloka_client.find_assignments(pool_id='1', status = ['SKIPPED', 'EXPIRED']) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ sort = None if sort is None else structure(sort, search_requests.AssignmentSortItems) response = self._search_request('get', '/v1/assignments', request, sort, limit) @@ -491,6 +498,10 @@ def get_assignment(self, assignment_id: str) -> Assignment: Returns: Assignment: The solution read as a result. + + Example: + >>> toloka_client.get_assignment(assignment_id='1') + ... """ response = self._request('get', f'/v1/assignments/{assignment_id}') return structure(response, Assignment) @@ -509,10 +520,11 @@ def get_assignments(self, request: search_requests.AssignmentSearchRequest) -> G Assignment: The next object corresponding to the request parameters. Example: - How to process all accepted assignmens. + Let’s make a list of `assignment_id` of all `SUBMITTED` assignments in the specified pool. - >>> for assignment in toloka_client.get_assignments(pool_id=some_pool_id, status=['ACCEPTED', 'SUBMITTED']): - >>> # somehow process "assignment" + >>> from toloka.client import Assignment + >>> assignments = toloka_client.get_assignments(pool_id='1', status=Assignment.SUBMITTED) + >>> result_list = [assignment.id for assignment in assignments] ... """ return self._find_all(self.find_assignments, request) @@ -529,6 +541,10 @@ def patch_assignment(self, assignment_id: str, patch: AssignmentPatch) -> Assign Returns: Assignment: Object with new status. + + Example: + >>> toloka_client.patch_assignment(assignment_id='1', public_comment='Some issues present, but work is acceptable', status='ACCEPTED') + ... """ response = self._request('patch', f'/v1/assignments/{assignment_id}', json=unstructure(patch)) return structure(response, Assignment) @@ -546,9 +562,10 @@ def reject_assignment(self, assignment_id: str, public_comment: str) -> Assignme Assignment: Object with new status. Example: - How to reject one assignment. + Reject an assignment that was completed too fast. - >>> toloka_client.reject_assignment(assignment_id, "Bad work.") + >>> toloka_client.reject_assignment(assignment_id='1', 'Assignment was completed too fast.') + ... """ return self.patch_assignment(assignment_id, public_comment=public_comment, status=Assignment.REJECTED) @@ -572,7 +589,15 @@ def find_attachments(self, request: search_requests.AttachmentSearchRequest, Defaults to None, in which case it returns first 50 results. Returns: - search_results.AttachmentSearchResult: The first "limit" assignments in "items". And a mark that there is more. + search_results.AttachmentSearchResult: The first `limit` assignments in `items`. And a mark that there is more. + + Example: + Let's find attachments in the pool and sort them by id and date of creation. + + >>> toloka_client.find_attachments(pool_id='1', sort=['-created', '-id'], limit=10) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ sort = None if sort is None else structure(sort, search_requests.AttachmentSortItems) response = self._search_request('get', '/v1/attachments', request, sort, limit) @@ -588,6 +613,12 @@ def get_attachment(self, attachment_id: str) -> Attachment: Returns: Attachment: The attachment metadata read as a result. + + Example: + Specify an `attachment_id` to get the information about any attachment object. + + >>> toloka_client.get_attachment(attachment_id='1') + ... """ response = self._request('get', f'/v1/attachments/{attachment_id}') return structure(response, Attachment) @@ -604,6 +635,12 @@ def get_attachments(self, request: search_requests.AttachmentSearchRequest) -> G Yields: Attachment: The next object corresponding to the request parameters. + + Example: + Make a list of all received attachments in the specified pool. + + >>> results_list = [attachment for attachment in toloka_client.get_attachments(pool_id='1')] + ... """ return self._find_all(self.find_attachments, request) @@ -615,10 +652,10 @@ def download_attachment(self, attachment_id: str, out: BinaryIO) -> None: out: File object where to put downloaded file. Example: - How to download attachment. + How to download an attachment. >>> with open('my_new_file.txt', 'wb') as out_f: - >>> toloka_client.download_attachment('attachment-id', out_f) + >>> toloka_client.download_attachment(attachment_id='1', out=out_f) ... """ response = self._raw_request('get', f'/v1/attachments/{attachment_id}/download', stream=True) @@ -636,6 +673,10 @@ def add_message_thread_to_folders(self, message_thread_id: str, folders: Union[L Returns: MessageThread: Full object by ID with updated folders. + + Example: + >>> toloka_client.add_message_thread_to_folders(message_thread_id='1', folders=['IMPORTANT']) + ... """ if not isinstance(folders, MessageThreadFolders): folders = structure({'folders': folders}, MessageThreadFolders) @@ -653,6 +694,18 @@ def compose_message_thread(self, compose: MessageThreadCompose) -> MessageThread Returns: MessageThread: New created thread. + + Example: + If you want to thank Toloka performers who have tried to complete your tasks, send them a nice message. + + >>> message_text = 'Amazing job! We\'ve just trained our first model with the data YOU prepared for us. Thank you!' + >>> toloka_client.compose_message_thread( + >>> recipients_select_type='ALL', + >>> topic={'EN':'Thank you, performer!'}, + >>> text={'EN': message_text}, + >>> answerable=False + >>> ) + ... """ response = self._request('post', '/v1/message-threads/compose', json=unstructure(compose)) return structure(response, MessageThread) @@ -675,8 +728,14 @@ def find_message_threads(self, request: search_requests.MessageThreadSearchReque Defaults to None, in which case it returns first 50 results. Returns: - search_results.MessageThreadSearchResult: The first "limit" message threads in "items". + search_results.MessageThreadSearchResult: The first `limit` message threads in `items`. And a mark that there is more. + + Example: + Find all message threads in the Inbox folder. + + >>> toloka_client.find_message_threads(folder='INBOX') + ... """ sort = None if sort is None else structure(sort, search_requests.MessageThreadSortItems) response = self._search_request('get', '/v1/message-threads', request, sort, limit) @@ -691,6 +750,13 @@ def reply_message_thread(self, message_thread_id: str, reply: MessageThreadReply Returns: MessageThread: New created message. + + Example: + >>> message_threads = toloka_client.get_message_threads(folder='UNREAD') + >>> message_reply = {'EN': 'Thank you for your message! I will get back to you soon.'} + >>> for thread in message_threads: + >>> toloka_client.reply_message_thread(message_thread_id=thread.id, reply=toloka.message_thread.MessageThreadReply(text=message_reply)) + ... """ response = self._request('post', f'/v1/message-threads/{message_thread_id}/reply', json=unstructure(reply)) return structure(response, MessageThread) @@ -725,6 +791,10 @@ def remove_message_thread_from_folders(self, message_thread_id: str, folders: Un Returns: MessageThread: Full object by ID with updated folders. + + Example: + >>> toloka_client.remove_message_thread_from_folders(message_thread_id='1', folders=['IMPORTANT']) + ... """ if not isinstance(folders, MessageThreadFolders): folders = structure({'folders': folders}, MessageThreadFolders) @@ -744,6 +814,10 @@ def archive_project(self, project_id: str) -> Project: Returns: Project: Object with updated status. + + Example: + >>> toloka_client.archive_project(project_id='1') + ... """ operation = self.archive_project_async(project_id) operation = self.wait_operation(operation) @@ -760,6 +834,11 @@ def archive_project_async(self, project_id: str) -> operations.ProjectArchiveOpe Returns: ProjectArchiveOperation: An operation upon completion of which you can get the project with updated status. + + Example: + >>> archive_op = toloka_client.archive_project_async(project_id='1') + >>> toloka_client.wait_operation(archive_op) + ... """ response = self._request('post', f'/v1/projects/{project_id}/archive') return structure(response, operations.ProjectArchiveOperation) @@ -814,8 +893,16 @@ def find_projects(self, request: search_requests.ProjectSearchRequest, Defaults to None, in which case it returns first 20 results. Returns: - search_results.ProjectSearchResult: The first "limit" projects in "items". + search_results.ProjectSearchResult: The first `limit` projects in `items`. And a mark that there is more. + + Example: + Find projects that were created before a specific date. + + >>> toloka_client.find_projects(created_lt='2021-06-01T00:00:00') + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ sort = None if sort is None else structure(sort, search_requests.ProjectSortItems) response = self._search_request('get', '/v1/projects', request, sort, limit) @@ -829,6 +916,10 @@ def get_project(self, project_id: str) -> Project: Returns: Project: The project. + + Example: + >>> toloka_client.get_project(project_id='1') + ... """ response = self._request('get', f'/v1/projects/{project_id}') return structure(response, Project) @@ -847,12 +938,12 @@ def get_projects(self, request: search_requests.ProjectSearchRequest) -> Generat Project: The next object corresponding to the request parameters. Example: - How to get all active projects. + Get all active projects. - >>> active_projects = toloka_client.get_projects(status='ACTIVE'): + >>> active_projects = toloka_client.get_projects(status='ACTIVE') ... - How to get all your projects. + Get all your projects. >>> my_projects = toloka_client.get_projects() ... @@ -868,6 +959,10 @@ def update_project(self, project_id: str, project: Project) -> Project: Returns: Project: Project object with all fields. + + Example: + >>> updated_project = toloka_client.update_project(project_id=old_project.id, project=new_project_object) + ... """ response = self._request('put', f'/v1/projects/{project_id}', json=unstructure(project)) return structure(response, Project) @@ -958,6 +1053,11 @@ def archive_pool(self, pool_id: str) -> Pool: Returns: Pool: Object with updated status. + + Example: + >>> closed_pool = next(toloka_client.get_pools(status='CLOSED')) + >>> toloka_client.archive_pool(pool_id=closed_pool.id) + ... """ operation = self.archive_pool_async(pool_id) operation = self.wait_operation(operation) @@ -974,6 +1074,12 @@ def archive_pool_async(self, pool_id: str) -> operations.PoolArchiveOperation: Returns: PoolArchiveOperation: An operation upon completion of which you can get the pool with updated status. + + Example: + >>> closed_pool = next(toloka_client.get_pools(status='CLOSED')) + >>> archive_op = toloka_client.archive_pool_async(pool_id=closed_pool.id) + >>> toloka_client.wait_operation(archive_op) + ... """ response = self._request('post', f'/v1/pools/{pool_id}/archive') return structure(response, operations.PoolArchiveOperation) @@ -988,6 +1094,11 @@ def close_pool(self, pool_id: str) -> Pool: Returns: Pool: Pool object with new status. + + Example: + >>> open_pool = next(toloka_client.get_pools(status='OPEN')) + >>> toloka_client.close_pool(pool_id=open_pool.id) + ... """ operation = self.close_pool_async(pool_id) operation = self.wait_operation(operation) @@ -1003,16 +1114,35 @@ def close_pool_async(self, pool_id: str) -> operations.PoolCloseOperation: Returns: PoolCloseOperation: An operation upon completion of which you can get the pool with updated status. + + Example: + >>> open_pool = next(toloka_client.get_pools(status='OPEN')) + >>> close_op = toloka_client.close_pool_async(pool_id=open_pool.id) + >>> toloka_client.wait_operation(close_op) + ... """ response = self._request('post', f'/v1/pools/{pool_id}/close') return structure(response, operations.PoolCloseOperation) def close_pool_for_update(self, pool_id: str) -> Pool: + """Closes pool for update + + Example: + >>> toloka_client.close_pool_for_update(pool_id='1') + ... + """ operation = self.close_pool_for_update_async(pool_id) operation = self.wait_operation(operation) return self.get_pool(operation.parameters.pool_id) def close_pool_for_update_async(self, pool_id: str) -> operations.PoolCloseOperation: + """Closes pool for update, asynchronous version + + Example: + >>> close_op = toloka_client.close_pool_for_update_async(pool_id='1') + >>> toloka_client.wait_operation(close_op) + ... + """ response = self._request('post', f'/v1/pools/{pool_id}/close-for-update') return structure(response, operations.PoolCloseOperation) @@ -1027,6 +1157,10 @@ def clone_pool(self, pool_id: str) -> Pool: Returns: Pool: New pool. + + Example: + >>> toloka_client.clone_pool(pool_id='1') + ... """ operation = self.clone_pool_async(pool_id) operation = self.wait_operation(operation) @@ -1045,6 +1179,11 @@ def clone_pool_async(self, pool_id: str) -> operations.PoolCloneOperation: Returns: PoolCloneOperation: An operation upon completion of which you can get the new pool. + + Example: + >>> new_pool = toloka_client.clone_pool_async(pool_id='1') + >>> toloka_client.wait_operation(new_pool) + ... """ response = self._request('post', f'/v1/pools/{pool_id}/clone') return structure(response, operations.PoolCloneOperation) @@ -1063,7 +1202,6 @@ def create_pool(self, pool: Pool) -> Pool: Example: How to create a new pool in a project. - >>> toloka_client = toloka.TolokaClient(your_token, 'PRODUCTION') >>> new_pool = toloka.pool.Pool( >>> project_id=existing_project_id, >>> private_name='Pool 1', @@ -1106,8 +1244,26 @@ def find_pools(self, request: search_requests.PoolSearchRequest, Defaults to None, in which case it returns first 20 results. Returns: - search_results.PoolSearchResult: The first "limit" pools in "items". + search_results.PoolSearchResult: The first `limit` pools in `items`. And a mark that there is more. + + Examples: + Find all pools in all projects. + + >>> toloka_client.find_pools() + ... + + Find all open pools in all projects. + + >>> toloka_client.find_pools(status='OPEN') + ... + + Find open pools in a specific project. + + >>> toloka_client.find_pools(status='OPEN', project_id='1') + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ sort = None if sort is None else structure(sort, search_requests.PoolSortItems) response = self._search_request('get', '/v1/pools', request, sort, limit) @@ -1121,6 +1277,10 @@ def get_pool(self, pool_id: str) -> Pool: Returns: Pool: The pool. + + Example: + >>> toloka_client.get_pool(pool_id='1') + ... """ response = self._request('get', f'/v1/pools/{pool_id}') return structure(response, Pool) @@ -1141,12 +1301,12 @@ def get_pools(self, request: search_requests.PoolSearchRequest) -> Generator[Poo Example: How to get all open pools from project. - >>> open_pools = toloka_client.get_pools(project_id=my_project_id, status='OPEN') + >>> open_pools = toloka_client.get_pools(project_id='1', status='OPEN') ... How to get all pools from project. - >>> all_pools = toloka_client.get_pools(project_id=my_project_id) + >>> all_pools = toloka_client.get_pools(project_id='1') ... """ return self._find_all(self.find_pools, request) @@ -1161,6 +1321,12 @@ def open_pool(self, pool_id: str) -> Pool: Returns: Pool: Pool object with new status. + + Example: + Open the pool for performers. + + >>> toloka_client.open_pool(pool_id='1') + ... """ operation = self.open_pool_async(pool_id) operation = self.wait_operation(operation) @@ -1176,6 +1342,13 @@ def open_pool_async(self, pool_id: str) -> operations.PoolOpenOperation: Returns: PoolOpenOperation: An operation upon completion of which you can get the pool with new status. + + Example: + Open the pool for performers. + + >>> open_pool = toloka_client.open_pool(pool_id='1') + >>> toloka_client.wait_operation(open_pool) + ... """ response = self._request('post', f'/v1/pools/{pool_id}/open') return structure(response, operations.PoolOpenOperation) @@ -1192,11 +1365,9 @@ def patch_pool(self, pool_id: str, request: PoolPatchRequest) -> Pool: Pool: Object with updated priority. Example: - How to set highest priority to some pool. + Set the highest priority to a specified pool. - >>> toloka_client = toloka.TolokaClient(your_token, 'PRODUCTION') - >>> patched_pool = toloka_client.patch_pool(existing_pool_id, 100) - >>> print(patched_pool.priority) + >>> toloka_client.patch_pool(pool_id='1', priority=100) ... """ response = self._request('patch', f'/v1/pools/{pool_id}', json=unstructure(request)) @@ -1211,6 +1382,10 @@ def update_pool(self, pool_id: str, pool: Pool) -> Pool: Returns: Pool: Pool object with all fields. + + Example: + >>> updated_pool = toloka_client.update_pool(pool_id=old_pool_id, pool=new_pool_object) + ... """ if pool.type == Pool.Type.TRAINING: raise ValueError('Training pools are not supported') @@ -1230,6 +1405,11 @@ def archive_training(self, training_id: str) -> Training: Returns: Training: Object with updated status. + + Example: + >>> closed_training = next(toloka_client.get_trainings(status='CLOSED')) + >>> toloka_client.archive_training(training_id=closed_training.id) + ... """ operation = self.archive_training_async(training_id) operation = self.wait_operation(operation) @@ -1246,6 +1426,12 @@ def archive_training_async(self, training_id: str) -> operations.TrainingArchive Returns: TrainingArchiveOperation: An operation upon completion of which you can get the training with updated status. + + Example: + >>> closed_training = next(toloka_client.find_trainings(status='CLOSED')) + >>> archive_op = toloka_client.archive_training_async(training_id=closed_training.id) + >>> toloka_client.wait_operation(archive_op) + ... """ response = self._request('post', f'/v1/trainings/{training_id}/archive') return structure(response, operations.TrainingArchiveOperation) @@ -1258,6 +1444,11 @@ def close_training(self, training_id: str) -> Training: Returns: Training: Training object with new status. + + Example: + >>> open_training = next(toloka_client.get_trainings(status='OPEN')) + >>> toloka_client.close_training(training_id=open_training.id) + ... """ operation = self.close_training_async(training_id) operation = self.wait_operation(operation) @@ -1271,6 +1462,12 @@ def close_training_async(self, training_id: str) -> operations.TrainingCloseOper Returns: TrainingCloseOperation: An operation upon completion of which you can get the training with updated status. + + Example: + >>> open_training = next(toloka_client.get_trainings(status='OPEN')) + >>> close_training = toloka_client.close_training_async(training_id=open_training.id) + >>> toloka_client.wait_operation(close_training) + ... """ response = self._request('post', f'/v1/trainings/{training_id}/close') return structure(response, operations.TrainingCloseOperation) @@ -1286,6 +1483,10 @@ def clone_training(self, training_id: str) -> Training: Returns: Training: New training. + + Example: + >>> toloka_client.clone_training(training_id='1') + ... """ operation = self.clone_training_async(training_id) operation = self.wait_operation(operation) @@ -1304,6 +1505,11 @@ def clone_training_async(self, training_id: str) -> operations.TrainingCloneOper Returns: TrainingCloneOperation: An operation upon completion of which you can get the new training. + + Example: + >>> clone_training = toloka_client.clone_training_async(training_id='1') + >>> toloka_client.wait_operation(clone_training) + ... """ response = self._request('post', f'/v1/trainings/{training_id}/clone') return structure(response, operations.TrainingCloneOperation) @@ -1359,8 +1565,26 @@ def find_trainings(self, request: search_requests.TrainingSearchRequest, limit: Limit on the number of results returned. Returns: - search_results.PoolSearchResult: The first "limit" trainings in "items". + search_results.TrainingSearchResult: The first `limit` trainings in `items`. And a mark that there is more. + + Examples: + Find all trainings in all projects. + + >>> toloka_client.find_trainings() + ... + + Find all open trainings in all projects. + + >>> toloka_client.find_trainings(status='OPEN') + ... + + Find all open trainings in a specific project. + + >>> toloka_client.find_trainings(status='OPEN', project_id='1') + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ sort = None if sort is None else structure(sort, search_requests.TrainingSortItems) response = self._search_request('get', '/v1/trainings', request, sort, limit) @@ -1374,6 +1598,10 @@ def get_training(self, training_id: str) -> Training: Returns: Training: The training. + + Example: + >>> toloka_client.get_training(training_id='1') + ... """ response = self._request('get', f'/v1/trainings/{training_id}') return structure(response, Training) @@ -1407,6 +1635,12 @@ def open_training(self, training_id: str) -> Training: Returns: Training: Training object with new status. + + Example: + Open the training for performers. + + >>> toloka_client.open_training(training_id='1') + ... """ operation = self.open_training_async(training_id) operation = self.wait_operation(operation) @@ -1420,6 +1654,13 @@ def open_training_async(self, training_id: str) -> operations.TrainingOpenOperat Returns: TrainingOpenOperation: An operation upon completion of which you can get the training with new status. + + Example: + Open the training for performers. + + >>> open_training = toloka_client.open_training_async(training_id='1') + >>> toloka_client.wait_operation(open_training) + ... """ response = self._request('post', f'/v1/trainings/{training_id}/open') return structure(response, operations.TrainingOpenOperation) @@ -1433,6 +1674,12 @@ def update_training(self, training_id: str, training: Training) -> Training: Returns: Training: Training object with all fields. + + Example: + If you want to update any configurations of the existing training. + + >>> updated_training = toloka_client.update_training(training_id=old_training_id, training=new_training_object) + ... """ response = self._request('put', f'/v1/trainings/{training_id}', json=unstructure(training)) return structure(response, Training) @@ -1452,13 +1699,13 @@ def create_skill(self, skill: Skill) -> Skill: Skill: Created skill. With read-only fields. Example: - How to create new skill. + How to create a new skill. >>> new_skill = toloka_client.create_skill( >>> name='Area selection of road signs', >>> public_requester_description={ >>> 'EN': 'Performer is annotating road signs', - >>> 'RU': 'Как исполнитель размечает дорожные знаки', + >>> 'FR': 'L'exécuteur marque les signaux routier', >>> }, >>> ) >>> print(new_skill.id) @@ -1486,8 +1733,16 @@ def find_skills(self, request: search_requests.SkillSearchRequest, limit: Limit on the number of results returned. Returns: - SkillSearchResult: The first "limit" skills in "items". + SkillSearchResult: The first `limit` skills in `items`. And a mark that there is more. + + Example: + Find ten most recently created skills. + + >>> toloka_client.find_skills(sort=['-created', '-id'], limit=10) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ sort = None if sort is None else structure(sort, search_requests.SkillSortItems) response = self._search_request('get', '/v1/skills', request, sort, limit) @@ -1501,6 +1756,10 @@ def get_skill(self, skill_id: str) -> Skill: Returns: Skill: The skill. + + Example: + >>> toloka_client.get_skill(skill_id='1') + ... """ response = self._request('get', f'/v1/skills/{skill_id}') return structure(response, Skill) @@ -1539,6 +1798,10 @@ def update_skill(self, skill_id: str, skill: Skill) -> Skill: Returns: Skill: Modified skill object with all fields. + + Example: + >>> toloka_client.create_skill(skill_id=old_skill_id, skill=new_skill_object) + ... """ response = self._request('put', f'/v1/skills/{skill_id}', json=unstructure(skill)) return structure(response, Skill) @@ -1587,6 +1850,13 @@ def create_task(self, task: Task, parameters: Optional[task.CreateTaskParameters Returns: Task: Created task. + + Example: + >>> task = toloka.task.Task( + >>> input_values={'image': 'https://tlk.s3.yandex.net/dataset/cats_vs_dogs/dogs/048e5760fc5a46faa434922b2447a527.jpg'}, + >>> pool_id='1') + >>> toloka_client.create_task(task=task, allow_defaults=True) + ... """ response = self._request('post', '/v1/tasks', json=unstructure(task), params=unstructure(parameters)) return structure(response, Task) @@ -1607,7 +1877,7 @@ def create_tasks(self, tasks: List[Task], parameters: Optional[task.CreateTasksP operations is used. Returns: - batch_create_results.TaskBatchCreateResult: Result of tasks creating. Contains created tasks in "items" and + batch_create_results.TaskBatchCreateResult: Result of tasks creating. Contains created tasks in `items` and problems in "validation_errors". Raises: @@ -1615,7 +1885,7 @@ def create_tasks(self, tasks: List[Task], parameters: Optional[task.CreateTasksP checking any task. Example: - How to create regular tasks from csv. + How to create regular tasks from tsv. >>> dataset = pandas.read_csv('dataset.tsv', sep='\t') >>> tasks = [ @@ -1667,6 +1937,19 @@ def create_tasks_async(self, tasks: List[Task], parameters: Optional[task.Create Returns: TasksCreateOperation: An operation upon completion of which you can get the created tasks. + + Example: + >>> training_tasks = [ + >>> toloka.task.Task( + >>> input_values={'image': 'link1'}, + >>> pool_id='1'), + >>> toloka.task.Task( + >>> input_values={'image': 'link2'}, + >>> pool_id='1') + >>> ] + >>> tasks_op = toloka_client.create_tasks_async(training_tasks) + >>> toloka_client.wait_operation(tasks_op) + ... """ params = {**(unstructure(parameters) or {}), 'async_mode': True} response = self._request('post', '/v1/tasks', json=unstructure(tasks), params=params) @@ -1690,7 +1973,15 @@ def find_tasks(self, request: search_requests.TaskSearchRequest, Defaults to None, in which case it returns first 50 results. Returns: - TaskSearchResult: The first "limit" tasks in "items". And a mark that there is more. + TaskSearchResult: The first `limit` tasks in `items`. And a mark that there is more. + + Example: + Find three most recently created tasks in a specified pool. + + >>> toloka_client.find_tasks(pool_id='1', sort=['-created', '-id'], limit=3) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ sort = None if sort is None else structure(sort, search_requests.TaskSortItems) response = self._search_request('get', '/v1/tasks', request, sort, limit) @@ -1704,6 +1995,10 @@ def get_task(self, task_id: str) -> Task: Returns: Task: The task. + + Example: + >>> toloka_client.get_task(task_id='1') + ... """ response = self._request('get', f'/v1/tasks/{task_id}') return structure(response, Task) @@ -1720,6 +2015,12 @@ def get_tasks(self, request: search_requests.TaskSearchRequest) -> Generator[Tas Yields: Task: The next object corresponding to the request parameters. + + Example: + Get tasks from a specific pool. + + >>> results_list = [task for task in toloka_client.get_tasks(pool_id='1')] + ... """ return self._find_all(self.find_tasks, request) @@ -1747,6 +2048,14 @@ def patch_task_overlap_or_min(self, task_id: str, patch: task.TaskOverlapPatch) Returns: Task: Task with updated fields. + + Example: + Set an infinite overlap for a specific task in training. + + >>> toloka_client.patch_task_overlap_or_min(task_id='1', infinite_overlap=True) + ... + + **Note**: you can't set infinite overlap in a regular pool. """ response = self._request('patch', f'/v1/tasks/{task_id}/set-overlap-or-min', json=unstructure(patch)) return structure(response, Task) @@ -1769,6 +2078,14 @@ def create_task_suite(self, task_suite: TaskSuite, parameters: Optional[task_sui Returns: TaskSuite: Created task suite. + + Example: + >>> new_task_suite = toloka.task_suite.TaskSuite( + >>> pool_id='1', + >>> tasks=[toloka.task.Task(input_values={'label': 'Cats vs Dogs'})], + >>> overlap=2) + >>> toloka_client.create_task_suite(new_task_suite) + ... """ params = {**(unstructure(parameters) or {}), 'async_mode': False} response = self._request('post', '/v1/task-suites', json=unstructure(task_suite), params=unstructure(params)) @@ -1793,12 +2110,28 @@ def create_task_suites(self, task_suites: List[TaskSuite], parameters: Optional[ operations is used. Returns: - TaskSuiteBatchCreateResult: Result of task suites creating. Contains created task suites in "items" and + TaskSuiteBatchCreateResult: Result of task suites creating. Contains created task suites in `items` and problems in "validation_errors". Raises: ValidationApiError: If no tasks were created, or skip_invalid_items==False and there is a problem when checking any task. + + Example: + >>> task_suites = [ + >>> toloka.task_suite.TaskSuite( + >>> pool_id=pool.id, + >>> overlap=1, + >>> tasks=[ + >>> toloka.task.Task(input_values={ + >>> 'input1': some_input_value, + >>> 'input2': some_input_value + >>> }) + >>> ] + >>> ) + >>> ] + >>> task_suites = toloka_client.create_task_suites(task_suites) + ... """ if not parameters: parameters = task_suite.TaskSuiteCreateRequestParameters() @@ -1825,6 +2158,23 @@ def create_task_suites_async(self, task_suites: List[TaskSuite], parameters: Opt Returns: TaskSuiteCreateBatchOperation: An operation upon completion of which you can get the created teask suites. + + Example: + >>> task_suites = [ + >>> toloka.task_suite.TaskSuite( + >>> pool_id=pool.id, + >>> overlap=1, + >>> tasks=[ + >>> toloka.task.Task(input_values={ + >>> 'input1': some_input_value, + >>> 'input2': some_input_value + >>> }) + >>> ] + >>> ) + >>> ] + >>> task_suites_op = toloka_client.create_task_suites_async(task_suites) + >>> toloka_client.wait_operation(task_suites_op) + ... """ params = {**(unstructure(parameters) or {}), 'async_mode': True} response = self._request('post', '/v1/task-suites', json=unstructure(task_suites), params=params) @@ -1848,7 +2198,15 @@ def find_task_suites(self, request: search_requests.TaskSuiteSearchRequest, Defaults to None, in which case it returns first 50 results. Returns: - TaskSuiteSearchResult: The first "limit" task suites in "items". And a mark that there is more. + TaskSuiteSearchResult: The first `limit` task suites in `items`. And a mark that there is more. + + Example: + Find three most recently created task suites in a specified pool. + + >>> toloka_client.find_task_suites(pool_id='1', sort=['-created', '-id'], limit=3) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ sort = None if sort is None else structure(sort, search_requests.TaskSuiteSortItems) response = self._search_request('get', '/v1/task-suites', request, sort, limit) @@ -1862,6 +2220,10 @@ def get_task_suite(self, task_suite_id: str) -> TaskSuite: Returns: TaskSuite: The task suite. + + Example: + >>> toloka_client.get_task_suite(task_suite_id='1') + ... """ response = self._request('get', f'/v1/task-suites/{task_suite_id}') return structure(response, TaskSuite) @@ -1878,6 +2240,12 @@ def get_task_suites(self, request: search_requests.TaskSuiteSearchRequest) -> Ge Yields: TaskSuite: The next object corresponding to the request parameters. + + Example: + Get task suites from a specific pool. + + >>> results_list = [task_suite for task_suite in toloka_client.get_task_suites(pool_id='1')] + ... """ return self._find_all(self.find_task_suites, request) @@ -1891,6 +2259,12 @@ def patch_task_suite(self, task_suite_id: str, patch: task_suite.TaskSuitePatch) Returns: TaskSuite: Task suite with updated fields. + + Example: + Change the task suite's priority. + + >>> toloka_client.patch_task_suite(task_suite_id='1', issuing_order_override=100) + ... """ body = unstructure(patch) params = {'open_pool': body.pop('open_pool')} if 'open_pool' in body else None @@ -1907,6 +2281,10 @@ def patch_task_suite_overlap_or_min(self, task_suite_id: str, patch: task_suite. Returns: TaskSuite: Task suite with updated fields. + + Example: + >>> toloka_client.patch_task_suite_overlap_or_min(task_suite_id='1', overlap=100) + ... """ body = unstructure(patch) params = {'open_pool': body.pop('open_pool')} if 'open_pool' in body else None @@ -1926,6 +2304,10 @@ def get_operation(self, operation_id: str) -> operations.Operation: Returns: Operation: The operation. + + Example: + >>> op = toloka_client.get_operation(operation_id='1') + ... """ response = self._request('get', f'/v1/operations/{operation_id}') return structure(response, operations.Operation) @@ -1942,6 +2324,23 @@ def wait_operation(self, op: operations.Operation, timeout: datetime.timedelta = Returns: Operation: Completed operation. + + Example: + Waiting for the pool to close can be running in the background. + + >>> pool = toloka_client.get_pool(pool_id) + >>> while not pool.is_closed(): + >>> op = toloka_client.get_analytics([toloka.analytics_request.CompletionPercentagePoolAnalytics(subject_id=pool.id)]) + >>> op = toloka_client.wait_operation(op) + >>> percentage = op.details['value'][0]['result']['value'] + >>> print( + >>> f' {datetime.datetime.now().strftime("%H:%M:%S")}\t' + >>> f'Pool {pool.id} - {percentage}%' + >>> ) + >>> time.sleep(60 * minutes_to_wait) + >>> pool = toloka_client.get_pool(pool.id) + >>> print('Pool was closed.') + ... """ default_time_to_wait = datetime.timedelta(seconds=1) default_initial_delay = datetime.timedelta(milliseconds=500) @@ -1975,6 +2374,10 @@ def get_operation_log(self, operation_id: str) -> List[OperationLogItem]: Returns: List[OperationLogItem]: Logs for the operation. + + Example: + >>> op = toloka_client.get_operation_log(operation_id='1') + ... """ response = self._request('get', f'/v1/operations/{operation_id}/log') return structure(response, List[OperationLogItem]) @@ -1994,14 +2397,15 @@ def create_user_bonus(self, user_bonus: UserBonus, parameters: Optional[UserBonu UserBonus: Created bonus. Example: - How to create bonus with message for specific assignment. + Create bonus for specific assignment. + >>> import decimal >>> new_bonus = toloka_client.create_user_bonus( >>> UserBonus( >>> user_id='1', - >>> amount='0.50', + >>> amount=decimal.Decimal('0.50'), >>> public_title='Perfect job!', - >>> public_message='You are the best performer EVER!' + >>> public_message='You are the best performer!', >>> assignment_id='012345' >>> ) >>> ) @@ -2025,8 +2429,27 @@ def create_user_bonuses(self, user_bonuses: List[UserBonus], parameters: Optiona parameters: Parameters for UserBonus creation controlling. Returns: - UserBonusBatchCreateResult: Result of user bonuses creating. Contains created user bonuses in "items" and + UserBonusBatchCreateResult: Result of user bonuses creating. Contains created user bonuses in `items` and problems in "validation_errors". + + Example: + >>> import decimal + >>> new_bonuses=[ + >>> UserBonus( + >>> user_id='1', + >>> amount=decimal.Decimal('0.50'), + >>> public_title='Perfect job!', + >>> public_message='You are the best performer!', + >>> assignment_id='1'), + >>> UserBonus( + >>> user_id='2', + >>> amount=decimal.Decimal('1.0'), + >>> public_title='Excellent work!', + >>> public_message='You completed all the tasks!', + >>> assignment_id='2') + >>> ] + >>> toloka_client.create_user_bonuses(new_bonuses) + ... """ response = self._request( 'post', '/v1/user-bonuses', json=unstructure(user_bonuses), @@ -2046,6 +2469,26 @@ def create_user_bonuses_async(self, user_bonuses: List[UserBonus], parameters: O Returns: UserBonusCreateBatchOperation: An operation upon completion of which the bonuses can be considered created. + + Example: + >>> import decimal + >>> new_bonuses=[ + >>> UserBonus( + >>> user_id='1', + >>> amount=decimal.Decimal('0.50'), + >>> public_title='Perfect job!', + >>> public_message='You are the best performer!', + >>> assignment_id='1'), + >>> UserBonus( + >>> user_id='2', + >>> amount=decimal.Decimal('1.0'), + >>> public_title='Excellent work!', + >>> public_message='You completed all the tasks!', + >>> assignment_id='2') + >>> ] + >>> create_bonuses = toloka_client.create_user_bonuses_async(new_bonuses) + >>> toloka_client.wait_operation(create_bonuses) + ... """ params = {'async_mode': True, **(unstructure(parameters) or {})} response = self._request('post', '/v1/user-bonuses', json=unstructure(user_bonuses), params=params) @@ -2068,8 +2511,14 @@ def find_user_bonuses(self, request: search_requests.UserBonusSearchRequest, limit: Limit on the number of results returned. Returns: - UserBonusSearchResult: The first "limit" user bonuses in "items". + UserBonusSearchResult: The first `limit` user bonuses in `items`. And a mark that there is more. + + Example: + >>> toloka_client.find_user_bonuses(user_id='1', sort=['-created', '-id'], limit=3) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ sort = None if sort is None else structure(sort, search_requests.UserBonusSortItems) response = self._search_request('get', '/v1/user-bonuses', request, sort, limit) @@ -2083,6 +2532,10 @@ def get_user_bonus(self, user_bonus_id: str) -> UserBonus: Returns: UserBonus: The user bonus. + + Example: + >>> toloka_client.get_user_bonus(user_bonus_id='1') + ... """ response = self._request('get', f'/v1/user-bonuses/{user_bonus_id}') return structure(response, UserBonus) @@ -2099,6 +2552,10 @@ def get_user_bonuses(self, request: search_requests.UserBonusSearchRequest) -> G Yields: UserBonus: The next object corresponding to the request parameters. + + Example: + >>> bonuses = [bonus for bonus in toloka_client.get_user_bonuses(created_lt='2021-06-01T00:00:00')] + ... """ return self._find_all(self.find_user_bonuses, request) @@ -2121,8 +2578,14 @@ def find_user_restrictions(self, request: search_requests.UserRestrictionSearchR limit: Limit on the number of results returned. Returns: - UserRestrictionSearchResult: The first "limit" user restrictions in "items". + UserRestrictionSearchResult: The first `limit` user restrictions in `items`. And a mark that there is more. + + Example: + >>> toloka_client.find_user_restrictions(sort=['-created', '-id'], limit=10) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ sort = None if sort is None else structure(sort, search_requests.UserRestrictionSortItems) response = self._search_request('get', '/v1/user-restrictions', request, sort, limit) @@ -2136,6 +2599,10 @@ def get_user_restriction(self, user_restriction_id: str) -> UserRestriction: Returns: UserRestriction: The user restriction. + + Example: + >>> toloka_client.get_user_restriction(user_restriction_id='1') + ... """ response = self._request('get', f'/v1/user-restrictions/{user_restriction_id}') return structure(response, UserRestriction) @@ -2152,6 +2619,10 @@ def get_user_restrictions(self, request: search_requests.UserRestrictionSearchRe Yields: UserRestriction: The next object corresponding to the request parameters. + + Example: + >>> results_list = [restriction for restriction in toloka_client.get_user_restrictions(scope='ALL_PROJECTS')] + ... """ return self._find_all(self.find_user_restrictions, request) @@ -2163,6 +2634,18 @@ def set_user_restriction(self, user_restriction: UserRestriction) -> UserRestric Returns: UserRestriction: Created restriction object. + + Example: + If performer often makes mistakes, we will restrict access to all our projects. + + >>> new_restriction = toloka_client.set_user_restriction( + >>> toloka.user_restriction.ProjectUserRestriction( + >>> user_id='1', + >>> private_comment='Performer often makes mistakes', + >>> project_id='5' + >>> ) + >>> ) + ... """ response = self._request('put', '/v1/user-restrictions', json=unstructure(user_restriction)) return structure(response, UserRestriction) @@ -2172,6 +2655,10 @@ def delete_user_restriction(self, user_restriction_id: str) -> None: Args: user_restriction_id: Restriction that should be removed. + + Example: + >>> toloka_client.delete_user_restriction(user_restriction_id='1') + ... """ self._raw_request('delete', f'/v1/user-restrictions/{user_restriction_id}') @@ -2182,6 +2669,21 @@ def get_requester(self) -> Requester: Returns: Requester: Object that contains all information about customer. + + Examples: + Make sure that you've entered a valid OAuth token. + + >>> toloka_client.get_requester() + ... + + You can also estimate approximate pipeline costs and check if there is enough money on your account. + + >>> requester = toloka_client.get_requester() + >>> if requester.balance >= approx_pipeline_price: + >>> print('You have enough money on your account!') + >>> else: + >>> print('You haven\'t got enough money on your account!') + ... """ response = self._request('get', '/v1/requester') return structure(response, Requester) @@ -2206,8 +2708,14 @@ def find_user_skills(self, request: search_requests.UserSkillSearchRequest, limit: Limit on the number of results returned. Returns: - UserSkillSearchResult: The first "limit" user skills in "items". + UserSkillSearchResult: The first `limit` user skills in `items`. And a mark that there is more. + + Example: + >>> toloka_client.find_user_skills(limit=10) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ sort = None if sort is None else structure(sort, search_requests.UserSkillSortItems) response = self._search_request('get', '/v1/user-skills', request, sort, limit) @@ -2223,6 +2731,10 @@ def get_user_skill(self, user_skill_id: str) -> UserSkill: Returns: UserSkill: The skill value. + + Example: + >>> toloka_client.get_user_skill(user_skill_id='1') + ... """ response = self._request('get', f'/v1/user-skills/{user_skill_id}') return structure(response, UserSkill) @@ -2240,6 +2752,10 @@ def get_user_skills(self, request: search_requests.UserSkillSearchRequest) -> Ge Yields: UserSkill: The next object corresponding to the request parameters. + + Example: + >>> results_list = [skill for skill in toloka_client.get_user_skills()] + ... """ return self._find_all(self.find_user_skills, request) @@ -2252,6 +2768,11 @@ def set_user_skill(self, request: SetUserSkillRequest) -> UserSkill: Returns: UserSkill: Сreated fact of skill installation. + + Example: + >>> from decimal import * + >>> toloka_client.set_user_skill(skill_id='1', user_id='1', value=Decimal(100)) + ... """ response = self._request('put', '/v1/user-skills', json=unstructure(request)) return structure(response, UserSkill) @@ -2263,6 +2784,10 @@ def delete_user_skill(self, user_skill_id: str) -> None: Args: user_skill_id: ID of the fact that the performer has a skill to delete. + + Example: + >>> toloka_client.delete_user_skill(user_skill_id='1') + ... """ self._raw_request('delete', f'/v1/user-skills/{user_skill_id}') @@ -2274,7 +2799,7 @@ def upsert_webhook_subscriptions(self, subscriptions: List[WebhookSubscription]) Returns: batch_create_results.WebhookSubscriptionBatchCreateResult: Result of subscriptions creation. - Contains created subscriptions in "items" and problems in "validation_errors". + Contains created subscriptions in `items` and problems in "validation_errors". Raises: ValidationApiError: If no subscriptions were created. @@ -2295,7 +2820,7 @@ def upsert_webhook_subscriptions(self, subscriptions: List[WebhookSubscription]) >>> } >>> ]) >>> print(len(created_result.items)) - 2 + ... """ response = self._request('put', '/v1/webhook-subscriptions', json=unstructure(subscriptions)) return structure(response, batch_create_results.WebhookSubscriptionBatchCreateResult) @@ -2330,7 +2855,7 @@ def find_webhook_subscriptions(self, request: search_requests.WebhookSubscriptio Defaults to None, in which case it returns first 50 results. Returns: - WebhookSubscriptionSearchResult: The first "limit" webhook-subscriptions in "items". + WebhookSubscriptionSearchResult: The first `limit` webhook-subscriptions in `items`. And a mark that there is more. """ sort = None if sort is None else structure(sort, search_requests.WebhookSubscriptionSortItems) @@ -2381,6 +2906,18 @@ def get_assignments_df(self, pool_id: str, parameters: GetAssignmentsTsvParamete * "HINT" - Hints for completing tasks. Filled in for training tasks. * "ACCEPT" - Fields describing the deferred acceptance of tasks. * "ASSIGNMENT" - fields describing additional information about the Assignment. + + Example: + Get all assignments from the specified pool by `pool_id` to [pandas.DataFrame](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html). + And apply the native pandas `rename` method to change columns' names. + + >>> answers_df = toloka_client.get_assignments_df(pool_id='1') + >>> answers_df = answers_df.rename(columns={ + >>> 'INPUT:image': 'task', + >>> 'OUTPUT:result': 'label', + >>> 'ASSIGNMENT:worker_id': 'performer' + >>> }) + ... """ logger.warning('Experimental method') response = self._raw_request('get', f'/new/requester/pools/{pool_id}/assignments.tsv', From 3a6e91569bf37031a68c33666a452e0926a37528 Mon Sep 17 00:00:00 2001 From: alexdrydew Date: Tue, 13 Jul 2021 12:15:58 +0300 Subject: [PATCH 2/8] new stubs ![review](https://codereview.in.yandex-team.ru/badges/review-complete-green.svg) [![sinosov](https://codereview.in.yandex-team.ru/badges/sinosov-ok-green.svg)](https://staff.yandex-team.ru/sinosov) ref:3bbd2f589b67543f7699455eebae0e6cfc59431b --- src/client/__init__.pyi | 1114 ++++++++++++++--- src/client/actions.pyi | 76 +- src/client/aggregation.pyi | 34 +- src/client/analytics_request.pyi | 7 +- src/client/assignment.pyi | 40 +- src/client/attachment.pyi | 30 +- src/client/batch_create_results.pyi | 36 +- src/client/collectors.pyi | 128 +- src/client/conditions.pyi | 171 ++- src/client/exceptions.pyi | 17 +- src/client/filter.pyi | 172 ++- src/client/message_thread.pyi | 59 +- src/client/operation_log.pyi | 9 +- src/client/operations.pyi | 248 +++- src/client/owner.pyi | 8 +- src/client/pool/__init__.pyi | 115 +- src/client/pool/dynamic_overlap_config.pyi | 10 +- src/client/pool/dynamic_pricing_config.pyi | 15 +- src/client/pool/mixer_config.pyi | 17 +- src/client/primitives/base.pyi | 24 +- src/client/primitives/infinite_overlap.pyi | 6 +- src/client/primitives/retry.pyi | 13 +- src/client/project/__init__.pyi | 25 +- src/client/project/field_spec.pyi | 146 ++- src/client/project/task_spec.pyi | 8 +- .../project/template_builder/__init__.pyi | 8 +- .../project/template_builder/actions.pyi | 67 +- .../project/template_builder/conditions.pyi | 106 +- src/client/project/template_builder/data.pyi | 42 +- .../project/template_builder/fields.pyi | 245 +++- .../project/template_builder/helpers.pyi | 100 +- .../project/template_builder/layouts.pyi | 51 +- .../project/template_builder/plugins.pyi | 93 +- src/client/project/template_builder/view.pyi | 211 +++- src/client/project/view_spec.pyi | 97 +- src/client/quality_control.pyi | 52 +- src/client/requester.pyi | 16 +- src/client/search_requests.pyi | 330 ++++- src/client/search_results.py | 3 +- src/client/search_results.pyi | 106 +- src/client/skill.pyi | 14 +- src/client/task.pyi | 85 +- src/client/task_distribution_function.pyi | 17 +- src/client/task_suite.pyi | 51 +- src/client/training.pyi | 32 +- src/client/user_bonus.pyi | 21 +- src/client/user_restriction.pyi | 52 +- src/client/user_skill.pyi | 20 +- src/client/webhook_subscription.pyi | 15 +- 49 files changed, 3799 insertions(+), 563 deletions(-) diff --git a/src/client/__init__.pyi b/src/client/__init__.pyi index aa70bcbb..56988022 100644 --- a/src/client/__init__.pyi +++ b/src/client/__init__.pyi @@ -216,7 +216,7 @@ class TolokaClient: * Set the timeout value to None if you're willing to wait forever. url: If you want to set a specific URL for some reason, for example, for testing. You can only set one parameter, "url" or "environment", not both. - retry_quotas: List of quotas that must be retried. By default retries only minutes quotas. + retry_quotas: List of quotas that must be retried. By default retries only minutes quotas. None or empty list for not retrying quotas. You must set this parameter to None, then you specify the 'retries' parameter as Retry instance. You can specify quotas: * MIN - Retry minutes quotas. @@ -240,9 +240,21 @@ class TolokaClient: SANDBOX = 'https://sandbox.toloka.yandex.com' PRODUCTION = 'https://toloka.yandex.com' - def __init__(self, token: str, environment: Union[Environment, str, None] = None, retries: Union[int, Retry] = 3, timeout: Union[float, Tuple[float, float]] = ..., url: Optional[str] = None, retry_quotas: Union[List[str], str, None] = ...): ... - - def accept_assignment(self, assignment_id: str, public_comment: str) -> Assignment: + def __init__( + self, + token: str, + environment: Union[Environment, str, None] = None, + retries: Union[int, Retry] = 3, + timeout: Union[float, Tuple[float, float]] = ..., + url: Optional[str] = None, + retry_quotas: Union[List[str], str, None] = 'MIN' + ): ... + + def accept_assignment( + self, + assignment_id: str, + public_comment: str + ) -> Assignment: """Marks one assignment as accepted Used then your pool created with auto_accept_solutions=False parametr. @@ -261,7 +273,11 @@ class TolokaClient: """ ... - def add_message_thread_to_folders(self, message_thread_id: str, folders: Union[List[Folder], MessageThreadFolders]) -> MessageThread: + def add_message_thread_to_folders( + self, + message_thread_id: str, + folders: Union[List[Folder], MessageThreadFolders] + ) -> MessageThread: """Adds a message chain to one or more folders ("unread", "important" etc.) Args: @@ -274,7 +290,14 @@ class TolokaClient: ... @overload - def aggregate_solutions_by_pool(self, *, type: Optional[AggregatedSolutionType] = None, pool_id: Optional[str] = None, answer_weight_skill_id: Optional[str] = None, fields: Optional[List[PoolAggregatedSolutionRequest.Field]] = None) -> AggregatedSolutionOperation: + def aggregate_solutions_by_pool( + self, + *, + type: Optional[AggregatedSolutionType] = None, + pool_id: Optional[str] = None, + answer_weight_skill_id: Optional[str] = None, + fields: Optional[List[PoolAggregatedSolutionRequest.Field]] = None + ) -> AggregatedSolutionOperation: """Starts aggregation of solutions in the pool Responses to all completed tasks will be aggregated. @@ -336,7 +359,14 @@ class TolokaClient: ... @overload - def aggregate_solutions_by_task(self, *, task_id: Optional[str] = None, pool_id: Optional[str] = None, answer_weight_skill_id: Optional[str] = None, fields: Optional[List[WeightedDynamicOverlapTaskAggregatedSolutionRequest.Field]] = None) -> AggregatedSolution: + def aggregate_solutions_by_task( + self, + *, + task_id: Optional[str] = None, + pool_id: Optional[str] = None, + answer_weight_skill_id: Optional[str] = None, + fields: Optional[List[WeightedDynamicOverlapTaskAggregatedSolutionRequest.Field]] = None + ) -> AggregatedSolution: """Starts aggregation of solutions to a single task The method only starts the aggregation and returns the operation for further tracking. @@ -501,7 +531,11 @@ class TolokaClient: """ ... - def clone_project(self, project_id: str, reuse_controllers: bool = True) -> CloneResults: + def clone_project( + self, + project_id: str, + reuse_controllers: bool = True + ) -> CloneResults: """Synchronously clones the project, all pools and trainings Emulates cloning behaviour via Toloka interface: @@ -515,7 +549,7 @@ class TolokaClient: Args: project_id: ID of the project to be cloned. - reuse_quality_controllers: Use same quality controllers in cloned and created projects. Defaults to True. + reuse_controllers: Use same quality controllers in cloned and created projects. Defaults to True. This means that all quality control rules will be applied to both projects. For example, if you have rule "fast_submitted_count", fast responses counts across both projects. @@ -611,7 +645,16 @@ class TolokaClient: ... @overload - def compose_message_thread(self, *, recipients_select_type: Optional[RecipientsSelectType] = None, topic: Optional[Dict[str, str]] = None, text: Optional[Dict[str, str]] = None, answerable: Optional[bool] = None, recipients_ids: Optional[List[str]] = None, recipients_filter: Optional[FilterCondition] = None) -> MessageThread: + def compose_message_thread( + self, + *, + recipients_select_type: Optional[RecipientsSelectType] = None, + topic: Optional[Dict[str, str]] = None, + text: Optional[Dict[str, str]] = None, + answerable: Optional[bool] = None, + recipients_ids: Optional[List[str]] = None, + recipients_filter: Optional[FilterCondition] = None + ) -> MessageThread: """Sends message to performer The sent message is added to a new message thread. @@ -701,7 +744,19 @@ class TolokaClient: ... @overload - def create_skill(self, *, name: Optional[str] = None, private_comment: Optional[str] = None, hidden: Optional[bool] = None, skill_ttl_hours: Optional[int] = None, training: Optional[bool] = None, public_name: Optional[Dict[str, str]] = None, public_requester_description: Optional[Dict[str, str]] = None, id: Optional[str] = None, created: Optional[datetime] = None) -> Skill: + def create_skill( + self, + *, + name: Optional[str] = None, + private_comment: Optional[str] = None, + hidden: Optional[bool] = None, + skill_ttl_hours: Optional[int] = None, + training: Optional[bool] = None, + public_name: Optional[Dict[str, str]] = None, + public_requester_description: Optional[Dict[str, str]] = None, + id: Optional[str] = None, + created: Optional[datetime] = None + ) -> Skill: """Creates a new Skill You can send a maximum of 10 requests of this kind per minute and 100 requests per day. @@ -755,7 +810,13 @@ class TolokaClient: ... @overload - def create_task(self, task: Task, *, allow_defaults: Optional[bool] = None, open_pool: Optional[bool] = None) -> Task: + def create_task( + self, + task: Task, + *, + allow_defaults: Optional[bool] = None, + open_pool: Optional[bool] = None + ) -> Task: """Creates a new task It's better to use "create_tasks", if you need to insert several tasks. @@ -772,7 +833,11 @@ class TolokaClient: ... @overload - def create_task(self, task: Task, parameters: Optional[CreateTaskParameters] = None) -> Task: + def create_task( + self, + task: Task, + parameters: Optional[CreateTaskParameters] = None + ) -> Task: """Creates a new task It's better to use "create_tasks", if you need to insert several tasks. @@ -789,7 +854,16 @@ class TolokaClient: ... @overload - def create_task_suite(self, task_suite: TaskSuite, *, operation_id: Optional[UUID] = None, skip_invalid_items: Optional[bool] = None, allow_defaults: Optional[bool] = None, open_pool: Optional[bool] = None, async_mode: Optional[bool] = True) -> TaskSuite: + def create_task_suite( + self, + task_suite: TaskSuite, + *, + operation_id: Optional[UUID] = None, + skip_invalid_items: Optional[bool] = None, + allow_defaults: Optional[bool] = None, + open_pool: Optional[bool] = None, + async_mode: Optional[bool] = True + ) -> TaskSuite: """Creates a new task suite Generally, you don't need to create a task set yourself, because you can create tasks and Toloka will create @@ -808,7 +882,11 @@ class TolokaClient: ... @overload - def create_task_suite(self, task_suite: TaskSuite, parameters: Optional[TaskSuiteCreateRequestParameters] = None) -> TaskSuite: + def create_task_suite( + self, + task_suite: TaskSuite, + parameters: Optional[TaskSuiteCreateRequestParameters] = None + ) -> TaskSuite: """Creates a new task suite Generally, you don't need to create a task set yourself, because you can create tasks and Toloka will create @@ -827,7 +905,16 @@ class TolokaClient: ... @overload - def create_task_suites(self, task_suites: List[TaskSuite], *, operation_id: Optional[UUID] = None, skip_invalid_items: Optional[bool] = None, allow_defaults: Optional[bool] = None, open_pool: Optional[bool] = None, async_mode: Optional[bool] = True) -> TaskSuiteBatchCreateResult: + def create_task_suites( + self, + task_suites: List[TaskSuite], + *, + operation_id: Optional[UUID] = None, + skip_invalid_items: Optional[bool] = None, + allow_defaults: Optional[bool] = None, + open_pool: Optional[bool] = None, + async_mode: Optional[bool] = True + ) -> TaskSuiteBatchCreateResult: """Creates many task suites in pools Generally, you don't need to create a task set yourself, because you can create tasks and Toloka will create @@ -855,7 +942,11 @@ class TolokaClient: ... @overload - def create_task_suites(self, task_suites: List[TaskSuite], parameters: Optional[TaskSuiteCreateRequestParameters] = None) -> TaskSuiteBatchCreateResult: + def create_task_suites( + self, + task_suites: List[TaskSuite], + parameters: Optional[TaskSuiteCreateRequestParameters] = None + ) -> TaskSuiteBatchCreateResult: """Creates many task suites in pools Generally, you don't need to create a task set yourself, because you can create tasks and Toloka will create @@ -883,7 +974,16 @@ class TolokaClient: ... @overload - def create_task_suites_async(self, task_suites: List[TaskSuite], *, operation_id: Optional[UUID] = None, skip_invalid_items: Optional[bool] = None, allow_defaults: Optional[bool] = None, open_pool: Optional[bool] = None, async_mode: Optional[bool] = True) -> TaskSuiteCreateBatchOperation: + def create_task_suites_async( + self, + task_suites: List[TaskSuite], + *, + operation_id: Optional[UUID] = None, + skip_invalid_items: Optional[bool] = None, + allow_defaults: Optional[bool] = None, + open_pool: Optional[bool] = None, + async_mode: Optional[bool] = True + ) -> TaskSuiteCreateBatchOperation: """Creates many task suites in pools, asynchronous version You can send a maximum of 100,000 requests of this kind per minute and 2,000,000 requests per day. @@ -899,7 +999,11 @@ class TolokaClient: ... @overload - def create_task_suites_async(self, task_suites: List[TaskSuite], parameters: Optional[TaskSuiteCreateRequestParameters] = None) -> TaskSuiteCreateBatchOperation: + def create_task_suites_async( + self, + task_suites: List[TaskSuite], + parameters: Optional[TaskSuiteCreateRequestParameters] = None + ) -> TaskSuiteCreateBatchOperation: """Creates many task suites in pools, asynchronous version You can send a maximum of 100,000 requests of this kind per minute and 2,000,000 requests per day. @@ -915,7 +1019,16 @@ class TolokaClient: ... @overload - def create_tasks(self, tasks: List[Task], *, allow_defaults: Optional[bool] = None, open_pool: Optional[bool] = None, skip_invalid_items: Optional[bool] = None, operation_id: Optional[UUID] = None, async_mode: Optional[bool] = True) -> TaskBatchCreateResult: + def create_tasks( + self, + tasks: List[Task], + *, + allow_defaults: Optional[bool] = None, + open_pool: Optional[bool] = None, + skip_invalid_items: Optional[bool] = None, + operation_id: Optional[UUID] = None, + async_mode: Optional[bool] = True + ) -> TaskBatchCreateResult: """Creates many tasks in pools By default uses asynchronous operation inside. It's better not to set "async_mode=False", if you not understand @@ -968,7 +1081,11 @@ class TolokaClient: ... @overload - def create_tasks(self, tasks: List[Task], parameters: Optional[CreateTasksParameters] = None) -> TaskBatchCreateResult: + def create_tasks( + self, + tasks: List[Task], + parameters: Optional[CreateTasksParameters] = None + ) -> TaskBatchCreateResult: """Creates many tasks in pools By default uses asynchronous operation inside. It's better not to set "async_mode=False", if you not understand @@ -1021,7 +1138,16 @@ class TolokaClient: ... @overload - def create_tasks_async(self, tasks: List[Task], *, allow_defaults: Optional[bool] = None, open_pool: Optional[bool] = None, skip_invalid_items: Optional[bool] = None, operation_id: Optional[UUID] = None, async_mode: Optional[bool] = True) -> TasksCreateOperation: + def create_tasks_async( + self, + tasks: List[Task], + *, + allow_defaults: Optional[bool] = None, + open_pool: Optional[bool] = None, + skip_invalid_items: Optional[bool] = None, + operation_id: Optional[UUID] = None, + async_mode: Optional[bool] = True + ) -> TasksCreateOperation: """Creates many tasks in pools, asynchronous version You can send a maximum of 100,000 requests of this kind per minute and a maximum of 2,000,000 requests per day. @@ -1037,7 +1163,11 @@ class TolokaClient: ... @overload - def create_tasks_async(self, tasks: List[Task], parameters: Optional[CreateTasksParameters] = None) -> TasksCreateOperation: + def create_tasks_async( + self, + tasks: List[Task], + parameters: Optional[CreateTasksParameters] = None + ) -> TasksCreateOperation: """Creates many tasks in pools, asynchronous version You can send a maximum of 100,000 requests of this kind per minute and a maximum of 2,000,000 requests per day. @@ -1083,7 +1213,11 @@ class TolokaClient: """ ... - def create_user_bonus(self, user_bonus: UserBonus, parameters: Optional[UserBonusCreateRequestParameters] = None) -> UserBonus: + def create_user_bonus( + self, + user_bonus: UserBonus, + parameters: Optional[UserBonusCreateRequestParameters] = None + ) -> UserBonus: """Issues payments directly to the performer You can send a maximum of 10,000 requests of this kind per day. @@ -1112,7 +1246,13 @@ class TolokaClient: ... @overload - def create_user_bonuses(self, user_bonuses: List[UserBonus], *, operation_id: Optional[str] = None, skip_invalid_items: Optional[bool] = None) -> UserBonusBatchCreateResult: + def create_user_bonuses( + self, + user_bonuses: List[UserBonus], + *, + operation_id: Optional[str] = None, + skip_invalid_items: Optional[bool] = None + ) -> UserBonusBatchCreateResult: """Creates many user bonuses Right now it's safer to use asynchronous version: "create_user_bonuses_async" @@ -1129,7 +1269,11 @@ class TolokaClient: ... @overload - def create_user_bonuses(self, user_bonuses: List[UserBonus], parameters: Optional[UserBonusCreateRequestParameters] = None) -> UserBonusBatchCreateResult: + def create_user_bonuses( + self, + user_bonuses: List[UserBonus], + parameters: Optional[UserBonusCreateRequestParameters] = None + ) -> UserBonusBatchCreateResult: """Creates many user bonuses Right now it's safer to use asynchronous version: "create_user_bonuses_async" @@ -1146,7 +1290,13 @@ class TolokaClient: ... @overload - def create_user_bonuses_async(self, user_bonuses: List[UserBonus], *, operation_id: Optional[str] = None, skip_invalid_items: Optional[bool] = None) -> UserBonusCreateBatchOperation: + def create_user_bonuses_async( + self, + user_bonuses: List[UserBonus], + *, + operation_id: Optional[str] = None, + skip_invalid_items: Optional[bool] = None + ) -> UserBonusCreateBatchOperation: """Issues payments directly to the performers, asynchronously creates many user bonuses You can send a maximum of 10,000 requests of this kind per day. @@ -1161,7 +1311,11 @@ class TolokaClient: ... @overload - def create_user_bonuses_async(self, user_bonuses: List[UserBonus], parameters: Optional[UserBonusCreateRequestParameters] = None) -> UserBonusCreateBatchOperation: + def create_user_bonuses_async( + self, + user_bonuses: List[UserBonus], + parameters: Optional[UserBonusCreateRequestParameters] = None + ) -> UserBonusCreateBatchOperation: """Issues payments directly to the performers, asynchronously creates many user bonuses You can send a maximum of 10,000 requests of this kind per day. @@ -1175,39 +1329,6 @@ class TolokaClient: """ ... - def upsert_webhook_subscriptions(self, subscriptions: List[WebhookSubscription]) -> WebhookSubscriptionBatchCreateResult: - """Creates (upsert) many webhook-subscriptions. - - Args: - subscriptions: List of webhook-subscriptions, that will be created. - - Returns: - batch_create_results.WebhookSubscriptionBatchCreateResult: Result of subscriptions creation. - Contains created subscriptions in "items" and problems in "validation_errors". - - Raises: - ValidationApiError: If no subscriptions were created. - - Example: - How to create several subscriptions. - - >>> created_result = toloka_client.upsert_webhook_subscriptions([ - >>> { - >>> 'webhook_url': 'https://awesome-requester.com/toloka-webhook', - >>> 'event_type': toloka.webhook_subscription.WebhookSubscription.EventType.ASSIGNMENT_CREATED, - >>> 'pool_id': '121212' - >>> }, - >>> { - >>> 'webhook_url': 'https://awesome-requester.com/toloka-webhook', - >>> 'event_type': toloka.webhook_subscription.WebhookSubscription.EventType.POOL_CLOSED, - >>> 'pool_id': '121212', - >>> } - >>> ]) - >>> print(len(created_result.items)) - 2 - """ - ... - def delete_user_restriction(self, user_restriction_id: str) -> None: """Unlocks existing restriction @@ -1234,7 +1355,11 @@ class TolokaClient: """ ... - def download_attachment(self, attachment_id: str, out: BinaryIO) -> None: + def download_attachment( + self, + attachment_id: str, + out: BinaryIO + ) -> None: """Downloads specific attachment Args: @@ -1251,7 +1376,16 @@ class TolokaClient: ... @overload - def find_aggregated_solutions(self, operation_id: str, task_id_lt: Optional[str] = None, task_id_lte: Optional[str] = None, task_id_gt: Optional[str] = None, task_id_gte: Optional[str] = None, sort: Union[List[str], AggregatedSolutionSortItems, None] = None, limit: Optional[int] = None) -> AggregatedSolutionSearchResult: + def find_aggregated_solutions( + self, + operation_id: str, + task_id_lt: Optional[str] = None, + task_id_lte: Optional[str] = None, + task_id_gt: Optional[str] = None, + task_id_gte: Optional[str] = None, + sort: Union[List[str], AggregatedSolutionSortItems, None] = None, + limit: Optional[int] = None + ) -> AggregatedSolutionSearchResult: """Gets aggregated responses after the AggregatedSolutionOperation completes. It is better to use the "get_aggregated_solutions" method, that allows to iterate through all results. @@ -1287,7 +1421,13 @@ class TolokaClient: ... @overload - def find_aggregated_solutions(self, operation_id: str, request: AggregatedSolutionSearchRequest, sort: Union[List[str], AggregatedSolutionSortItems, None] = None, limit: Optional[int] = None) -> AggregatedSolutionSearchResult: + def find_aggregated_solutions( + self, + operation_id: str, + request: AggregatedSolutionSearchRequest, + sort: Union[List[str], AggregatedSolutionSortItems, None] = None, + limit: Optional[int] = None + ) -> AggregatedSolutionSearchResult: """Gets aggregated responses after the AggregatedSolutionOperation completes. It is better to use the "get_aggregated_solutions" method, that allows to iterate through all results. @@ -1323,55 +1463,28 @@ class TolokaClient: ... @overload - def get_aggregated_solutions(self, operation_id: str, task_id_lt: Optional[str] = None, task_id_lte: Optional[str] = None, task_id_gt: Optional[str] = None, task_id_gte: Optional[str] = None) -> Generator[AggregatedSolution, None, None]: - """Finds all aggregated responses after the AggregatedSolutionOperation completes - - Note: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation - methods and can perform on your computers: https://github.com/Toloka/crowd-kit - - Args: - operation_id: From what aggregation operation you want to get results. - request: How to filter search results. - - Yields: - AggregatedSolution: The next object corresponding to the request parameters. - - Example: - How to get all aggregated solutions from pool. - - >>> # run toloka_client.aggregate_solutions_by_pool and wait operation for closing. - >>> aggregation_results = list(toloka_client.get_aggregated_solutions(aggregation_operation.id)) - >>> print(len(aggregation_results)) - ... - """ - ... - - @overload - def get_aggregated_solutions(self, operation_id: str, request: AggregatedSolutionSearchRequest) -> Generator[AggregatedSolution, None, None]: - """Finds all aggregated responses after the AggregatedSolutionOperation completes - - Note: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation - methods and can perform on your computers: https://github.com/Toloka/crowd-kit - - Args: - operation_id: From what aggregation operation you want to get results. - request: How to filter search results. - - Yields: - AggregatedSolution: The next object corresponding to the request parameters. - - Example: - How to get all aggregated solutions from pool. - - >>> # run toloka_client.aggregate_solutions_by_pool and wait operation for closing. - >>> aggregation_results = list(toloka_client.get_aggregated_solutions(aggregation_operation.id)) - >>> print(len(aggregation_results)) - ... - """ - ... - - @overload - def find_assignments(self, status: Union[str, Assignment.Status, List[Union[str, Assignment.Status]]] = None, task_id: Optional[str] = None, task_suite_id: Optional[str] = None, pool_id: Optional[str] = None, user_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, submitted_lt: Optional[datetime] = None, submitted_lte: Optional[datetime] = None, submitted_gt: Optional[datetime] = None, submitted_gte: Optional[datetime] = None, sort: Union[List[str], AssignmentSortItems, None] = None, limit: Optional[int] = None) -> AssignmentSearchResult: + def find_assignments( + self, + status: Union[str, Assignment.Status, List[Union[str, Assignment.Status]]] = None, + task_id: Optional[str] = None, + task_suite_id: Optional[str] = None, + pool_id: Optional[str] = None, + user_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + submitted_lt: Optional[datetime] = None, + submitted_lte: Optional[datetime] = None, + submitted_gt: Optional[datetime] = None, + submitted_gte: Optional[datetime] = None, + sort: Union[List[str], AssignmentSortItems, None] = None, + limit: Optional[int] = None + ) -> AssignmentSearchResult: """Finds all assignments that match certain rules As a result, it returns an object that contains the first part of the found assignments and whether there @@ -1391,7 +1504,12 @@ class TolokaClient: ... @overload - def find_assignments(self, request: AssignmentSearchRequest, sort: Union[List[str], AssignmentSortItems, None] = None, limit: Optional[int] = None) -> AssignmentSearchResult: + def find_assignments( + self, + request: AssignmentSearchRequest, + sort: Union[List[str], AssignmentSortItems, None] = None, + limit: Optional[int] = None + ) -> AssignmentSearchResult: """Finds all assignments that match certain rules As a result, it returns an object that contains the first part of the found assignments and whether there @@ -1411,7 +1529,26 @@ class TolokaClient: ... @overload - def find_attachments(self, name: Optional[str] = None, type: Optional[Attachment.Type] = None, user_id: Optional[str] = None, assignment_id: Optional[str] = None, pool_id: Optional[str] = None, owner_id: Optional[str] = None, owner_company_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, sort: Union[List[str], AttachmentSortItems, None] = None, limit: Optional[int] = None) -> AttachmentSearchResult: + def find_attachments( + self, + name: Optional[str] = None, + type: Optional[Attachment.Type] = None, + user_id: Optional[str] = None, + assignment_id: Optional[str] = None, + pool_id: Optional[str] = None, + owner_id: Optional[str] = None, + owner_company_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + sort: Union[List[str], AttachmentSortItems, None] = None, + limit: Optional[int] = None + ) -> AttachmentSearchResult: """Finds all attachments that match certain rules As a result, it returns an object that contains the first part of the found attachments and whether there @@ -1431,7 +1568,12 @@ class TolokaClient: ... @overload - def find_attachments(self, request: AttachmentSearchRequest, sort: Union[List[str], AttachmentSortItems, None] = None, limit: Optional[int] = None) -> AttachmentSearchResult: + def find_attachments( + self, + request: AttachmentSearchRequest, + sort: Union[List[str], AttachmentSortItems, None] = None, + limit: Optional[int] = None + ) -> AttachmentSearchResult: """Finds all attachments that match certain rules As a result, it returns an object that contains the first part of the found attachments and whether there @@ -1451,7 +1593,21 @@ class TolokaClient: ... @overload - def find_message_threads(self, folder: Union[str, Folder, List[Union[str, Folder]]] = None, folder_ne: Union[str, Folder, List[Union[str, Folder]]] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, sort: Union[List[str], MessageThreadSortItems, None] = None, limit: Optional[int] = None) -> MessageThreadSearchResult: + def find_message_threads( + self, + folder: Union[str, Folder, List[Union[str, Folder]]] = None, + folder_ne: Union[str, Folder, List[Union[str, Folder]]] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + sort: Union[List[str], MessageThreadSortItems, None] = None, + limit: Optional[int] = None + ) -> MessageThreadSearchResult: """Finds all message threads that match certain rules As a result, it returns an object that contains the first part of the found threads and whether there @@ -1472,7 +1628,12 @@ class TolokaClient: ... @overload - def find_message_threads(self, request: MessageThreadSearchRequest, sort: Union[List[str], MessageThreadSortItems, None] = None, limit: Optional[int] = None) -> MessageThreadSearchResult: + def find_message_threads( + self, + request: MessageThreadSearchRequest, + sort: Union[List[str], MessageThreadSortItems, None] = None, + limit: Optional[int] = None + ) -> MessageThreadSearchResult: """Finds all message threads that match certain rules As a result, it returns an object that contains the first part of the found threads and whether there @@ -1493,7 +1654,25 @@ class TolokaClient: ... @overload - def find_pools(self, status: Optional[Pool.Status] = None, project_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, last_started_lt: Optional[datetime] = None, last_started_lte: Optional[datetime] = None, last_started_gt: Optional[datetime] = None, last_started_gte: Optional[datetime] = None, sort: Union[List[str], PoolSortItems, None] = None, limit: Optional[int] = None) -> PoolSearchResult: + def find_pools( + self, + status: Optional[Pool.Status] = None, + project_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + last_started_lt: Optional[datetime] = None, + last_started_lte: Optional[datetime] = None, + last_started_gt: Optional[datetime] = None, + last_started_gte: Optional[datetime] = None, + sort: Union[List[str], PoolSortItems, None] = None, + limit: Optional[int] = None + ) -> PoolSearchResult: """Finds all pools that match certain rules As a result, it returns an object that contains the first part of the found pools and whether there @@ -1514,7 +1693,12 @@ class TolokaClient: ... @overload - def find_pools(self, request: PoolSearchRequest, sort: Union[List[str], PoolSortItems, None] = None, limit: Optional[int] = None) -> PoolSearchResult: + def find_pools( + self, + request: PoolSearchRequest, + sort: Union[List[str], PoolSortItems, None] = None, + limit: Optional[int] = None + ) -> PoolSearchResult: """Finds all pools that match certain rules As a result, it returns an object that contains the first part of the found pools and whether there @@ -1535,7 +1719,20 @@ class TolokaClient: ... @overload - def find_projects(self, status: Optional[Project.ProjectStatus] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, sort: Union[List[str], ProjectSortItems, None] = None, limit: Optional[int] = None) -> ProjectSearchResult: + def find_projects( + self, + status: Optional[Project.ProjectStatus] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + sort: Union[List[str], ProjectSortItems, None] = None, + limit: Optional[int] = None + ) -> ProjectSearchResult: """Finds all projects that match certain rules As a result, it returns an object that contains the first part of the found projects and whether there @@ -1556,7 +1753,12 @@ class TolokaClient: ... @overload - def find_projects(self, request: ProjectSearchRequest, sort: Union[List[str], ProjectSortItems, None] = None, limit: Optional[int] = None) -> ProjectSearchResult: + def find_projects( + self, + request: ProjectSearchRequest, + sort: Union[List[str], ProjectSortItems, None] = None, + limit: Optional[int] = None + ) -> ProjectSearchResult: """Finds all projects that match certain rules As a result, it returns an object that contains the first part of the found projects and whether there @@ -1577,7 +1779,20 @@ class TolokaClient: ... @overload - def find_skills(self, name: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, sort: Union[List[str], SkillSortItems, None] = None, limit: Optional[int] = None) -> SkillSearchResult: + def find_skills( + self, + name: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + sort: Union[List[str], SkillSortItems, None] = None, + limit: Optional[int] = None + ) -> SkillSearchResult: """Finds all skills that match certain rules As a result, it returns an object that contains the first part of the found skills and whether there @@ -1597,7 +1812,12 @@ class TolokaClient: ... @overload - def find_skills(self, request: SkillSearchRequest, sort: Union[List[str], SkillSortItems, None] = None, limit: Optional[int] = None) -> SkillSearchResult: + def find_skills( + self, + request: SkillSearchRequest, + sort: Union[List[str], SkillSortItems, None] = None, + limit: Optional[int] = None + ) -> SkillSearchResult: """Finds all skills that match certain rules As a result, it returns an object that contains the first part of the found skills and whether there @@ -1617,7 +1837,26 @@ class TolokaClient: ... @overload - def find_task_suites(self, task_id: Optional[str] = None, pool_id: Optional[str] = None, overlap: Optional[int] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, overlap_lt: Optional[int] = None, overlap_lte: Optional[int] = None, overlap_gt: Optional[int] = None, overlap_gte: Optional[int] = None, sort: Union[List[str], TaskSuiteSortItems, None] = None, limit: Optional[int] = None) -> TaskSuiteSearchResult: + def find_task_suites( + self, + task_id: Optional[str] = None, + pool_id: Optional[str] = None, + overlap: Optional[int] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + overlap_lt: Optional[int] = None, + overlap_lte: Optional[int] = None, + overlap_gt: Optional[int] = None, + overlap_gte: Optional[int] = None, + sort: Union[List[str], TaskSuiteSortItems, None] = None, + limit: Optional[int] = None + ) -> TaskSuiteSearchResult: """Finds all task suites that match certain rules As a result, it returns an object that contains the first part of the found task suites and whether there @@ -1637,7 +1876,12 @@ class TolokaClient: ... @overload - def find_task_suites(self, request: TaskSuiteSearchRequest, sort: Union[List[str], TaskSuiteSortItems, None] = None, limit: Optional[int] = None) -> TaskSuiteSearchResult: + def find_task_suites( + self, + request: TaskSuiteSearchRequest, + sort: Union[List[str], TaskSuiteSortItems, None] = None, + limit: Optional[int] = None + ) -> TaskSuiteSearchResult: """Finds all task suites that match certain rules As a result, it returns an object that contains the first part of the found task suites and whether there @@ -1657,7 +1901,25 @@ class TolokaClient: ... @overload - def find_tasks(self, pool_id: Optional[str] = None, overlap: Optional[int] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, overlap_lt: Optional[int] = None, overlap_lte: Optional[int] = None, overlap_gt: Optional[int] = None, overlap_gte: Optional[int] = None, sort: Union[List[str], TaskSortItems, None] = None, limit: Optional[int] = None) -> TaskSearchResult: + def find_tasks( + self, + pool_id: Optional[str] = None, + overlap: Optional[int] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + overlap_lt: Optional[int] = None, + overlap_lte: Optional[int] = None, + overlap_gt: Optional[int] = None, + overlap_gte: Optional[int] = None, + sort: Union[List[str], TaskSortItems, None] = None, + limit: Optional[int] = None + ) -> TaskSearchResult: """Finds all tasks that match certain rules As a result, it returns an object that contains the first part of the found tasks and whether there @@ -1677,7 +1939,12 @@ class TolokaClient: ... @overload - def find_tasks(self, request: TaskSearchRequest, sort: Union[List[str], TaskSortItems, None] = None, limit: Optional[int] = None) -> TaskSearchResult: + def find_tasks( + self, + request: TaskSearchRequest, + sort: Union[List[str], TaskSortItems, None] = None, + limit: Optional[int] = None + ) -> TaskSearchResult: """Finds all tasks that match certain rules As a result, it returns an object that contains the first part of the found tasks and whether there @@ -1697,7 +1964,25 @@ class TolokaClient: ... @overload - def find_trainings(self, status: Optional[Training.Status] = None, project_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, last_started_lt: Optional[datetime] = None, last_started_lte: Optional[datetime] = None, last_started_gt: Optional[datetime] = None, last_started_gte: Optional[datetime] = None, sort: Union[List[str], TrainingSortItems, None] = None, limit: Optional[int] = None) -> TrainingSearchResult: + def find_trainings( + self, + status: Optional[Training.Status] = None, + project_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + last_started_lt: Optional[datetime] = None, + last_started_lte: Optional[datetime] = None, + last_started_gt: Optional[datetime] = None, + last_started_gte: Optional[datetime] = None, + sort: Union[List[str], TrainingSortItems, None] = None, + limit: Optional[int] = None + ) -> TrainingSearchResult: """Finds all trainings that match certain rules As a result, it returns an object that contains the first part of the found trainings and whether there @@ -1717,7 +2002,12 @@ class TolokaClient: ... @overload - def find_trainings(self, request: TrainingSearchRequest, sort: Union[List[str], TrainingSortItems, None] = None, limit: Optional[int] = None) -> TrainingSearchResult: + def find_trainings( + self, + request: TrainingSearchRequest, + sort: Union[List[str], TrainingSortItems, None] = None, + limit: Optional[int] = None + ) -> TrainingSearchResult: """Finds all trainings that match certain rules As a result, it returns an object that contains the first part of the found trainings and whether there @@ -1737,7 +2027,21 @@ class TolokaClient: ... @overload - def find_user_bonuses(self, user_id: Optional[str] = None, private_comment: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, sort: Union[List[str], UserBonusSortItems, None] = None, limit: Optional[int] = None) -> UserBonusSearchResult: + def find_user_bonuses( + self, + user_id: Optional[str] = None, + private_comment: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + sort: Union[List[str], UserBonusSortItems, None] = None, + limit: Optional[int] = None + ) -> UserBonusSearchResult: """Finds all user bonuses that match certain rules As a result, it returns an object that contains the first part of the found user bonuses and whether there @@ -1757,7 +2061,12 @@ class TolokaClient: ... @overload - def find_user_bonuses(self, request: UserBonusSearchRequest, sort: Union[List[str], UserBonusSortItems, None] = None, limit: Optional[int] = None) -> UserBonusSearchResult: + def find_user_bonuses( + self, + request: UserBonusSearchRequest, + sort: Union[List[str], UserBonusSortItems, None] = None, + limit: Optional[int] = None + ) -> UserBonusSearchResult: """Finds all user bonuses that match certain rules As a result, it returns an object that contains the first part of the found user bonuses and whether there @@ -1777,7 +2086,23 @@ class TolokaClient: ... @overload - def find_user_restrictions(self, scope: Optional[UserRestriction.Scope] = None, user_id: Optional[str] = None, project_id: Optional[str] = None, pool_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, sort: Union[List[str], UserRestrictionSortItems, None] = None, limit: Optional[int] = None) -> UserRestrictionSearchResult: + def find_user_restrictions( + self, + scope: Optional[UserRestriction.Scope] = None, + user_id: Optional[str] = None, + project_id: Optional[str] = None, + pool_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + sort: Union[List[str], UserRestrictionSortItems, None] = None, + limit: Optional[int] = None + ) -> UserRestrictionSearchResult: """Finds all user restrictions that match certain rules As a result, it returns an object that contains the first part of the found user restrictions and whether there @@ -1797,7 +2122,12 @@ class TolokaClient: ... @overload - def find_user_restrictions(self, request: UserRestrictionSearchRequest, sort: Union[List[str], UserRestrictionSortItems, None] = None, limit: Optional[int] = None) -> UserRestrictionSearchResult: + def find_user_restrictions( + self, + request: UserRestrictionSearchRequest, + sort: Union[List[str], UserRestrictionSortItems, None] = None, + limit: Optional[int] = None + ) -> UserRestrictionSearchResult: """Finds all user restrictions that match certain rules As a result, it returns an object that contains the first part of the found user restrictions and whether there @@ -1817,7 +2147,26 @@ class TolokaClient: ... @overload - def find_user_skills(self, name: Optional[str] = None, user_id: Optional[str] = None, skill_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, modified_lt: Optional[datetime] = None, modified_lte: Optional[datetime] = None, modified_gt: Optional[datetime] = None, modified_gte: Optional[datetime] = None, sort: Union[List[str], UserSkillSortItems, None] = None, limit: Optional[int] = None) -> UserSkillSearchResult: + def find_user_skills( + self, + name: Optional[str] = None, + user_id: Optional[str] = None, + skill_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + modified_lt: Optional[datetime] = None, + modified_lte: Optional[datetime] = None, + modified_gt: Optional[datetime] = None, + modified_gte: Optional[datetime] = None, + sort: Union[List[str], UserSkillSortItems, None] = None, + limit: Optional[int] = None + ) -> UserSkillSearchResult: """Finds all user skills that match certain rules UserSkill describe the skill value for a specific performer. @@ -1838,7 +2187,12 @@ class TolokaClient: ... @overload - def find_user_skills(self, request: UserSkillSearchRequest, sort: Union[List[str], UserSkillSortItems, None] = None, limit: Optional[int] = None) -> UserSkillSearchResult: + def find_user_skills( + self, + request: UserSkillSearchRequest, + sort: Union[List[str], UserSkillSortItems, None] = None, + limit: Optional[int] = None + ) -> UserSkillSearchResult: """Finds all user skills that match certain rules UserSkill describe the skill value for a specific performer. @@ -1859,7 +2213,21 @@ class TolokaClient: ... @overload - def find_webhook_subscriptions(self, event_type: Optional[WebhookSubscription.EventType] = None, pool_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, sort: Union[List[str], WebhookSubscriptionSortItems, None] = None, limit: Optional[int] = None) -> WebhookSubscriptionSearchResult: + def find_webhook_subscriptions( + self, + event_type: Optional[WebhookSubscription.EventType] = None, + pool_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + sort: Union[List[str], WebhookSubscriptionSortItems, None] = None, + limit: Optional[int] = None + ) -> WebhookSubscriptionSearchResult: """Finds all webhook-subscriptions that match certain rules As a result, it returns an object that contains the first part of the found webhook-subscriptions @@ -1880,7 +2248,12 @@ class TolokaClient: ... @overload - def find_webhook_subscriptions(self, request: WebhookSubscriptionSearchRequest, sort: Union[List[str], WebhookSubscriptionSortItems, None] = None, limit: Optional[int] = None) -> WebhookSubscriptionSearchResult: + def find_webhook_subscriptions( + self, + request: WebhookSubscriptionSearchRequest, + sort: Union[List[str], WebhookSubscriptionSortItems, None] = None, + limit: Optional[int] = None + ) -> WebhookSubscriptionSearchResult: """Finds all webhook-subscriptions that match certain rules As a result, it returns an object that contains the first part of the found webhook-subscriptions @@ -1900,6 +2273,65 @@ class TolokaClient: """ ... + @overload + def get_aggregated_solutions( + self, + operation_id: str, + task_id_lt: Optional[str] = None, + task_id_lte: Optional[str] = None, + task_id_gt: Optional[str] = None, + task_id_gte: Optional[str] = None + ) -> Generator[AggregatedSolution, None, None]: + """Finds all aggregated responses after the AggregatedSolutionOperation completes + + Note: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation + methods and can perform on your computers: https://github.com/Toloka/crowd-kit + + Args: + operation_id: From what aggregation operation you want to get results. + request: How to filter search results. + + Yields: + AggregatedSolution: The next object corresponding to the request parameters. + + Example: + How to get all aggregated solutions from pool. + + >>> # run toloka_client.aggregate_solutions_by_pool and wait operation for closing. + >>> aggregation_results = list(toloka_client.get_aggregated_solutions(aggregation_operation.id)) + >>> print(len(aggregation_results)) + ... + """ + ... + + @overload + def get_aggregated_solutions( + self, + operation_id: str, + request: AggregatedSolutionSearchRequest + ) -> Generator[AggregatedSolution, None, None]: + """Finds all aggregated responses after the AggregatedSolutionOperation completes + + Note: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation + methods and can perform on your computers: https://github.com/Toloka/crowd-kit + + Args: + operation_id: From what aggregation operation you want to get results. + request: How to filter search results. + + Yields: + AggregatedSolution: The next object corresponding to the request parameters. + + Example: + How to get all aggregated solutions from pool. + + >>> # run toloka_client.aggregate_solutions_by_pool and wait operation for closing. + >>> aggregation_results = list(toloka_client.get_aggregated_solutions(aggregation_operation.id)) + >>> print(len(aggregation_results)) + ... + """ + ... + def get_analytics(self, stats: List[AnalyticsRequest]) -> Operation: """Sends analytics queries, for example, to estimate the percentage of completed tasks in the pool @@ -1937,7 +2369,26 @@ class TolokaClient: ... @overload - def get_assignments(self, status: Union[str, Assignment.Status, List[Union[str, Assignment.Status]]] = None, task_id: Optional[str] = None, task_suite_id: Optional[str] = None, pool_id: Optional[str] = None, user_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, submitted_lt: Optional[datetime] = None, submitted_lte: Optional[datetime] = None, submitted_gt: Optional[datetime] = None, submitted_gte: Optional[datetime] = None) -> Generator[Assignment, None, None]: + def get_assignments( + self, + status: Union[str, Assignment.Status, List[Union[str, Assignment.Status]]] = None, + task_id: Optional[str] = None, + task_suite_id: Optional[str] = None, + pool_id: Optional[str] = None, + user_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + submitted_lt: Optional[datetime] = None, + submitted_lte: Optional[datetime] = None, + submitted_gt: Optional[datetime] = None, + submitted_gte: Optional[datetime] = None + ) -> Generator[Assignment, None, None]: """Finds all assignments that match certain rules and returns them in an iterable object Unlike find_assignments, returns generator. Does not sort assignments. @@ -1981,7 +2432,16 @@ class TolokaClient: ... @overload - def get_assignments_df(self, pool_id: str, *, status: Optional[List[GetAssignmentsTsvParameters.Status]] = ..., start_time_from: Optional[datetime] = None, start_time_to: Optional[datetime] = None, exclude_banned: Optional[bool] = None, field: Optional[List[GetAssignmentsTsvParameters.Field]] = ...) -> DataFrame: + def get_assignments_df( + self, + pool_id: str, + *, + status: Optional[List[GetAssignmentsTsvParameters.Status]] = ..., + start_time_from: Optional[datetime] = None, + start_time_to: Optional[datetime] = None, + exclude_banned: Optional[bool] = None, + field: Optional[List[GetAssignmentsTsvParameters.Field]] = ... + ) -> DataFrame: """Downloads assignments as pandas.DataFrame Experimental method. @@ -2003,7 +2463,11 @@ class TolokaClient: ... @overload - def get_assignments_df(self, pool_id: str, parameters: GetAssignmentsTsvParameters) -> DataFrame: + def get_assignments_df( + self, + pool_id: str, + parameters: GetAssignmentsTsvParameters + ) -> DataFrame: """Downloads assignments as pandas.DataFrame Experimental method. @@ -2038,7 +2502,24 @@ class TolokaClient: ... @overload - def get_attachments(self, name: Optional[str] = None, type: Optional[Attachment.Type] = None, user_id: Optional[str] = None, assignment_id: Optional[str] = None, pool_id: Optional[str] = None, owner_id: Optional[str] = None, owner_company_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> Generator[Attachment, None, None]: + def get_attachments( + self, + name: Optional[str] = None, + type: Optional[Attachment.Type] = None, + user_id: Optional[str] = None, + assignment_id: Optional[str] = None, + pool_id: Optional[str] = None, + owner_id: Optional[str] = None, + owner_company_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None + ) -> Generator[Attachment, None, None]: """Finds all attachments that match certain rules and returns their metadata in an iterable object Unlike find_attachments, returns generator. Does not sort attachments. @@ -2068,7 +2549,19 @@ class TolokaClient: ... @overload - def get_message_threads(self, folder: Union[str, Folder, List[Union[str, Folder]]] = None, folder_ne: Union[str, Folder, List[Union[str, Folder]]] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> Generator[MessageThread, None, None]: + def get_message_threads( + self, + folder: Union[str, Folder, List[Union[str, Folder]]] = None, + folder_ne: Union[str, Folder, List[Union[str, Folder]]] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None + ) -> Generator[MessageThread, None, None]: """Finds all message threads that match certain rules and returns them in an iterable object Unlike find_message_threads, returns generator. Does not sort threads. @@ -2150,7 +2643,23 @@ class TolokaClient: ... @overload - def get_pools(self, status: Optional[Pool.Status] = None, project_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, last_started_lt: Optional[datetime] = None, last_started_lte: Optional[datetime] = None, last_started_gt: Optional[datetime] = None, last_started_gte: Optional[datetime] = None) -> Generator[Pool, None, None]: + def get_pools( + self, + status: Optional[Pool.Status] = None, + project_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + last_started_lt: Optional[datetime] = None, + last_started_lte: Optional[datetime] = None, + last_started_gt: Optional[datetime] = None, + last_started_gte: Optional[datetime] = None + ) -> Generator[Pool, None, None]: """Finds all pools that match certain rules and returns them in an iterable object Unlike find_pools, returns generator. Does not sort pools. @@ -2213,7 +2722,18 @@ class TolokaClient: ... @overload - def get_projects(self, status: Optional[Project.ProjectStatus] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> Generator[Project, None, None]: + def get_projects( + self, + status: Optional[Project.ProjectStatus] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None + ) -> Generator[Project, None, None]: """Finds all projects that match certain rules and returns them in an iterable object Unlike find_projects, returns generator. Does not sort projects. @@ -2284,7 +2804,18 @@ class TolokaClient: ... @overload - def get_skills(self, name: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> Generator[Skill, None, None]: + def get_skills( + self, + name: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None + ) -> Generator[Skill, None, None]: """Finds all skills that match certain rules and returns them in an iterable object Unlike find_skills, returns generator. Does not sort skills. @@ -2356,7 +2887,24 @@ class TolokaClient: ... @overload - def get_task_suites(self, task_id: Optional[str] = None, pool_id: Optional[str] = None, overlap: Optional[int] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, overlap_lt: Optional[int] = None, overlap_lte: Optional[int] = None, overlap_gt: Optional[int] = None, overlap_gte: Optional[int] = None) -> Generator[TaskSuite, None, None]: + def get_task_suites( + self, + task_id: Optional[str] = None, + pool_id: Optional[str] = None, + overlap: Optional[int] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + overlap_lt: Optional[int] = None, + overlap_lte: Optional[int] = None, + overlap_gt: Optional[int] = None, + overlap_gte: Optional[int] = None + ) -> Generator[TaskSuite, None, None]: """Finds all task suites that match certain rules and returns them in an iterable object Unlike find_task_suites, returns generator. Does not sort task suites. @@ -2386,7 +2934,23 @@ class TolokaClient: ... @overload - def get_tasks(self, pool_id: Optional[str] = None, overlap: Optional[int] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, overlap_lt: Optional[int] = None, overlap_lte: Optional[int] = None, overlap_gt: Optional[int] = None, overlap_gte: Optional[int] = None) -> Generator[Task, None, None]: + def get_tasks( + self, + pool_id: Optional[str] = None, + overlap: Optional[int] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + overlap_lt: Optional[int] = None, + overlap_lte: Optional[int] = None, + overlap_gt: Optional[int] = None, + overlap_gte: Optional[int] = None + ) -> Generator[Task, None, None]: """Finds all tasks that match certain rules and returns them in an iterable object Unlike find_tasks, returns generator. Does not sort tasks. @@ -2427,7 +2991,23 @@ class TolokaClient: ... @overload - def get_trainings(self, status: Optional[Training.Status] = None, project_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, last_started_lt: Optional[datetime] = None, last_started_lte: Optional[datetime] = None, last_started_gt: Optional[datetime] = None, last_started_gte: Optional[datetime] = None) -> Generator[Training, None, None]: + def get_trainings( + self, + status: Optional[Training.Status] = None, + project_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + last_started_lt: Optional[datetime] = None, + last_started_lte: Optional[datetime] = None, + last_started_gt: Optional[datetime] = None, + last_started_gte: Optional[datetime] = None + ) -> Generator[Training, None, None]: """Finds all trainings that match certain rules and returns them in an iterable object Unlike find_trainings, returns generator. Does not sort trainings. @@ -2480,7 +3060,19 @@ class TolokaClient: ... @overload - def get_user_bonuses(self, user_id: Optional[str] = None, private_comment: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> Generator[UserBonus, None, None]: + def get_user_bonuses( + self, + user_id: Optional[str] = None, + private_comment: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None + ) -> Generator[UserBonus, None, None]: """Finds all user bonuses that match certain rules and returns them in an iterable object Unlike find_user_bonuses, returns generator. Does not sort user bonuses. @@ -2521,7 +3113,21 @@ class TolokaClient: ... @overload - def get_user_restrictions(self, scope: Optional[UserRestriction.Scope] = None, user_id: Optional[str] = None, project_id: Optional[str] = None, pool_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> Generator[UserRestriction, None, None]: + def get_user_restrictions( + self, + scope: Optional[UserRestriction.Scope] = None, + user_id: Optional[str] = None, + project_id: Optional[str] = None, + pool_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None + ) -> Generator[UserRestriction, None, None]: """Finds all user restrictions that match certain rules and returns them in an iterable object Unlike find_user_restrictions, returns generator. Does not sort user restrictions. @@ -2564,7 +3170,24 @@ class TolokaClient: ... @overload - def get_user_skills(self, name: Optional[str] = None, user_id: Optional[str] = None, skill_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, modified_lt: Optional[datetime] = None, modified_lte: Optional[datetime] = None, modified_gt: Optional[datetime] = None, modified_gte: Optional[datetime] = None) -> Generator[UserSkill, None, None]: + def get_user_skills( + self, + name: Optional[str] = None, + user_id: Optional[str] = None, + skill_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + modified_lt: Optional[datetime] = None, + modified_lte: Optional[datetime] = None, + modified_gt: Optional[datetime] = None, + modified_gte: Optional[datetime] = None + ) -> Generator[UserSkill, None, None]: """Finds all user skills that match certain rules and returns them in an iterable object UserSkill describe the skill value for a specific performer. @@ -2607,7 +3230,19 @@ class TolokaClient: ... @overload - def get_webhook_subscriptions(self, event_type: Optional[WebhookSubscription.EventType] = None, pool_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> Generator[WebhookSubscription, None, None]: + def get_webhook_subscriptions( + self, + event_type: Optional[WebhookSubscription.EventType] = None, + pool_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None + ) -> Generator[WebhookSubscription, None, None]: """Finds all webhook-subscriptions that match certain rules and returns them in an iterable object Unlike find_webhook-subscriptions, returns generator. Does not sort webhook-subscriptions. @@ -2685,7 +3320,13 @@ class TolokaClient: ... @overload - def patch_assignment(self, assignment_id: str, *, public_comment: Optional[str] = None, status: Optional[Assignment.Status] = None) -> Assignment: + def patch_assignment( + self, + assignment_id: str, + *, + public_comment: Optional[str] = None, + status: Optional[Assignment.Status] = None + ) -> Assignment: """Changes status and comment on assignment It's better to use methods "reject_assignment" and "accept_assignment". @@ -2700,7 +3341,11 @@ class TolokaClient: ... @overload - def patch_assignment(self, assignment_id: str, patch: AssignmentPatch) -> Assignment: + def patch_assignment( + self, + assignment_id: str, + patch: AssignmentPatch + ) -> Assignment: """Changes status and comment on assignment It's better to use methods "reject_assignment" and "accept_assignment". @@ -2715,7 +3360,11 @@ class TolokaClient: ... @overload - def patch_pool(self, pool_id: str, priority: Optional[int] = None) -> Pool: + def patch_pool( + self, + pool_id: str, + priority: Optional[int] = None + ) -> Pool: """Changes the priority of the pool issue Args: @@ -2736,7 +3385,11 @@ class TolokaClient: ... @overload - def patch_pool(self, pool_id: str, request: PoolPatchRequest) -> Pool: + def patch_pool( + self, + pool_id: str, + request: PoolPatchRequest + ) -> Pool: """Changes the priority of the pool issue Args: @@ -2757,7 +3410,14 @@ class TolokaClient: ... @overload - def patch_task(self, task_id: str, *, overlap: Optional[int] = None, infinite_overlap: Optional[bool] = None, baseline_solutions: Optional[List[Task.BaselineSolution]] = None) -> Task: + def patch_task( + self, + task_id: str, + *, + overlap: Optional[int] = None, + infinite_overlap: Optional[bool] = None, + baseline_solutions: Optional[List[Task.BaselineSolution]] = None + ) -> Task: """Changes the task overlap Args: @@ -2770,7 +3430,11 @@ class TolokaClient: ... @overload - def patch_task(self, task_id: str, patch: TaskPatch) -> Task: + def patch_task( + self, + task_id: str, + patch: TaskPatch + ) -> Task: """Changes the task overlap Args: @@ -2783,7 +3447,13 @@ class TolokaClient: ... @overload - def patch_task_overlap_or_min(self, task_id: str, *, overlap: Optional[int] = None, infinite_overlap: Optional[bool] = None) -> Task: + def patch_task_overlap_or_min( + self, + task_id: str, + *, + overlap: Optional[int] = None, + infinite_overlap: Optional[bool] = None + ) -> Task: """Stops issuing the task Args: @@ -2796,7 +3466,11 @@ class TolokaClient: ... @overload - def patch_task_overlap_or_min(self, task_id: str, patch: TaskOverlapPatch) -> Task: + def patch_task_overlap_or_min( + self, + task_id: str, + patch: TaskOverlapPatch + ) -> Task: """Stops issuing the task Args: @@ -2809,7 +3483,15 @@ class TolokaClient: ... @overload - def patch_task_suite(self, task_suite_id: str, *, infinite_overlap=None, overlap=None, issuing_order_override: Optional[float] = None, open_pool: Optional[bool] = None) -> TaskSuite: + def patch_task_suite( + self, + task_suite_id: str, + *, + infinite_overlap=None, + overlap=None, + issuing_order_override: Optional[float] = None, + open_pool: Optional[bool] = None + ) -> TaskSuite: """Changes the task suite overlap or priority Args: @@ -2822,7 +3504,11 @@ class TolokaClient: ... @overload - def patch_task_suite(self, task_suite_id: str, patch: TaskSuitePatch) -> TaskSuite: + def patch_task_suite( + self, + task_suite_id: str, + patch: TaskSuitePatch + ) -> TaskSuite: """Changes the task suite overlap or priority Args: @@ -2835,7 +3521,12 @@ class TolokaClient: ... @overload - def patch_task_suite_overlap_or_min(self, task_suite_id: str, *, overlap: Optional[int] = None) -> TaskSuite: + def patch_task_suite_overlap_or_min( + self, + task_suite_id: str, + *, + overlap: Optional[int] = None + ) -> TaskSuite: """Stops issuing the task suites Args: @@ -2848,7 +3539,11 @@ class TolokaClient: ... @overload - def patch_task_suite_overlap_or_min(self, task_suite_id: str, patch: TaskSuiteOverlapPatch) -> TaskSuite: + def patch_task_suite_overlap_or_min( + self, + task_suite_id: str, + patch: TaskSuiteOverlapPatch + ) -> TaskSuite: """Stops issuing the task suites Args: @@ -2860,7 +3555,11 @@ class TolokaClient: """ ... - def reject_assignment(self, assignment_id: str, public_comment: str) -> Assignment: + def reject_assignment( + self, + assignment_id: str, + public_comment: str + ) -> Assignment: """Marks one assignment as rejected Used then your pool created with auto_accept_solutions=False parametr. @@ -2879,7 +3578,11 @@ class TolokaClient: """ ... - def remove_message_thread_from_folders(self, message_thread_id: str, folders: Union[List[Folder], MessageThreadFolders]) -> MessageThread: + def remove_message_thread_from_folders( + self, + message_thread_id: str, + folders: Union[List[Folder], MessageThreadFolders] + ) -> MessageThread: """Deletes a message chain from one or more folders ("unread", "important" etc.) Args: @@ -2891,7 +3594,11 @@ class TolokaClient: """ ... - def reply_message_thread(self, message_thread_id: str, reply: MessageThreadReply) -> MessageThread: + def reply_message_thread( + self, + message_thread_id: str, + reply: MessageThreadReply + ) -> MessageThread: """Replies to a message in thread Args: @@ -2915,7 +3622,13 @@ class TolokaClient: ... @overload - def set_user_skill(self, *, skill_id: Optional[str] = None, user_id: Optional[str] = None, value: Optional[Decimal] = None) -> UserSkill: + def set_user_skill( + self, + *, + skill_id: Optional[str] = None, + user_id: Optional[str] = None, + value: Optional[Decimal] = None + ) -> UserSkill: """Sets the skill value to the performer Args: @@ -2938,7 +3651,11 @@ class TolokaClient: """ ... - def update_pool(self, pool_id: str, pool: Pool) -> Pool: + def update_pool( + self, + pool_id: str, + pool: Pool + ) -> Pool: """Makes changes to the pool Args: @@ -2950,7 +3667,11 @@ class TolokaClient: """ ... - def update_project(self, project_id: str, project: Project) -> Project: + def update_project( + self, + project_id: str, + project: Project + ) -> Project: """Makes changes to the project Args: @@ -2962,7 +3683,11 @@ class TolokaClient: """ ... - def update_skill(self, skill_id: str, skill: Skill) -> Skill: + def update_skill( + self, + skill_id: str, + skill: Skill + ) -> Skill: """Makes changes to the skill Args: @@ -2974,7 +3699,11 @@ class TolokaClient: """ ... - def update_training(self, training_id: str, training: Training) -> Training: + def update_training( + self, + training_id: str, + training: Training + ) -> Training: """Makes changes to the training Args: @@ -2986,7 +3715,44 @@ class TolokaClient: """ ... - def wait_operation(self, op: Operation, timeout: timedelta = ...) -> Operation: + def upsert_webhook_subscriptions(self, subscriptions: List[WebhookSubscription]) -> WebhookSubscriptionBatchCreateResult: + """Creates (upsert) many webhook-subscriptions. + + Args: + subscriptions: List of webhook-subscriptions, that will be created. + + Returns: + batch_create_results.WebhookSubscriptionBatchCreateResult: Result of subscriptions creation. + Contains created subscriptions in "items" and problems in "validation_errors". + + Raises: + ValidationApiError: If no subscriptions were created. + + Example: + How to create several subscriptions. + + >>> created_result = toloka_client.upsert_webhook_subscriptions([ + >>> { + >>> 'webhook_url': 'https://awesome-requester.com/toloka-webhook', + >>> 'event_type': toloka.webhook_subscription.WebhookSubscription.EventType.ASSIGNMENT_CREATED, + >>> 'pool_id': '121212' + >>> }, + >>> { + >>> 'webhook_url': 'https://awesome-requester.com/toloka-webhook', + >>> 'event_type': toloka.webhook_subscription.WebhookSubscription.EventType.POOL_CLOSED, + >>> 'pool_id': '121212', + >>> } + >>> ]) + >>> print(len(created_result.items)) + 2 + """ + ... + + def wait_operation( + self, + op: Operation, + timeout: timedelta = ... + ) -> Operation: """Waits for the operation to complete, and return it Args: diff --git a/src/client/actions.pyi b/src/client/actions.pyi index cfafac89..408ffca0 100644 --- a/src/client/actions.pyi +++ b/src/client/actions.pyi @@ -60,7 +60,13 @@ class Restriction(RuleAction): """ class Parameters(BaseParameters.Parameters): - def __init__(self, *, scope: Optional[UserRestriction.Scope] = None, duration_days: Optional[int] = None, private_comment: Optional[str] = None) -> None: + def __init__( + self, + *, + scope: Optional[UserRestriction.Scope] = None, + duration_days: Optional[int] = None, + private_comment: Optional[str] = None + ) -> None: """Method generated by attrs for class Restriction.Parameters. """ ... @@ -71,7 +77,13 @@ class Restriction(RuleAction): private_comment: Optional[str] @overload - def __init__(self, *, scope: Optional[UserRestriction.Scope] = None, duration_days: Optional[int] = None, private_comment: Optional[str] = None) -> None: + def __init__( + self, + *, + scope: Optional[UserRestriction.Scope] = None, + duration_days: Optional[int] = None, + private_comment: Optional[str] = None + ) -> None: """Method generated by attrs for class Restriction. """ ... @@ -120,7 +132,14 @@ class RestrictionV2(RuleAction): """ class Parameters(BaseParameters.Parameters): - def __init__(self, *, scope: Optional[UserRestriction.Scope] = None, duration: Optional[int] = None, duration_unit: Optional[DurationUnit] = None, private_comment: Optional[str] = None) -> None: + def __init__( + self, + *, + scope: Optional[UserRestriction.Scope] = None, + duration: Optional[int] = None, + duration_unit: Optional[DurationUnit] = None, + private_comment: Optional[str] = None + ) -> None: """Method generated by attrs for class RestrictionV2.Parameters. """ ... @@ -132,7 +151,14 @@ class RestrictionV2(RuleAction): private_comment: Optional[str] @overload - def __init__(self, *, scope: Optional[UserRestriction.Scope] = None, duration: Optional[int] = None, duration_unit: Optional[DurationUnit] = None, private_comment: Optional[str] = None) -> None: + def __init__( + self, + *, + scope: Optional[UserRestriction.Scope] = None, + duration: Optional[int] = None, + duration_unit: Optional[DurationUnit] = None, + private_comment: Optional[str] = None + ) -> None: """Method generated by attrs for class RestrictionV2. """ ... @@ -176,7 +202,12 @@ class SetSkillFromOutputField(RuleAction): """ class Parameters(BaseParameters.Parameters): - def __init__(self, *, skill_id: Optional[str] = None, from_field: Optional[RuleConditionKey] = None) -> None: + def __init__( + self, + *, + skill_id: Optional[str] = None, + from_field: Optional[RuleConditionKey] = None + ) -> None: """Method generated by attrs for class SetSkillFromOutputField.Parameters. """ ... @@ -186,7 +217,12 @@ class SetSkillFromOutputField(RuleAction): from_field: Optional[RuleConditionKey] @overload - def __init__(self, *, skill_id: Optional[str] = None, from_field: Optional[RuleConditionKey] = None) -> None: + def __init__( + self, + *, + skill_id: Optional[str] = None, + from_field: Optional[RuleConditionKey] = None + ) -> None: """Method generated by attrs for class SetSkillFromOutputField. """ ... @@ -226,7 +262,12 @@ class ChangeOverlap(RuleAction): """ class Parameters(BaseParameters.Parameters): - def __init__(self, *, delta: Optional[int] = None, open_pool: Optional[bool] = None) -> None: + def __init__( + self, + *, + delta: Optional[int] = None, + open_pool: Optional[bool] = None + ) -> None: """Method generated by attrs for class ChangeOverlap.Parameters. """ ... @@ -236,7 +277,12 @@ class ChangeOverlap(RuleAction): open_pool: Optional[bool] @overload - def __init__(self, *, delta: Optional[int] = None, open_pool: Optional[bool] = None) -> None: + def __init__( + self, + *, + delta: Optional[int] = None, + open_pool: Optional[bool] = None + ) -> None: """Method generated by attrs for class ChangeOverlap. """ ... @@ -271,7 +317,12 @@ class SetSkill(RuleAction): """ class Parameters(BaseParameters.Parameters): - def __init__(self, *, skill_id: Optional[str] = None, skill_value: Optional[int] = None) -> None: + def __init__( + self, + *, + skill_id: Optional[str] = None, + skill_value: Optional[int] = None + ) -> None: """Method generated by attrs for class SetSkill.Parameters. """ ... @@ -281,7 +332,12 @@ class SetSkill(RuleAction): skill_value: Optional[int] @overload - def __init__(self, *, skill_id: Optional[str] = None, skill_value: Optional[int] = None) -> None: + def __init__( + self, + *, + skill_id: Optional[str] = None, + skill_value: Optional[int] = None + ) -> None: """Method generated by attrs for class SetSkill. """ ... diff --git a/src/client/aggregation.pyi b/src/client/aggregation.pyi index ebf50090..44d701c6 100644 --- a/src/client/aggregation.pyi +++ b/src/client/aggregation.pyi @@ -57,7 +57,14 @@ class PoolAggregatedSolutionRequest(BaseTolokaObject): _unexpected: Optional[Dict[str, Any]] name: Optional[str] - def __init__(self, *, type: Optional[AggregatedSolutionType] = None, pool_id: Optional[str] = None, answer_weight_skill_id: Optional[str] = None, fields: Optional[List[Field]] = None) -> None: + def __init__( + self, + *, + type: Optional[AggregatedSolutionType] = None, + pool_id: Optional[str] = None, + answer_weight_skill_id: Optional[str] = None, + fields: Optional[List[Field]] = None + ) -> None: """Method generated by attrs for class PoolAggregatedSolutionRequest. """ ... @@ -77,7 +84,12 @@ class TaskAggregatedSolutionRequest(BaseTolokaObject): pool_id: In which pool this task. """ - def __init__(self, *, task_id: Optional[str] = None, pool_id: Optional[str] = None) -> None: + def __init__( + self, + *, + task_id: Optional[str] = None, + pool_id: Optional[str] = None + ) -> None: """Method generated by attrs for class TaskAggregatedSolutionRequest. """ ... @@ -105,7 +117,14 @@ class WeightedDynamicOverlapTaskAggregatedSolutionRequest(TaskAggregatedSolution _unexpected: Optional[Dict[str, Any]] name: Optional[str] - def __init__(self, *, task_id: Optional[str] = None, pool_id: Optional[str] = None, answer_weight_skill_id: Optional[str] = None, fields: Optional[List[Field]] = None) -> None: + def __init__( + self, + *, + task_id: Optional[str] = None, + pool_id: Optional[str] = None, + answer_weight_skill_id: Optional[str] = None, + fields: Optional[List[Field]] = None + ) -> None: """Method generated by attrs for class WeightedDynamicOverlapTaskAggregatedSolutionRequest. """ ... @@ -127,7 +146,14 @@ class AggregatedSolution(BaseTolokaObject): output_values: Output data fields and aggregate response. """ - def __init__(self, *, pool_id: Optional[str] = None, task_id: Optional[str] = None, confidence: Optional[float] = None, output_values: Optional[Dict[str, Any]] = None) -> None: + def __init__( + self, + *, + pool_id: Optional[str] = None, + task_id: Optional[str] = None, + confidence: Optional[float] = None, + output_values: Optional[Dict[str, Any]] = None + ) -> None: """Method generated by attrs for class AggregatedSolution. """ ... diff --git a/src/client/analytics_request.pyi b/src/client/analytics_request.pyi index 0e47151b..008d7bbf 100644 --- a/src/client/analytics_request.pyi +++ b/src/client/analytics_request.pyi @@ -209,7 +209,12 @@ class ActiveWorkersByFilterCountPoolAnalytics(PoolAnalyticsRequest): interval_hours: The number of hours to take into account when collecting statistics. """ - def __init__(self, *, subject_id: str, interval_hours: int) -> None: + def __init__( + self, + *, + subject_id: str, + interval_hours: int + ) -> None: """Method generated by attrs for class ActiveWorkersByFilterCountPoolAnalytics. """ ... diff --git a/src/client/assignment.pyi b/src/client/assignment.pyi index 2639cce3..e9c6cb98 100644 --- a/src/client/assignment.pyi +++ b/src/client/assignment.pyi @@ -60,7 +60,28 @@ class Assignment(BaseTolokaObject): SKIPPED = 'SKIPPED' EXPIRED = 'EXPIRED' - def __init__(self, *, id: Optional[str] = None, task_suite_id: Optional[str] = None, pool_id: Optional[str] = None, user_id: Optional[str] = None, status: Optional[Status] = None, reward: Optional[Decimal] = None, tasks: Optional[List[Task]] = None, automerged: Optional[bool] = None, created: Optional[datetime] = None, submitted: Optional[datetime] = None, accepted: Optional[datetime] = None, rejected: Optional[datetime] = None, skipped: Optional[datetime] = None, expired: Optional[datetime] = None, first_declined_solution_attempt: Optional[List[Solution]] = None, solutions: Optional[List[Solution]] = None, mixed: Optional[bool] = None, public_comment: Optional[str] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + task_suite_id: Optional[str] = None, + pool_id: Optional[str] = None, + user_id: Optional[str] = None, + status: Optional[Status] = None, + reward: Optional[Decimal] = None, + tasks: Optional[List[Task]] = None, + automerged: Optional[bool] = None, + created: Optional[datetime] = None, + submitted: Optional[datetime] = None, + accepted: Optional[datetime] = None, + rejected: Optional[datetime] = None, + skipped: Optional[datetime] = None, + expired: Optional[datetime] = None, + first_declined_solution_attempt: Optional[List[Solution]] = None, + solutions: Optional[List[Solution]] = None, + mixed: Optional[bool] = None, + public_comment: Optional[str] = None + ) -> None: """Method generated by attrs for class Assignment. """ ... @@ -98,7 +119,12 @@ class AssignmentPatch(BaseTolokaObject): * REJECTED - Rejected by the requester. """ - def __init__(self, *, public_comment: Optional[str] = None, status: Optional[Assignment.Status] = None) -> None: + def __init__( + self, + *, + public_comment: Optional[str] = None, + status: Optional[Assignment.Status] = None + ) -> None: """Method generated by attrs for class AssignmentPatch. """ ... @@ -151,7 +177,15 @@ class GetAssignmentsTsvParameters(Parameters): SKIPPED = 'SKIPPED' EXPIRED = 'EXPIRED' - def __init__(self, *, status: Optional[List[Status]] = ..., start_time_from: Optional[datetime] = None, start_time_to: Optional[datetime] = None, exclude_banned: Optional[bool] = None, field: Optional[List[Field]] = ...) -> None: + def __init__( + self, + *, + status: Optional[List[Status]] = ..., + start_time_from: Optional[datetime] = None, + start_time_to: Optional[datetime] = None, + exclude_banned: Optional[bool] = None, + field: Optional[List[Field]] = ... + ) -> None: """Method generated by attrs for class GetAssignmentsTsvParameters. """ ... diff --git a/src/client/attachment.pyi b/src/client/attachment.pyi index 47f4d2e3..0d9fc532 100644 --- a/src/client/attachment.pyi +++ b/src/client/attachment.pyi @@ -30,7 +30,13 @@ class Attachment(BaseTolokaObject): pool_id: Pool ID. """ - def __init__(self, *, user_id: Optional[str] = None, assignment_id: Optional[str] = None, pool_id: Optional[str] = None) -> None: + def __init__( + self, + *, + user_id: Optional[str] = None, + assignment_id: Optional[str] = None, + pool_id: Optional[str] = None + ) -> None: """Method generated by attrs for class Attachment.Details. """ ... @@ -46,7 +52,16 @@ class Attachment(BaseTolokaObject): ASSIGNMENT_ATTACHMENT = 'ASSIGNMENT_ATTACHMENT' - def __init__(self, *, id: Optional[str] = None, name: Optional[str] = None, details: Optional[Details] = None, created: Optional[datetime] = None, media_type: Optional[str] = None, owner: Optional[Owner] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + details: Optional[Details] = None, + created: Optional[datetime] = None, + media_type: Optional[str] = None, + owner: Optional[Owner] = None + ) -> None: """Method generated by attrs for class Attachment. """ ... @@ -64,7 +79,16 @@ class AssignmentAttachment(Attachment): """Assignment Attachment. """ - def __init__(self, *, id: Optional[str] = None, name: Optional[str] = None, details: Optional[Attachment.Details] = None, created: Optional[datetime] = None, media_type: Optional[str] = None, owner: Optional[Owner] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + details: Optional[Attachment.Details] = None, + created: Optional[datetime] = None, + media_type: Optional[str] = None, + owner: Optional[Owner] = None + ) -> None: """Method generated by attrs for class AssignmentAttachment. """ ... diff --git a/src/client/batch_create_results.pyi b/src/client/batch_create_results.pyi index 88b2a5a7..3fd37022 100644 --- a/src/client/batch_create_results.pyi +++ b/src/client/batch_create_results.pyi @@ -19,7 +19,13 @@ class FieldValidationError(BaseTolokaObject): params: additional params. """ - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, params: Optional[List[Any]] = None) -> None: + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + params: Optional[List[Any]] = None + ) -> None: """Method generated by attrs for class FieldValidationError. """ ... @@ -38,7 +44,12 @@ class TaskBatchCreateResult(BaseTolokaObject): validation_errors: Object with errors in tasks. Returned if the parameter is used in the request skip_invalid_items=True. """ - def __init__(self, *, items: Optional[Dict[str, Task]] = None, validation_errors: Optional[Dict[str, Dict[str, FieldValidationError]]] = None) -> None: + def __init__( + self, + *, + items: Optional[Dict[str, Task]] = None, + validation_errors: Optional[Dict[str, Dict[str, FieldValidationError]]] = None + ) -> None: """Method generated by attrs for class TaskBatchCreateResult. """ ... @@ -56,7 +67,12 @@ class TaskSuiteBatchCreateResult(BaseTolokaObject): validation_errors: Object with errors in task suites. Returned if the parameter is used in the request skip_invalid_items=True. """ - def __init__(self, *, items: Optional[Dict[str, TaskSuite]] = None, validation_errors: Optional[Dict[str, Dict[str, FieldValidationError]]] = None) -> None: + def __init__( + self, + *, + items: Optional[Dict[str, TaskSuite]] = None, + validation_errors: Optional[Dict[str, Dict[str, FieldValidationError]]] = None + ) -> None: """Method generated by attrs for class TaskSuiteBatchCreateResult. """ ... @@ -74,7 +90,12 @@ class UserBonusBatchCreateResult(BaseTolokaObject): validation_errors: Object with validation errors. Returned if the parameter is used in the request skip_invalid_items=True. """ - def __init__(self, *, items: Optional[Dict[str, UserBonus]] = None, validation_errors: Optional[Dict[str, Dict[str, FieldValidationError]]] = None) -> None: + def __init__( + self, + *, + items: Optional[Dict[str, UserBonus]] = None, + validation_errors: Optional[Dict[str, Dict[str, FieldValidationError]]] = None + ) -> None: """Method generated by attrs for class UserBonusBatchCreateResult. """ ... @@ -91,7 +112,12 @@ class WebhookSubscriptionBatchCreateResult(BaseTolokaObject): validation_errors: Object with validation errors. """ - def __init__(self, *, items: Optional[Dict[str, WebhookSubscription]] = None, validation_errors: Optional[Dict[str, Dict[str, FieldValidationError]]] = None) -> None: + def __init__( + self, + *, + items: Optional[Dict[str, WebhookSubscription]] = None, + validation_errors: Optional[Dict[str, Dict[str, FieldValidationError]]] = None + ) -> None: """Method generated by attrs for class WebhookSubscriptionBatchCreateResult. """ ... diff --git a/src/client/collectors.pyi b/src/client/collectors.pyi index 8dbb5723..c34fdee8 100644 --- a/src/client/collectors.pyi +++ b/src/client/collectors.pyi @@ -42,7 +42,12 @@ class CollectorConfig(BaseParameters): ... @overload - def __init__(self, *, parameters: Optional[BaseParameters.Parameters] = None, uuid: Optional[UUID] = None) -> None: + def __init__( + self, + *, + parameters: Optional[BaseParameters.Parameters] = None, + uuid: Optional[UUID] = None + ) -> None: """Method generated by attrs for class CollectorConfig. """ ... @@ -100,7 +105,12 @@ class AcceptanceRate(CollectorConfig): ... @overload - def __init__(self, *, parameters: Optional[BaseParameters.Parameters] = None, uuid: Optional[UUID] = None) -> None: + def __init__( + self, + *, + parameters: Optional[BaseParameters.Parameters] = None, + uuid: Optional[UUID] = None + ) -> None: """Method generated by attrs for class AcceptanceRate. """ ... @@ -146,7 +156,12 @@ class AnswerCount(CollectorConfig): ... @overload - def __init__(self, *, parameters: Optional[BaseParameters.Parameters] = None, uuid: Optional[UUID] = None) -> None: + def __init__( + self, + *, + parameters: Optional[BaseParameters.Parameters] = None, + uuid: Optional[UUID] = None + ) -> None: """Method generated by attrs for class AnswerCount. """ ... @@ -195,7 +210,12 @@ class AssignmentsAssessment(CollectorConfig): ... @overload - def __init__(self, *, parameters: Optional[BaseParameters.Parameters] = None, uuid: Optional[UUID] = None) -> None: + def __init__( + self, + *, + parameters: Optional[BaseParameters.Parameters] = None, + uuid: Optional[UUID] = None + ) -> None: """Method generated by attrs for class AssignmentsAssessment. """ ... @@ -240,7 +260,12 @@ class AssignmentSubmitTime(CollectorConfig): """ class Parameters(BaseParameters.Parameters): - def __init__(self, *, fast_submit_threshold_seconds: Optional[int] = None, history_size: Optional[int] = None) -> None: + def __init__( + self, + *, + fast_submit_threshold_seconds: Optional[int] = None, + history_size: Optional[int] = None + ) -> None: """Method generated by attrs for class AssignmentSubmitTime.Parameters. """ ... @@ -250,13 +275,24 @@ class AssignmentSubmitTime(CollectorConfig): history_size: Optional[int] @overload - def __init__(self, *, uuid: Optional[UUID] = None, fast_submit_threshold_seconds: Optional[int] = None, history_size: Optional[int] = None) -> None: + def __init__( + self, + *, + uuid: Optional[UUID] = None, + fast_submit_threshold_seconds: Optional[int] = None, + history_size: Optional[int] = None + ) -> None: """Method generated by attrs for class AssignmentSubmitTime. """ ... @overload - def __init__(self, *, uuid: Optional[UUID] = None, parameters: Optional[Parameters] = None) -> None: + def __init__( + self, + *, + uuid: Optional[UUID] = None, + parameters: Optional[Parameters] = None + ) -> None: """Method generated by attrs for class AssignmentSubmitTime. """ ... @@ -314,13 +350,23 @@ class Captcha(CollectorConfig): history_size: Optional[int] @overload - def __init__(self, *, uuid: Optional[UUID] = None, history_size: Optional[int] = None) -> None: + def __init__( + self, + *, + uuid: Optional[UUID] = None, + history_size: Optional[int] = None + ) -> None: """Method generated by attrs for class Captcha. """ ... @overload - def __init__(self, *, uuid: Optional[UUID] = None, parameters: Optional[Parameters] = None) -> None: + def __init__( + self, + *, + uuid: Optional[UUID] = None, + parameters: Optional[Parameters] = None + ) -> None: """Method generated by attrs for class Captcha. """ ... @@ -383,13 +429,23 @@ class GoldenSet(CollectorConfig): history_size: Optional[int] @overload - def __init__(self, *, uuid: Optional[UUID] = None, history_size: Optional[int] = None) -> None: + def __init__( + self, + *, + uuid: Optional[UUID] = None, + history_size: Optional[int] = None + ) -> None: """Method generated by attrs for class GoldenSet. """ ... @overload - def __init__(self, *, uuid: Optional[UUID] = None, parameters: Optional[Parameters] = None) -> None: + def __init__( + self, + *, + uuid: Optional[UUID] = None, + parameters: Optional[Parameters] = None + ) -> None: """Method generated by attrs for class GoldenSet. """ ... @@ -438,7 +494,12 @@ class Income(CollectorConfig): ... @overload - def __init__(self, *, parameters: Optional[BaseParameters.Parameters] = None, uuid: Optional[UUID] = None) -> None: + def __init__( + self, + *, + parameters: Optional[BaseParameters.Parameters] = None, + uuid: Optional[UUID] = None + ) -> None: """Method generated by attrs for class Income. """ ... @@ -488,7 +549,12 @@ class MajorityVote(CollectorConfig): """ class Parameters(BaseParameters.Parameters): - def __init__(self, *, answer_threshold: Optional[int] = None, history_size: Optional[int] = None) -> None: + def __init__( + self, + *, + answer_threshold: Optional[int] = None, + history_size: Optional[int] = None + ) -> None: """Method generated by attrs for class MajorityVote.Parameters. """ ... @@ -498,13 +564,24 @@ class MajorityVote(CollectorConfig): history_size: Optional[int] @overload - def __init__(self, *, uuid: Optional[UUID] = None, answer_threshold: Optional[int] = None, history_size: Optional[int] = None) -> None: + def __init__( + self, + *, + uuid: Optional[UUID] = None, + answer_threshold: Optional[int] = None, + history_size: Optional[int] = None + ) -> None: """Method generated by attrs for class MajorityVote. """ ... @overload - def __init__(self, *, uuid: Optional[UUID] = None, parameters: Optional[Parameters] = None) -> None: + def __init__( + self, + *, + uuid: Optional[UUID] = None, + parameters: Optional[Parameters] = None + ) -> None: """Method generated by attrs for class MajorityVote. """ ... @@ -552,7 +629,12 @@ class SkippedInRowAssignments(CollectorConfig): ... @overload - def __init__(self, *, parameters: Optional[BaseParameters.Parameters] = None, uuid: Optional[UUID] = None) -> None: + def __init__( + self, + *, + parameters: Optional[BaseParameters.Parameters] = None, + uuid: Optional[UUID] = None + ) -> None: """Method generated by attrs for class SkippedInRowAssignments. """ ... @@ -570,7 +652,12 @@ class Training(CollectorConfig): ... @overload - def __init__(self, *, parameters: Optional[BaseParameters.Parameters] = None, uuid: Optional[UUID] = None) -> None: + def __init__( + self, + *, + parameters: Optional[BaseParameters.Parameters] = None, + uuid: Optional[UUID] = None + ) -> None: """Method generated by attrs for class Training. """ ... @@ -612,7 +699,12 @@ class UsersAssessment(CollectorConfig): ... @overload - def __init__(self, *, parameters: Optional[BaseParameters.Parameters] = None, uuid: Optional[UUID] = None) -> None: + def __init__( + self, + *, + parameters: Optional[BaseParameters.Parameters] = None, + uuid: Optional[UUID] = None + ) -> None: """Method generated by attrs for class UsersAssessment. """ ... diff --git a/src/client/conditions.pyi b/src/client/conditions.pyi index b3e3e3f7..070e58da 100644 --- a/src/client/conditions.pyi +++ b/src/client/conditions.pyi @@ -44,7 +44,12 @@ class RuleConditionKey(Enum): class RuleCondition(BaseTolokaObject): - def __init__(self, *, operator: Optional[Any] = None, value: Optional[Any] = None) -> None: + def __init__( + self, + *, + operator: Optional[Any] = None, + value: Optional[Any] = None + ) -> None: """Method generated by attrs for class RuleCondition. """ ... @@ -55,7 +60,12 @@ class RuleCondition(BaseTolokaObject): class ComparableRuleCondition(RuleCondition, ComparableConditionMixin): - def __init__(self, operator: CompareOperator, *, value: Optional[Any] = None) -> None: + def __init__( + self, + operator: CompareOperator, + *, + value: Optional[Any] = None + ) -> None: """Method generated by attrs for class ComparableRuleCondition. """ ... @@ -66,7 +76,12 @@ class ComparableRuleCondition(RuleCondition, ComparableConditionMixin): class IdentityRuleCondition(RuleCondition, IdentityConditionMixin): - def __init__(self, operator: IdentityOperator, *, value: Optional[Any] = None) -> None: + def __init__( + self, + operator: IdentityOperator, + *, + value: Optional[Any] = None + ) -> None: """Method generated by attrs for class IdentityRuleCondition. """ ... @@ -85,7 +100,11 @@ class AcceptedAssignmentsCount(ComparableRuleCondition): Sorry about that. """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class AcceptedAssignmentsCount. """ ... @@ -99,7 +118,11 @@ class AcceptedAssignmentsRate(ComparableRuleCondition): """Percentage of how many assignments were accepted from this performer out of all checked assignment """ - def __init__(self, operator: CompareOperator, value: Optional[float] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[float] = None + ) -> None: """Method generated by attrs for class AcceptedAssignmentsRate. """ ... @@ -138,7 +161,11 @@ class AssessmentEvent(IdentityRuleCondition): ACCEPT = 'ACCEPT' REJECT = 'REJECT' - def __init__(self, operator: IdentityOperator, value: Optional[Type] = None) -> None: + def __init__( + self, + operator: IdentityOperator, + value: Optional[Type] = None + ) -> None: """Method generated by attrs for class AssessmentEvent. """ ... @@ -157,7 +184,11 @@ class AssignmentsAcceptedCount(ComparableRuleCondition): Sorry about that. """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class AssignmentsAcceptedCount. """ ... @@ -173,7 +204,11 @@ class CorrectAnswersRate(ComparableRuleCondition): Be careful, it may have different meanings in different collectors. """ - def __init__(self, operator: CompareOperator, value: Optional[float] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[float] = None + ) -> None: """Method generated by attrs for class CorrectAnswersRate. """ ... @@ -187,7 +222,11 @@ class FailRate(ComparableRuleCondition): """Percentage of wrong answers of the performer to the captcha """ - def __init__(self, operator: CompareOperator, value: Optional[float] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[float] = None + ) -> None: """Method generated by attrs for class FailRate. """ ... @@ -201,7 +240,11 @@ class FastSubmittedCount(ComparableRuleCondition): """The number of assignments a specific performer completed too fast """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class FastSubmittedCount. """ ... @@ -215,7 +258,11 @@ class GoldenSetAnswersCount(ComparableRuleCondition): """The number of completed control tasks """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class GoldenSetAnswersCount. """ ... @@ -229,7 +276,11 @@ class GoldenSetCorrectAnswersRate(ComparableRuleCondition): """The percentage of correct responses in control tasks """ - def __init__(self, operator: CompareOperator, value: Optional[float] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[float] = None + ) -> None: """Method generated by attrs for class GoldenSetCorrectAnswersRate. """ ... @@ -243,7 +294,11 @@ class GoldenSetIncorrectAnswersRate(ComparableRuleCondition): """The percentage of incorrect responses in control tasks """ - def __init__(self, operator: CompareOperator, value: Optional[float] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[float] = None + ) -> None: """Method generated by attrs for class GoldenSetIncorrectAnswersRate. """ ... @@ -257,7 +312,11 @@ class IncomeSumForLast24Hours(ComparableRuleCondition): """The performer earnings for completed tasks in the pool over the last 24 hours """ - def __init__(self, operator: CompareOperator, value: Optional[float] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[float] = None + ) -> None: """Method generated by attrs for class IncomeSumForLast24Hours. """ ... @@ -273,7 +332,11 @@ class IncorrectAnswersRate(ComparableRuleCondition): Be careful, it may have different meanings in different collectors. """ - def __init__(self, operator: CompareOperator, value: Optional[float] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[float] = None + ) -> None: """Method generated by attrs for class IncorrectAnswersRate. """ ... @@ -284,7 +347,11 @@ class IncorrectAnswersRate(ComparableRuleCondition): class NextAssignmentAvailable(ComparableRuleCondition): - def __init__(self, operator: CompareOperator, value: Optional[bool] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[bool] = None + ) -> None: """Method generated by attrs for class NextAssignmentAvailable. """ ... @@ -298,7 +365,11 @@ class PendingAssignmentsCount(ComparableRuleCondition): """Number of Assignments pending checking """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class PendingAssignmentsCount. """ ... @@ -325,7 +396,11 @@ class PoolAccessRevokedReason(IdentityRuleCondition): SKILL_CHANGE = 'SKILL_CHANGE' RESTRICTION = 'RESTRICTION' - def __init__(self, operator: IdentityOperator, value: Optional[Type] = None) -> None: + def __init__( + self, + operator: IdentityOperator, + value: Optional[Type] = None + ) -> None: """Method generated by attrs for class PoolAccessRevokedReason. """ ... @@ -339,7 +414,11 @@ class RejectedAssignmentsCount(ComparableRuleCondition): """How many times this assignment was rejected """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class RejectedAssignmentsCount. """ ... @@ -353,7 +432,11 @@ class RejectedAssignmentsRate(ComparableRuleCondition): """Percentage of how many assignments were rejected from this performer out of all checked assignment """ - def __init__(self, operator: CompareOperator, value: Optional[float] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[float] = None + ) -> None: """Method generated by attrs for class RejectedAssignmentsRate. """ ... @@ -367,7 +450,11 @@ class SkillId(IdentityRuleCondition): """The performer no longer meets the specific skill filter """ - def __init__(self, operator: IdentityOperator, value: Optional[str] = None) -> None: + def __init__( + self, + operator: IdentityOperator, + value: Optional[str] = None + ) -> None: """Method generated by attrs for class SkillId. """ ... @@ -381,7 +468,11 @@ class SkippedInRowCount(ComparableRuleCondition): """How many tasks in a row the performer skipped """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class SkippedInRowCount. """ ... @@ -395,7 +486,11 @@ class StoredResultsCount(ComparableRuleCondition): """How many times the performer entered captcha """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class StoredResultsCount. """ ... @@ -406,7 +501,11 @@ class StoredResultsCount(ComparableRuleCondition): class SubmittedAssignmentsCount(ComparableRuleCondition): - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class SubmittedAssignmentsCount. """ ... @@ -420,7 +519,11 @@ class SuccessRate(ComparableRuleCondition): """Percentage of correct answers of the performer to the captcha """ - def __init__(self, operator: CompareOperator, value: Optional[float] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[float] = None + ) -> None: """Method generated by attrs for class SuccessRate. """ ... @@ -436,7 +539,11 @@ class TotalAnswersCount(ComparableRuleCondition): Be careful, it may have different meanings in different collectors. """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class TotalAnswersCount. """ ... @@ -450,7 +557,11 @@ class TotalAssignmentsCount(ComparableRuleCondition): """How many assignments from this performer were checked """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class TotalAssignmentsCount. """ ... @@ -464,7 +575,11 @@ class TotalSubmittedCount(ComparableRuleCondition): """The number of assignments a specific performer completed """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class TotalSubmittedCount. """ ... diff --git a/src/client/exceptions.pyi b/src/client/exceptions.pyi index e00f6b02..3707dedc 100644 --- a/src/client/exceptions.pyi +++ b/src/client/exceptions.pyi @@ -13,7 +13,12 @@ class SpecClassIdentificationError(Exception): spec_enum: enum class containing spec_class possible types """ - def __init__(self, *, spec_field: Optional[str] = None, spec_enum: Optional[str] = None) -> None: + def __init__( + self, + *, + spec_field: Optional[str] = None, + spec_enum: Optional[str] = None + ) -> None: """Method generated by attrs for class SpecClassIdentificationError. """ ... @@ -33,7 +38,15 @@ class ApiError(Exception): payload: additional payload """ - def __init__(self, *, status_code: Optional[int] = None, request_id: Optional[str] = None, code: Optional[str] = None, message: Optional[str] = None, payload: Optional[Any] = None) -> None: + def __init__( + self, + *, + status_code: Optional[int] = None, + request_id: Optional[str] = None, + code: Optional[str] = None, + message: Optional[str] = None, + payload: Optional[Any] = None + ) -> None: """Method generated by attrs for class ApiError. """ ... diff --git a/src/client/filter.pyi b/src/client/filter.pyi index 30e660da..08138d9a 100644 --- a/src/client/filter.pyi +++ b/src/client/filter.pyi @@ -101,7 +101,12 @@ class Condition(FilterCondition): COMPUTED = 'computed' SKILL = 'skill' - def __init__(self, *, operator: Any, value: Any) -> None: + def __init__( + self, + *, + operator: Any, + value: Any + ) -> None: """Method generated by attrs for class Condition. """ ... @@ -135,7 +140,12 @@ class Profile(Condition): CITY = 'city' LANGUAGES = 'languages' - def __init__(self, *, operator: Any, value: Any) -> None: + def __init__( + self, + *, + operator: Any, + value: Any + ) -> None: """Method generated by attrs for class Profile. """ ... @@ -174,7 +184,12 @@ class Computed(Condition): USER_AGENT_VERSION_MINOR = 'user_agent_version_minor' USER_AGENT_VERSION_BUGFIX = 'user_agent_version_bugfix' - def __init__(self, *, operator: Any, value: Any) -> None: + def __init__( + self, + *, + operator: Any, + value: Any + ) -> None: """Method generated by attrs for class Computed. """ ... @@ -194,7 +209,12 @@ class Skill(StatefulComparableConditionMixin, Condition): value: Attribute value from the field key. """ - def __init__(self, key: str, operator: CompareOperator = ..., value: Optional[float] = None) -> None: + def __init__( + self, + key: str, + operator: CompareOperator = ..., + value: Optional[float] = None + ) -> None: """Method generated by attrs for class Skill. """ ... @@ -219,7 +239,11 @@ class Gender(Profile, IdentityConditionMixin): MALE = 'MALE' FEMALE = 'FEMALE' - def __init__(self, operator: IdentityOperator, value: Gender) -> None: + def __init__( + self, + operator: IdentityOperator, + value: Gender + ) -> None: """Method generated by attrs for class Gender. """ ... @@ -236,7 +260,11 @@ class Country(Profile, IdentityConditionMixin): value: Country of the user (two-letter code of the standard ISO 3166-1 alpha-2). """ - def __init__(self, operator: IdentityOperator, value: str) -> None: + def __init__( + self, + operator: IdentityOperator, + value: str + ) -> None: """Method generated by attrs for class Country. """ ... @@ -253,7 +281,11 @@ class Citizenship(Profile, IdentityConditionMixin): value: User citizenship (two-letter country code) ISO 3166-1 alpha-2 """ - def __init__(self, operator: IdentityOperator, value: str) -> None: + def __init__( + self, + operator: IdentityOperator, + value: str + ) -> None: """Method generated by attrs for class Citizenship. """ ... @@ -278,7 +310,11 @@ class Education(Profile, IdentityConditionMixin): MIDDLE = 'MIDDLE' HIGH = 'HIGH' - def __init__(self, operator: IdentityOperator, value: Education) -> None: + def __init__( + self, + operator: IdentityOperator, + value: Education + ) -> None: """Method generated by attrs for class Education. """ ... @@ -295,7 +331,11 @@ class AdultAllowed(Profile, IdentityConditionMixin): value: User agreement. """ - def __init__(self, operator: IdentityOperator, value: bool) -> None: + def __init__( + self, + operator: IdentityOperator, + value: bool + ) -> None: """Method generated by attrs for class AdultAllowed. """ ... @@ -312,7 +352,11 @@ class DateOfBirth(Profile, ComparableConditionMixin): value: The user's date of birth (UNIX time in seconds). """ - def __init__(self, operator: CompareOperator, value: int) -> None: + def __init__( + self, + operator: CompareOperator, + value: int + ) -> None: """Method generated by attrs for class DateOfBirth. """ ... @@ -329,7 +373,11 @@ class City(Profile, InclusionConditionMixin): value: User city(ID of the region). """ - def __init__(self, operator: InclusionOperator, value: int) -> None: + def __init__( + self, + operator: InclusionOperator, + value: int + ) -> None: """Method generated by attrs for class City. """ ... @@ -346,7 +394,11 @@ class Languages(Profile, InclusionConditionMixin): value: Languages specified by the user in the profile (two-letter ISO code of the standard ISO 639-1 in upper case). """ - def __init__(self, operator: InclusionOperator, value: Union[str, List[str]]) -> None: + def __init__( + self, + operator: InclusionOperator, + value: Union[str, List[str]] + ) -> None: """Method generated by attrs for class Languages. """ ... @@ -363,7 +415,11 @@ class RegionByPhone(Computed, InclusionConditionMixin): value: The user's region. """ - def __init__(self, operator: InclusionOperator, value: int) -> None: + def __init__( + self, + operator: InclusionOperator, + value: int + ) -> None: """Method generated by attrs for class RegionByPhone. """ ... @@ -380,7 +436,11 @@ class RegionByIp(Computed, InclusionConditionMixin): value: The user's region. """ - def __init__(self, operator: InclusionOperator, value: int) -> None: + def __init__( + self, + operator: InclusionOperator, + value: int + ) -> None: """Method generated by attrs for class RegionByIp. """ ... @@ -406,7 +466,11 @@ class DeviceCategory(Computed, IdentityConditionMixin): TABLET = 'TABLET' WEARABLE_COMPUTER = 'WEARABLE_COMPUTER' - def __init__(self, operator: IdentityOperator, value: DeviceCategory) -> None: + def __init__( + self, + operator: IdentityOperator, + value: DeviceCategory + ) -> None: """Method generated by attrs for class DeviceCategory. """ ... @@ -430,7 +494,11 @@ class ClientType(Computed, IdentityConditionMixin): BROWSER = 'BROWSER' TOLOKA_APP = 'TOLOKA_APP' - def __init__(self, operator: IdentityOperator, value: ClientType) -> None: + def __init__( + self, + operator: IdentityOperator, + value: ClientType + ) -> None: """Method generated by attrs for class ClientType. """ ... @@ -460,7 +528,11 @@ class OSFamily(Computed, IdentityConditionMixin): IOS = 'IOS' BLACKBERRY = 'BLACKBERRY' - def __init__(self, operator: IdentityOperator, value: OSFamily) -> None: + def __init__( + self, + operator: IdentityOperator, + value: OSFamily + ) -> None: """Method generated by attrs for class OSFamily. """ ... @@ -478,7 +550,11 @@ class OSVersion(Computed, ComparableConditionMixin): value: Full version of the operating system. """ - def __init__(self, operator: CompareOperator, value: float) -> None: + def __init__( + self, + operator: CompareOperator, + value: float + ) -> None: """Method generated by attrs for class OSVersion. """ ... @@ -496,7 +572,11 @@ class OSVersionMajor(Computed, ComparableConditionMixin): value: Major version of the operating system. """ - def __init__(self, operator: CompareOperator, value: int) -> None: + def __init__( + self, + operator: CompareOperator, + value: int + ) -> None: """Method generated by attrs for class OSVersionMajor. """ ... @@ -514,7 +594,11 @@ class OSVersionMinor(Computed, ComparableConditionMixin): value: Minor version of the operating system. """ - def __init__(self, operator: CompareOperator, value: int) -> None: + def __init__( + self, + operator: CompareOperator, + value: int + ) -> None: """Method generated by attrs for class OSVersionMinor. """ ... @@ -532,7 +616,11 @@ class OSVersionBugfix(Computed, ComparableConditionMixin): value: Build number (bugfix version) of the operating system. """ - def __init__(self, operator: CompareOperator, value: int) -> None: + def __init__( + self, + operator: CompareOperator, + value: int + ) -> None: """Method generated by attrs for class OSVersionBugfix. """ ... @@ -557,7 +645,11 @@ class UserAgentType(Computed, IdentityConditionMixin): MOBILE_BROWSER = 'MOBILE_BROWSER' OTHER = 'OTHER' - def __init__(self, operator: IdentityOperator, value: UserAgentType) -> None: + def __init__( + self, + operator: IdentityOperator, + value: UserAgentType + ) -> None: """Method generated by attrs for class UserAgentType. """ ... @@ -589,7 +681,11 @@ class UserAgentFamily(Computed, IdentityConditionMixin): MOBILE_FIREFOX = 'MOBILE_FIREFOX' MOBILE_SAFARI = 'MOBILE_SAFARI' - def __init__(self, operator: IdentityOperator, value: UserAgentFamily) -> None: + def __init__( + self, + operator: IdentityOperator, + value: UserAgentFamily + ) -> None: """Method generated by attrs for class UserAgentFamily. """ ... @@ -606,7 +702,11 @@ class UserAgentVersion(Computed, ComparableConditionMixin): value: Full browser version. .. """ - def __init__(self, operator: CompareOperator, value: Optional[float] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[float] = None + ) -> None: """Method generated by attrs for class UserAgentVersion. """ ... @@ -623,7 +723,11 @@ class UserAgentVersionMajor(Computed, ComparableConditionMixin): value: Major browser version. """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class UserAgentVersionMajor. """ ... @@ -640,7 +744,11 @@ class UserAgentVersionMinor(Computed, ComparableConditionMixin): value: Minor browser version. """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class UserAgentVersionMinor. """ ... @@ -657,7 +765,11 @@ class UserAgentVersionBugfix(Computed, ComparableConditionMixin): value: Build number (bugfix version) of the browser. """ - def __init__(self, operator: CompareOperator, value: Optional[int] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[int] = None + ) -> None: """Method generated by attrs for class UserAgentVersionBugfix. """ ... @@ -674,7 +786,11 @@ class Rating(Computed, ComparableConditionMixin): value: User rating. Calculated based on earnings in all projects available to the user. """ - def __init__(self, operator: CompareOperator, value: Optional[float] = None) -> None: + def __init__( + self, + operator: CompareOperator, + value: Optional[float] = None + ) -> None: """Method generated by attrs for class Rating. """ ... diff --git a/src/client/message_thread.pyi b/src/client/message_thread.pyi index 7d9c5b79..d53ff763 100644 --- a/src/client/message_thread.pyi +++ b/src/client/message_thread.pyi @@ -58,7 +58,13 @@ class Interlocutor(BaseTolokaObject): ADMINISTRATOR = 'ADMINISTRATOR' SYSTEM = 'SYSTEM' - def __init__(self, *, id: Optional[str] = None, role: Optional[InterlocutorRole] = None, myself: Optional[bool] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + role: Optional[InterlocutorRole] = None, + myself: Optional[bool] = None + ) -> None: """Method generated by attrs for class Interlocutor. """ ... @@ -104,7 +110,13 @@ class MessageThread(BaseTolokaObject): recipients_filter: Condition to filter recipients. """ - def __init__(self, *, recipients_select_type: Optional[RecipientsSelectType] = None, recipients_ids: Optional[List[str]] = None, recipients_filter: Optional[FilterCondition] = None) -> None: + def __init__( + self, + *, + recipients_select_type: Optional[RecipientsSelectType] = None, + recipients_ids: Optional[List[str]] = None, + recipients_filter: Optional[FilterCondition] = None + ) -> None: """Method generated by attrs for class MessageThread.ComposeDetails. """ ... @@ -123,7 +135,13 @@ class MessageThread(BaseTolokaObject): created: Date the message was created. """ - def __init__(self, *, text: Optional[Dict[str, str]] = None, from_: Optional[Interlocutor] = None, created: Optional[datetime] = None) -> None: + def __init__( + self, + *, + text: Optional[Dict[str, str]] = None, + from_: Optional[Interlocutor] = None, + created: Optional[datetime] = None + ) -> None: """Method generated by attrs for class MessageThread.Message. """ ... @@ -134,7 +152,13 @@ class MessageThread(BaseTolokaObject): created: Optional[datetime] class Meta(BaseTolokaObject): - def __init__(self, *, pool_id: Optional[str] = None, project_id: Optional[str] = None, assignment_id: Optional[str] = None) -> None: + def __init__( + self, + *, + pool_id: Optional[str] = None, + project_id: Optional[str] = None, + assignment_id: Optional[str] = None + ) -> None: """Method generated by attrs for class MessageThread.Meta. """ ... @@ -144,7 +168,21 @@ class MessageThread(BaseTolokaObject): project_id: Optional[str] assignment_id: Optional[str] - def __init__(self, *, id: Optional[str] = None, topic: Optional[Dict[str, str]] = None, interlocutors_inlined: Optional[bool] = None, interlocutors: Optional[List[Interlocutor]] = None, messages_inlined: Optional[bool] = None, messages: Optional[List[Message]] = None, meta: Optional[Meta] = None, answerable: Optional[bool] = None, folders: Optional[List[Folder]] = None, compose_details: Optional[ComposeDetails] = None, created: Optional[datetime] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + topic: Optional[Dict[str, str]] = None, + interlocutors_inlined: Optional[bool] = None, + interlocutors: Optional[List[Interlocutor]] = None, + messages_inlined: Optional[bool] = None, + messages: Optional[List[Message]] = None, + meta: Optional[Meta] = None, + answerable: Optional[bool] = None, + folders: Optional[List[Folder]] = None, + compose_details: Optional[ComposeDetails] = None, + created: Optional[datetime] = None + ) -> None: """Method generated by attrs for class MessageThread. """ ... @@ -212,7 +250,16 @@ class MessageThreadCompose(BaseTolokaObject): recipients_filter: Filter to select recipients. """ - def __init__(self, *, recipients_select_type: Optional[RecipientsSelectType] = None, topic: Optional[Dict[str, str]] = None, text: Optional[Dict[str, str]] = None, answerable: Optional[bool] = None, recipients_ids: Optional[List[str]] = None, recipients_filter: Optional[FilterCondition] = None) -> None: + def __init__( + self, + *, + recipients_select_type: Optional[RecipientsSelectType] = None, + topic: Optional[Dict[str, str]] = None, + text: Optional[Dict[str, str]] = None, + answerable: Optional[bool] = None, + recipients_ids: Optional[List[str]] = None, + recipients_filter: Optional[FilterCondition] = None + ) -> None: """Method generated by attrs for class MessageThreadCompose. """ ... diff --git a/src/client/operation_log.pyi b/src/client/operation_log.pyi index daeee415..269a4d56 100644 --- a/src/client/operation_log.pyi +++ b/src/client/operation_log.pyi @@ -17,7 +17,14 @@ class OperationLogItem(BaseTolokaObject): output: Operation step output. Depends on the type. """ - def __init__(self, *, type: Optional[str] = None, success: Optional[bool] = None, input: Optional[Dict[str, Any]] = None, output: Optional[Dict[str, Any]] = None) -> None: + def __init__( + self, + *, + type: Optional[str] = None, + success: Optional[bool] = None, + input: Optional[Dict[str, Any]] = None, + output: Optional[Dict[str, Any]] = None + ) -> None: """Method generated by attrs for class OperationLogItem. """ ... diff --git a/src/client/operations.pyi b/src/client/operations.pyi index ee1d756a..f54acd9b 100644 --- a/src/client/operations.pyi +++ b/src/client/operations.pyi @@ -71,7 +71,18 @@ class Operation(BaseTolokaObject): SUCCESS = 'SUCCESS' FAIL = 'FAIL' - def __init__(self, *, id: Optional[str] = None, status: Optional[Status] = None, submitted: Optional[datetime] = None, parameters: Optional[Parameters] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, details: Optional[Any] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Status] = None, + submitted: Optional[datetime] = None, + parameters: Optional[Parameters] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + details: Optional[Any] = None + ) -> None: """Method generated by attrs for class Operation. """ ... @@ -93,7 +104,18 @@ class AnalyticsOperation(Operation): """Operation returned when requesting analytics via TolokaClient.get_analytics() """ - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, parameters: Optional[Operation.Parameters] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, details: Optional[Any] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + parameters: Optional[Operation.Parameters] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + details: Optional[Any] = None + ) -> None: """Method generated by attrs for class AnalyticsOperation. """ ... @@ -125,7 +147,18 @@ class PoolOperation(Operation): _unexpected: Optional[Dict[str, Any]] pool_id: Optional[str] - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, details: Optional[Any] = None, parameters: Optional[Parameters] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + details: Optional[Any] = None, + parameters: Optional[Parameters] = None + ) -> None: """Method generated by attrs for class PoolOperation. """ ... @@ -145,7 +178,18 @@ class PoolArchiveOperation(PoolOperation): """Operation returned by an asynchronous archive pool via TolokaClient.archive_pool_async() """ - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, details: Optional[Any] = None, parameters: Optional[PoolOperation.Parameters] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + details: Optional[Any] = None, + parameters: Optional[PoolOperation.Parameters] = None + ) -> None: """Method generated by attrs for class PoolArchiveOperation. """ ... @@ -181,7 +225,18 @@ class PoolCloneOperation(PoolOperation): _unexpected: Optional[Dict[str, Any]] pool_id: Optional[str] - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, parameters: Optional[PoolOperation.Parameters] = None, details: Optional[Details] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + parameters: Optional[PoolOperation.Parameters] = None, + details: Optional[Details] = None + ) -> None: """Method generated by attrs for class PoolCloneOperation. """ ... @@ -201,7 +256,18 @@ class PoolCloseOperation(PoolOperation): """Operation returned by an asynchronous closing pool via TolokaClient.close_pool_async() """ - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, details: Optional[Any] = None, parameters: Optional[PoolOperation.Parameters] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + details: Optional[Any] = None, + parameters: Optional[PoolOperation.Parameters] = None + ) -> None: """Method generated by attrs for class PoolCloseOperation. """ ... @@ -221,7 +287,18 @@ class PoolOpenOperation(PoolOperation): """Operation returned by an asynchronous opening pool via TolokaClient.open_pool_async() """ - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, details: Optional[Any] = None, parameters: Optional[PoolOperation.Parameters] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + details: Optional[Any] = None, + parameters: Optional[PoolOperation.Parameters] = None + ) -> None: """Method generated by attrs for class PoolOpenOperation. """ ... @@ -253,7 +330,18 @@ class TrainingOperation(Operation): _unexpected: Optional[Dict[str, Any]] training_id: Optional[str] - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, details: Optional[Any] = None, parameters: Optional[Parameters] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + details: Optional[Any] = None, + parameters: Optional[Parameters] = None + ) -> None: """Method generated by attrs for class TrainingOperation. """ ... @@ -273,7 +361,18 @@ class TrainingArchiveOperation(TrainingOperation): """Operation returned by an asynchronous archive training pool via TolokaClient.archive_training_async() """ - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, details: Optional[Any] = None, parameters: Optional[TrainingOperation.Parameters] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + details: Optional[Any] = None, + parameters: Optional[TrainingOperation.Parameters] = None + ) -> None: """Method generated by attrs for class TrainingArchiveOperation. """ ... @@ -309,7 +408,18 @@ class TrainingCloneOperation(TrainingOperation): _unexpected: Optional[Dict[str, Any]] training_id: Optional[str] - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, parameters: Optional[TrainingOperation.Parameters] = None, details: Optional[Details] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + parameters: Optional[TrainingOperation.Parameters] = None, + details: Optional[Details] = None + ) -> None: """Method generated by attrs for class TrainingCloneOperation. """ ... @@ -329,7 +439,18 @@ class TrainingCloseOperation(TrainingOperation): """Operation returned by an asynchronous closing training pool via TolokaClient.close_training_async() """ - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, details: Optional[Any] = None, parameters: Optional[TrainingOperation.Parameters] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + details: Optional[Any] = None, + parameters: Optional[TrainingOperation.Parameters] = None + ) -> None: """Method generated by attrs for class TrainingCloseOperation. """ ... @@ -349,7 +470,18 @@ class TrainingOpenOperation(TrainingOperation): """Operation returned by an asynchronous opening training pool via TolokaClient.open_training_async() """ - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, details: Optional[Any] = None, parameters: Optional[TrainingOperation.Parameters] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + details: Optional[Any] = None, + parameters: Optional[TrainingOperation.Parameters] = None + ) -> None: """Method generated by attrs for class TrainingOpenOperation. """ ... @@ -381,7 +513,18 @@ class ProjectArchiveOperation(Operation): _unexpected: Optional[Dict[str, Any]] project_id: Optional[str] - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, details: Optional[Any] = None, parameters: Optional[Parameters] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + details: Optional[Any] = None, + parameters: Optional[Parameters] = None + ) -> None: """Method generated by attrs for class ProjectArchiveOperation. """ ... @@ -415,7 +558,13 @@ class TasksCreateOperation(Operation): """ class Parameters(Operation.Parameters): - def __init__(self, *, skip_invalid_items: Optional[bool] = None, allow_defaults: Optional[bool] = None, open_pool: Optional[bool] = None) -> None: + def __init__( + self, + *, + skip_invalid_items: Optional[bool] = None, + allow_defaults: Optional[bool] = None, + open_pool: Optional[bool] = None + ) -> None: """Method generated by attrs for class TasksCreateOperation.Parameters. """ ... @@ -425,7 +574,18 @@ class TasksCreateOperation(Operation): allow_defaults: Optional[bool] open_pool: Optional[bool] - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, progress: Optional[int] = None, parameters: Optional[Parameters] = None, finished: Optional[datetime] = None, details: Optional[Any] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + progress: Optional[int] = None, + parameters: Optional[Parameters] = None, + finished: Optional[datetime] = None, + details: Optional[Any] = None + ) -> None: """Method generated by attrs for class TasksCreateOperation. """ ... @@ -458,7 +618,13 @@ class TaskSuiteCreateBatchOperation(Operation): """ class Parameters(Operation.Parameters): - def __init__(self, *, skip_invalid_items: Optional[bool] = None, allow_defaults: Optional[bool] = None, open_pool: Optional[bool] = None) -> None: + def __init__( + self, + *, + skip_invalid_items: Optional[bool] = None, + allow_defaults: Optional[bool] = None, + open_pool: Optional[bool] = None + ) -> None: """Method generated by attrs for class TaskSuiteCreateBatchOperation.Parameters. """ ... @@ -468,7 +634,18 @@ class TaskSuiteCreateBatchOperation(Operation): allow_defaults: Optional[bool] open_pool: Optional[bool] - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, progress: Optional[int] = None, parameters: Optional[Parameters] = None, finished: Optional[datetime] = None, details: Optional[Any] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + progress: Optional[int] = None, + parameters: Optional[Parameters] = None, + finished: Optional[datetime] = None, + details: Optional[Any] = None + ) -> None: """Method generated by attrs for class TaskSuiteCreateBatchOperation. """ ... @@ -500,7 +677,18 @@ class AggregatedSolutionOperation(Operation): _unexpected: Optional[Dict[str, Any]] pool_id: Optional[str] - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, details: Optional[Any] = None, parameters: Optional[Parameters] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + details: Optional[Any] = None, + parameters: Optional[Parameters] = None + ) -> None: """Method generated by attrs for class AggregatedSolutionOperation. """ ... @@ -535,7 +723,16 @@ class UserBonusCreateBatchOperation(Operation): """ class Details(PoolOperation.Parameters): - def __init__(self, *, pool_id: Optional[str] = None, total_count: Optional[int] = None, valid_count: Optional[int] = None, not_valid_count: Optional[int] = None, success_count: Optional[int] = None, failed_count: Optional[int] = None) -> None: + def __init__( + self, + *, + pool_id: Optional[str] = None, + total_count: Optional[int] = None, + valid_count: Optional[int] = None, + not_valid_count: Optional[int] = None, + success_count: Optional[int] = None, + failed_count: Optional[int] = None + ) -> None: """Method generated by attrs for class UserBonusCreateBatchOperation.Details. """ ... @@ -557,7 +754,18 @@ class UserBonusCreateBatchOperation(Operation): _unexpected: Optional[Dict[str, Any]] skip_invalid_items: Optional[bool] - def __init__(self, *, id: Optional[str] = None, status: Optional[Operation.Status] = None, submitted: Optional[datetime] = None, started: Optional[datetime] = None, finished: Optional[datetime] = None, progress: Optional[int] = None, parameters: Optional[Parameters] = None, details: Optional[Details] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Operation.Status] = None, + submitted: Optional[datetime] = None, + started: Optional[datetime] = None, + finished: Optional[datetime] = None, + progress: Optional[int] = None, + parameters: Optional[Parameters] = None, + details: Optional[Details] = None + ) -> None: """Method generated by attrs for class UserBonusCreateBatchOperation. """ ... diff --git a/src/client/owner.pyi b/src/client/owner.pyi index 83e1d8d0..f6ba2d8d 100644 --- a/src/client/owner.pyi +++ b/src/client/owner.pyi @@ -17,7 +17,13 @@ class Owner(BaseTolokaObject): company_id: ID of the customer's company. """ - def __init__(self, *, id: Optional[str] = None, myself: Optional[bool] = None, company_id: Optional[str] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + myself: Optional[bool] = None, + company_id: Optional[str] = None + ) -> None: """Method generated by attrs for class Owner. """ ... diff --git a/src/client/pool/__init__.pyi b/src/client/pool/__init__.pyi index 4d72d05e..b58f8b58 100644 --- a/src/client/pool/__init__.pyi +++ b/src/client/pool/__init__.pyi @@ -160,7 +160,12 @@ class Pool(BaseTolokaObject): (used if the allow_defaults=True parameter is set when uploading). """ - def __init__(self, *, default_overlap_for_new_task_suites: Optional[int] = None, default_overlap_for_new_tasks: Optional[int] = None) -> None: + def __init__( + self, + *, + default_overlap_for_new_task_suites: Optional[int] = None, + default_overlap_for_new_tasks: Optional[int] = None + ) -> None: """Method generated by attrs for class Pool.Defaults. """ ... @@ -200,7 +205,40 @@ class Pool(BaseTolokaObject): REGULAR = 'REGULAR' TRAINING = 'TRAINING' - def __init__(self, *, project_id: Optional[str] = None, private_name: Optional[str] = None, may_contain_adult_content: Optional[bool] = None, reward_per_assignment: Optional[float] = None, assignment_max_duration_seconds: Optional[int] = None, defaults: Optional[Defaults] = None, will_expire: Optional[datetime] = None, private_comment: Optional[str] = None, public_description: Optional[str] = None, public_instructions: Optional[str] = None, auto_close_after_complete_delay_seconds: Optional[int] = None, dynamic_pricing_config: Optional[DynamicPricingConfig] = None, auto_accept_solutions: Optional[bool] = None, auto_accept_period_day: Optional[int] = None, assignments_issuing_config: Optional[AssignmentsIssuingConfig] = None, priority: Optional[int] = None, filter: Optional[FilterCondition] = None, quality_control: Optional[QualityControl] = ..., dynamic_overlap_config: Optional[DynamicOverlapConfig] = None, mixer_config: Optional[MixerConfig] = None, training_config: Optional[TrainingConfig] = None, metadata: Optional[Dict[str, List[str]]] = None, owner: Optional[Owner] = None, id: Optional[str] = None, status: Optional[Status] = None, last_close_reason: Optional[CloseReason] = None, created: Optional[datetime] = None, last_started: Optional[datetime] = None, last_stopped: Optional[datetime] = None, type: Optional[Type] = None) -> None: + def __init__( + self, + *, + project_id: Optional[str] = None, + private_name: Optional[str] = None, + may_contain_adult_content: Optional[bool] = None, + reward_per_assignment: Optional[float] = None, + assignment_max_duration_seconds: Optional[int] = None, + defaults: Optional[Defaults] = ..., + will_expire: Optional[datetime] = None, + private_comment: Optional[str] = None, + public_description: Optional[str] = None, + public_instructions: Optional[str] = None, + auto_close_after_complete_delay_seconds: Optional[int] = None, + dynamic_pricing_config: Optional[DynamicPricingConfig] = None, + auto_accept_solutions: Optional[bool] = None, + auto_accept_period_day: Optional[int] = None, + assignments_issuing_config: Optional[AssignmentsIssuingConfig] = None, + priority: Optional[int] = None, + filter: Optional[FilterCondition] = None, + quality_control: Optional[QualityControl] = ..., + dynamic_overlap_config: Optional[DynamicOverlapConfig] = None, + mixer_config: Optional[MixerConfig] = None, + training_config: Optional[TrainingConfig] = None, + metadata: Optional[Dict[str, List[str]]] = None, + owner: Optional[Owner] = None, + id: Optional[str] = None, + status: Optional[Status] = None, + last_close_reason: Optional[CloseReason] = None, + created: Optional[datetime] = None, + last_started: Optional[datetime] = None, + last_stopped: Optional[datetime] = None, + type: Optional[Type] = None + ) -> None: """Method generated by attrs for class Pool. """ ... @@ -231,7 +269,13 @@ class Pool(BaseTolokaObject): ... @overload - def set_checkpoints_config(self, *, real_settings: Optional[QualityControl.CheckpointsConfig.Settings] = None, golden_settings: Optional[QualityControl.CheckpointsConfig.Settings] = None, training_settings: Optional[QualityControl.CheckpointsConfig.Settings] = None): + def set_checkpoints_config( + self, + *, + real_settings: Optional[QualityControl.CheckpointsConfig.Settings] = None, + golden_settings: Optional[QualityControl.CheckpointsConfig.Settings] = None, + training_settings: Optional[QualityControl.CheckpointsConfig.Settings] = None + ): """A shortcut setter for quality_control.checkpoints_config """ ... @@ -243,7 +287,12 @@ class Pool(BaseTolokaObject): ... @overload - def set_defaults(self, *, default_overlap_for_new_task_suites: Optional[int] = None, default_overlap_for_new_tasks: Optional[int] = None): + def set_defaults( + self, + *, + default_overlap_for_new_task_suites: Optional[int] = None, + default_overlap_for_new_tasks: Optional[int] = None + ): """A shortcut setter for defaults """ ... @@ -255,7 +304,15 @@ class Pool(BaseTolokaObject): ... @overload - def set_dynamic_overlap_config(self, *, type: Optional[DynamicOverlapConfig.Type] = None, max_overlap: Optional[int] = None, min_confidence: Optional[float] = None, answer_weight_skill_id: Optional[str] = None, fields: Optional[List[DynamicOverlapConfig.Field]] = None): + def set_dynamic_overlap_config( + self, + *, + type: Optional[DynamicOverlapConfig.Type] = None, + max_overlap: Optional[int] = None, + min_confidence: Optional[float] = None, + answer_weight_skill_id: Optional[str] = None, + fields: Optional[List[DynamicOverlapConfig.Field]] = None + ): """A shortcut setter for dynamic_overlap_config """ ... @@ -267,7 +324,12 @@ class Pool(BaseTolokaObject): ... @overload - def set_dynamic_pricing_config(self, type: Optional[DynamicPricingConfig.Type] = None, skill_id: Optional[str] = None, intervals: Optional[List[DynamicPricingConfig.Interval]] = None): + def set_dynamic_pricing_config( + self, + type: Optional[DynamicPricingConfig.Type] = None, + skill_id: Optional[str] = None, + intervals: Optional[List[DynamicPricingConfig.Interval]] = None + ): """A shortcut setter for dynamic_pricing_config """ ... @@ -291,7 +353,22 @@ class Pool(BaseTolokaObject): ... @overload - def set_mixer_config(self, *, real_tasks_count: int = 0, golden_tasks_count: int = 0, training_tasks_count: int = 0, min_real_tasks_count: Optional[int] = None, min_golden_tasks_count: Optional[int] = None, min_training_tasks_count: Optional[int] = None, force_last_assignment: Optional[bool] = None, force_last_assignment_delay_seconds: Optional[int] = None, mix_tasks_in_creation_order: Optional[bool] = None, shuffle_tasks_in_task_suite: Optional[bool] = None, golden_task_distribution_function: Optional[TaskDistributionFunction] = None, training_task_distribution_function: Optional[TaskDistributionFunction] = None): + def set_mixer_config( + self, + *, + real_tasks_count: int = 0, + golden_tasks_count: int = 0, + training_tasks_count: int = 0, + min_real_tasks_count: Optional[int] = None, + min_golden_tasks_count: Optional[int] = None, + min_training_tasks_count: Optional[int] = None, + force_last_assignment: Optional[bool] = None, + force_last_assignment_delay_seconds: Optional[int] = None, + mix_tasks_in_creation_order: Optional[bool] = None, + shuffle_tasks_in_task_suite: Optional[bool] = None, + golden_task_distribution_function: Optional[TaskDistributionFunction] = None, + training_task_distribution_function: Optional[TaskDistributionFunction] = None + ): """A shortcut setter for mixer_config """ ... @@ -303,7 +380,13 @@ class Pool(BaseTolokaObject): ... @overload - def set_owner(self, *, id: Optional[str] = None, myself: Optional[bool] = None, company_id: Optional[str] = None): + def set_owner( + self, + *, + id: Optional[str] = None, + myself: Optional[bool] = None, + company_id: Optional[str] = None + ): """A shortcut setter for owner """ ... @@ -315,7 +398,14 @@ class Pool(BaseTolokaObject): ... @overload - def set_quality_control(self, *, training_requirement: Optional[QualityControl.TrainingRequirement] = None, captcha_frequency: Optional[QualityControl.CaptchaFrequency] = None, configs: Optional[List[QualityControl.QualityControlConfig]] = ..., checkpoints_config: Optional[QualityControl.CheckpointsConfig] = None): + def set_quality_control( + self, + *, + training_requirement: Optional[QualityControl.TrainingRequirement] = None, + captcha_frequency: Optional[QualityControl.CaptchaFrequency] = None, + configs: Optional[List[QualityControl.QualityControlConfig]] = ..., + checkpoints_config: Optional[QualityControl.CheckpointsConfig] = None + ): """A shortcut setter for quality_control """ ... @@ -344,7 +434,12 @@ class Pool(BaseTolokaObject): ... @overload - def set_training_requirement(self, *, training_pool_id: Optional[str] = None, training_passing_skill_value: Optional[int] = None): + def set_training_requirement( + self, + *, + training_pool_id: Optional[str] = None, + training_passing_skill_value: Optional[int] = None + ): """A shortcut setter for quality_control.training_requirement """ ... diff --git a/src/client/pool/dynamic_overlap_config.pyi b/src/client/pool/dynamic_overlap_config.pyi index 99f79a81..668fb076 100644 --- a/src/client/pool/dynamic_overlap_config.pyi +++ b/src/client/pool/dynamic_overlap_config.pyi @@ -54,7 +54,15 @@ class DynamicOverlapConfig(BaseTolokaObject): BASIC = 'BASIC' - def __init__(self, *, type: Optional[Type] = None, max_overlap: Optional[int] = None, min_confidence: Optional[float] = None, answer_weight_skill_id: Optional[str] = None, fields: Optional[List[Field]] = None) -> None: + def __init__( + self, + *, + type: Optional[Type] = None, + max_overlap: Optional[int] = None, + min_confidence: Optional[float] = None, + answer_weight_skill_id: Optional[str] = None, + fields: Optional[List[Field]] = None + ) -> None: """Method generated by attrs for class DynamicOverlapConfig. """ ... diff --git a/src/client/pool/dynamic_pricing_config.pyi b/src/client/pool/dynamic_pricing_config.pyi index 832bd1eb..2dae48d6 100644 --- a/src/client/pool/dynamic_pricing_config.pyi +++ b/src/client/pool/dynamic_pricing_config.pyi @@ -27,7 +27,13 @@ class DynamicPricingConfig(BaseTolokaObject): reward_per_assignment: The price per task page for a performer with the specified skill level. """ - def __init__(self, *, from_: Optional[int] = None, to: Optional[int] = None, reward_per_assignment: Optional[float] = None) -> None: + def __init__( + self, + *, + from_: Optional[int] = None, + to: Optional[int] = None, + reward_per_assignment: Optional[float] = None + ) -> None: """Method generated by attrs for class DynamicPricingConfig.Interval. """ ... @@ -43,7 +49,12 @@ class DynamicPricingConfig(BaseTolokaObject): SKILL = 'SKILL' - def __init__(self, type: Optional[Type] = None, skill_id: Optional[str] = None, intervals: Optional[List[Interval]] = None) -> None: + def __init__( + self, + type: Optional[Type] = None, + skill_id: Optional[str] = None, + intervals: Optional[List[Interval]] = None + ) -> None: """Method generated by attrs for class DynamicPricingConfig. """ ... diff --git a/src/client/pool/mixer_config.pyi b/src/client/pool/mixer_config.pyi index 277865fa..e984f8f5 100644 --- a/src/client/pool/mixer_config.pyi +++ b/src/client/pool/mixer_config.pyi @@ -50,7 +50,22 @@ class MixerConfig(BaseTolokaObject): change the frequency of training tasks as the user completes more tasks. """ - def __init__(self, *, real_tasks_count: Optional[int] = None, golden_tasks_count: Optional[int] = None, training_tasks_count: Optional[int] = None, min_real_tasks_count: Optional[int] = None, min_golden_tasks_count: Optional[int] = None, min_training_tasks_count: Optional[int] = None, force_last_assignment: Optional[bool] = None, force_last_assignment_delay_seconds: Optional[int] = None, mix_tasks_in_creation_order: Optional[bool] = None, shuffle_tasks_in_task_suite: Optional[bool] = None, golden_task_distribution_function: Optional[TaskDistributionFunction] = None, training_task_distribution_function: Optional[TaskDistributionFunction] = None) -> None: + def __init__( + self, + *, + real_tasks_count: int = 0, + golden_tasks_count: int = 0, + training_tasks_count: int = 0, + min_real_tasks_count: Optional[int] = None, + min_golden_tasks_count: Optional[int] = None, + min_training_tasks_count: Optional[int] = None, + force_last_assignment: Optional[bool] = None, + force_last_assignment_delay_seconds: Optional[int] = None, + mix_tasks_in_creation_order: Optional[bool] = None, + shuffle_tasks_in_task_suite: Optional[bool] = None, + golden_task_distribution_function: Optional[TaskDistributionFunction] = None, + training_task_distribution_function: Optional[TaskDistributionFunction] = None + ) -> None: """Method generated by attrs for class MixerConfig. """ ... diff --git a/src/client/primitives/base.pyi b/src/client/primitives/base.pyi index 7dfe8d20..2d86c715 100644 --- a/src/client/primitives/base.pyi +++ b/src/client/primitives/base.pyi @@ -13,11 +13,25 @@ from typing import ( E = TypeVar('E', bound=Enum) class VariantRegistry: - def __init__(self, field: str, enum: Type[E]): ... - - def register(self, type_: type, value: E) -> type: ... - -def attribute(*args, required=False, origin=None, **kwargs): ... + def __init__( + self, + field: str, + enum: Type[E] + ): ... + + def register( + self, + type_: type, + value: E + ) -> type: ... + + +def attribute( + *args, + required=False, + origin=None, + **kwargs +): ... class BaseTolokaObjectMetaclass(type): diff --git a/src/client/primitives/infinite_overlap.pyi b/src/client/primitives/infinite_overlap.pyi index af34d00c..a89cbbf5 100644 --- a/src/client/primitives/infinite_overlap.pyi +++ b/src/client/primitives/infinite_overlap.pyi @@ -15,7 +15,11 @@ class InfiniteOverlapParametersMixin: All other states are considered invalid """ - def __init__(self, infinite_overlap=None, overlap=None) -> None: + def __init__( + self, + infinite_overlap=None, + overlap=None + ) -> None: """Method generated by attrs for class InfiniteOverlapParametersMixin. """ ... diff --git a/src/client/primitives/retry.pyi b/src/client/primitives/retry.pyi index 5315db91..42322116 100644 --- a/src/client/primitives/retry.pyi +++ b/src/client/primitives/retry.pyi @@ -22,11 +22,20 @@ class TolokaRetry(Retry): class Unit: ... - def __init__(self, *args, retry_quotas: Union[List[str], str, None] = 'MIN', **kwargs): ... + def __init__( + self, + *args, + retry_quotas: Union[List[str], str, None] = 'MIN', + **kwargs + ): ... def get_retry_after(self, response: HTTPResponse) -> Optional[float]: ... - def increment(self, *args, **kwargs) -> 'Retry': ... + def increment( + self, + *args, + **kwargs + ) -> 'Retry': ... def new(self, **kwargs): ... diff --git a/src/client/project/__init__.pyi b/src/client/project/__init__.pyi index c321aa0d..ee076cf4 100644 --- a/src/client/project/__init__.pyi +++ b/src/client/project/__init__.pyi @@ -130,7 +130,12 @@ class Project(BaseTolokaObject): description_template: Brief description of the task. Users will see it in the task preview mode. """ - def __init__(self, *, title_template: Optional[str] = None, description_template: Optional[str] = None) -> None: + def __init__( + self, + *, + title_template: Optional[str] = None, + description_template: Optional[str] = None + ) -> None: """Method generated by attrs for class Project.AssignmentsIssuingViewConfig. """ ... @@ -150,7 +155,23 @@ class Project(BaseTolokaObject): ACTIVE = 'ACTIVE' ARCHIVED = 'ARCHIVED' - def __init__(self, *, public_name: Optional[str] = None, public_description: Optional[str] = None, task_spec: Optional[TaskSpec] = None, assignments_issuing_type: Optional[AssignmentsIssuingType] = None, assignments_issuing_view_config: Optional[AssignmentsIssuingViewConfig] = None, assignments_automerge_enabled: Optional[bool] = None, max_active_assignments_count: Optional[int] = None, quality_control: Optional[QualityControl] = None, status: Optional[ProjectStatus] = None, created: Optional[datetime] = None, id: Optional[str] = None, public_instructions: Optional[str] = None, private_comment: Optional[str] = None) -> None: + def __init__( + self, + *, + public_name: Optional[str] = None, + public_description: Optional[str] = None, + task_spec: Optional[TaskSpec] = None, + assignments_issuing_type: AssignmentsIssuingType = ..., + assignments_issuing_view_config: Optional[AssignmentsIssuingViewConfig] = None, + assignments_automerge_enabled: Optional[bool] = None, + max_active_assignments_count: Optional[int] = None, + quality_control: Optional[QualityControl] = None, + status: Optional[ProjectStatus] = None, + created: Optional[datetime] = None, + id: Optional[str] = None, + public_instructions: Optional[str] = None, + private_comment: Optional[str] = None + ) -> None: """Method generated by attrs for class Project. """ ... diff --git a/src/client/project/field_spec.pyi b/src/client/project/field_spec.pyi index 0377032d..b40553ea 100644 --- a/src/client/project/field_spec.pyi +++ b/src/client/project/field_spec.pyi @@ -40,7 +40,12 @@ class FieldSpec(BaseTolokaObject): hidden: Whether or not to hide the input value field from the user """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False + ) -> None: """Method generated by attrs for class FieldSpec. """ ... @@ -59,7 +64,13 @@ class BooleanSpec(FieldSpec): allowed_values: Allowed values """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False, allowed_values: Optional[List[bool]] = None) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False, + allowed_values: Optional[List[bool]] = None + ) -> None: """Method generated by attrs for class BooleanSpec. """ ... @@ -81,7 +92,15 @@ class StringSpec(FieldSpec): allowed_values: Allowed values """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False, min_length: Optional[int] = None, max_length: Optional[int] = None, allowed_values: Optional[List[str]] = None) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False, + min_length: Optional[int] = None, + max_length: Optional[int] = None, + allowed_values: Optional[List[str]] = None + ) -> None: """Method generated by attrs for class StringSpec. """ ... @@ -105,7 +124,15 @@ class IntegerSpec(FieldSpec): allowed_values: Allowed values """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False, min_value: Optional[int] = None, max_value: Optional[int] = None, allowed_values: Optional[List[int]] = None) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False, + min_value: Optional[int] = None, + max_value: Optional[int] = None, + allowed_values: Optional[List[int]] = None + ) -> None: """Method generated by attrs for class IntegerSpec. """ ... @@ -128,7 +155,14 @@ class FloatSpec(FieldSpec): max_value: Maximum value of the number """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False, min_value: Optional[float] = None, max_value: Optional[float] = None) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False, + min_value: Optional[float] = None, + max_value: Optional[float] = None + ) -> None: """Method generated by attrs for class FloatSpec. """ ... @@ -148,7 +182,12 @@ class UrlSpec(FieldSpec): hidden: Whether or not to hide the input value field from the user """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False + ) -> None: """Method generated by attrs for class UrlSpec. """ ... @@ -166,7 +205,12 @@ class FileSpec(FieldSpec): hidden: Whether or not to hide the input value field from the user """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False + ) -> None: """Method generated by attrs for class FileSpec. """ ... @@ -186,7 +230,13 @@ class CoordinatesSpec(FieldSpec): Used in tasks for the mobile app. """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False, current_location: Optional[bool] = None) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False, + current_location: Optional[bool] = None + ) -> None: """Method generated by attrs for class CoordinatesSpec. """ ... @@ -205,7 +255,12 @@ class JsonSpec(FieldSpec): hidden: Whether or not to hide the input value field from the user """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False + ) -> None: """Method generated by attrs for class JsonSpec. """ ... @@ -226,7 +281,15 @@ class ArrayBooleanSpec(BooleanSpec): max_size: Maximum number of elements in the array """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False, allowed_values: Optional[List[bool]] = None, min_size: Optional[int] = None, max_size: Optional[int] = None) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False, + allowed_values: Optional[List[bool]] = None, + min_size: Optional[int] = None, + max_size: Optional[int] = None + ) -> None: """Method generated by attrs for class ArrayBooleanSpec. """ ... @@ -252,7 +315,17 @@ class ArrayStringSpec(StringSpec): max_size: Maximum number of elements in the array """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False, min_length: Optional[int] = None, max_length: Optional[int] = None, allowed_values: Optional[List[str]] = None, min_size: Optional[int] = None, max_size: Optional[int] = None) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False, + min_length: Optional[int] = None, + max_length: Optional[int] = None, + allowed_values: Optional[List[str]] = None, + min_size: Optional[int] = None, + max_size: Optional[int] = None + ) -> None: """Method generated by attrs for class ArrayStringSpec. """ ... @@ -280,7 +353,17 @@ class ArrayIntegerSpec(IntegerSpec): max_size: Maximum number of elements in the array """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False, min_value: Optional[int] = None, max_value: Optional[int] = None, allowed_values: Optional[List[int]] = None, min_size: Optional[int] = None, max_size: Optional[int] = None) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False, + min_value: Optional[int] = None, + max_value: Optional[int] = None, + allowed_values: Optional[List[int]] = None, + min_size: Optional[int] = None, + max_size: Optional[int] = None + ) -> None: """Method generated by attrs for class ArrayIntegerSpec. """ ... @@ -307,7 +390,16 @@ class ArrayFloatSpec(FloatSpec): max_size: Maximum number of elements in the array """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False, min_value: Optional[float] = None, max_value: Optional[float] = None, min_size: Optional[int] = None, max_size: Optional[int] = None) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False, + min_value: Optional[float] = None, + max_value: Optional[float] = None, + min_size: Optional[int] = None, + max_size: Optional[int] = None + ) -> None: """Method generated by attrs for class ArrayFloatSpec. """ ... @@ -331,7 +423,14 @@ class ArrayUrlSpec(UrlSpec): max_size: Maximum number of elements in the array """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False, min_size: Optional[int] = None, max_size: Optional[int] = None) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False, + min_size: Optional[int] = None, + max_size: Optional[int] = None + ) -> None: """Method generated by attrs for class ArrayUrlSpec. """ ... @@ -353,7 +452,14 @@ class ArrayFileSpec(FileSpec): max_size: Maximum number of elements in the array """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False, min_size: Optional[int] = None, max_size: Optional[int] = None) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False, + min_size: Optional[int] = None, + max_size: Optional[int] = None + ) -> None: """Method generated by attrs for class ArrayFileSpec. """ ... @@ -377,7 +483,15 @@ class ArrayCoordinatesSpec(CoordinatesSpec): max_size: Maximum number of elements in the array """ - def __init__(self, *, required: Optional[bool] = True, hidden: Optional[bool] = False, current_location: Optional[bool] = None, min_size: Optional[int] = None, max_size: Optional[int] = None) -> None: + def __init__( + self, + *, + required: Optional[bool] = True, + hidden: Optional[bool] = False, + current_location: Optional[bool] = None, + min_size: Optional[int] = None, + max_size: Optional[int] = None + ) -> None: """Method generated by attrs for class ArrayCoordinatesSpec. """ ... diff --git a/src/client/project/task_spec.pyi b/src/client/project/task_spec.pyi index 65fef113..db8e5213 100644 --- a/src/client/project/task_spec.pyi +++ b/src/client/project/task_spec.pyi @@ -18,7 +18,13 @@ class TaskSpec(BaseTolokaObject): view_spec: Description of the task interface. """ - def __init__(self, *, input_spec: Optional[Dict[str, FieldSpec]] = None, output_spec: Optional[Dict[str, FieldSpec]] = None, view_spec: Optional[ViewSpec] = None) -> None: + def __init__( + self, + *, + input_spec: Optional[Dict[str, FieldSpec]] = None, + output_spec: Optional[Dict[str, FieldSpec]] = None, + view_spec: Optional[ViewSpec] = None + ) -> None: """Method generated by attrs for class TaskSpec. """ ... diff --git a/src/client/project/template_builder/__init__.pyi b/src/client/project/template_builder/__init__.pyi index 5af714fc..09dd1c88 100644 --- a/src/client/project/template_builder/__init__.pyi +++ b/src/client/project/template_builder/__init__.pyi @@ -190,7 +190,13 @@ from typing import ( ) class TemplateBuilder(BaseTolokaObject): - def __init__(self, *, view: Optional[BaseComponent] = None, plugins: Optional[List[BaseComponent]] = None, vars: Optional[Dict[str, Any]] = None) -> None: + def __init__( + self, + *, + view: Optional[BaseComponent] = None, + plugins: Optional[List[BaseComponent]] = None, + vars: Optional[Dict[str, Any]] = None + ) -> None: """Method generated by attrs for class TemplateBuilder. """ ... diff --git a/src/client/project/template_builder/actions.pyi b/src/client/project/template_builder/actions.pyi index 36cdfe4c..076a7799 100644 --- a/src/client/project/template_builder/actions.pyi +++ b/src/client/project/template_builder/actions.pyi @@ -35,7 +35,12 @@ class BulkActionV1(BaseActionV1): payload: An array of actions that you want to call. """ - def __init__(self, *, version: Optional[str] = '1.0.0', payload: Optional[Union[BaseComponent, List[BaseComponent]]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + payload: Optional[Union[BaseComponent, List[BaseComponent]]] = None + ) -> None: """Method generated by attrs for class BulkActionV1. """ ... @@ -81,7 +86,14 @@ class NotifyActionV1(BaseActionV1): SUCCESS = 'success' WARNING = 'warning' - def __init__(self, *, content: Optional[Any] = None, theme: Optional[Union[BaseComponent, Theme]] = None, delay: Optional[Union[BaseComponent, float]] = None, duration: Optional[Union[BaseComponent, float]] = None) -> None: + def __init__( + self, + *, + content: Optional[Any] = None, + theme: Optional[Union[BaseComponent, Theme]] = None, + delay: Optional[Union[BaseComponent, float]] = None, + duration: Optional[Union[BaseComponent, float]] = None + ) -> None: """Method generated by attrs for class NotifyActionV1.Payload. """ ... @@ -92,7 +104,12 @@ class NotifyActionV1(BaseActionV1): delay: Optional[Union[BaseComponent, float]] duration: Optional[Union[BaseComponent, float]] - def __init__(self, *, version: Optional[str] = '1.0.0', payload: Optional[Union[BaseComponent, Payload]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + payload: Optional[Union[BaseComponent, Payload]] = None + ) -> None: """Method generated by attrs for class NotifyActionV1. """ ... @@ -112,7 +129,12 @@ class OpenCloseActionV1(BaseActionV1): view: Points to the component to perform the action with. """ - def __init__(self, *, version: Optional[str] = '1.0.0', view: Optional[Union[BaseComponent, RefComponent]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + view: Optional[Union[BaseComponent, RefComponent]] = None + ) -> None: """Method generated by attrs for class OpenCloseActionV1. """ ... @@ -130,7 +152,12 @@ class OpenLinkActionV1(BaseActionV1): payload: URL of the web page. """ - def __init__(self, *, version: Optional[str] = '1.0.0', payload: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + payload: Optional[Any] = None + ) -> None: """Method generated by attrs for class OpenLinkActionV1. """ ... @@ -150,7 +177,12 @@ class PlayPauseActionV1(BaseActionV1): view: Points to the component that plays audio or video. """ - def __init__(self, *, version: Optional[str] = '1.0.0', view: Optional[Union[BaseComponent, RefComponent]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + view: Optional[Union[BaseComponent, RefComponent]] = None + ) -> None: """Method generated by attrs for class PlayPauseActionV1. """ ... @@ -176,7 +208,13 @@ class RotateActionV1(BaseActionV1): LEFT = 'left' RIGHT = 'right' - def __init__(self, *, version: Optional[str] = '1.0.0', payload: Optional[Union[BaseComponent, Payload]] = None, view: Optional[Union[BaseComponent, RefComponent]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + payload: Optional[Union[BaseComponent, Payload]] = None, + view: Optional[Union[BaseComponent, RefComponent]] = None + ) -> None: """Method generated by attrs for class RotateActionV1. """ ... @@ -195,7 +233,13 @@ class SetActionV1(BaseActionV1): payload: The value to write to the data. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, payload: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + payload: Optional[Any] = None + ) -> None: """Method generated by attrs for class SetActionV1. """ ... @@ -213,7 +257,12 @@ class ToggleActionV1(BaseActionV1): data: Data in which the value will be changed. The data type must be boolean. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None + ) -> None: """Method generated by attrs for class ToggleActionV1. """ ... diff --git a/src/client/project/template_builder/conditions.pyi b/src/client/project/template_builder/conditions.pyi index 8a3c3860..1538a04d 100644 --- a/src/client/project/template_builder/conditions.pyi +++ b/src/client/project/template_builder/conditions.pyi @@ -16,7 +16,12 @@ class BaseConditionV1(VersionedBaseComponent): For example, you can check that a text field is filled in. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None + ) -> None: """Method generated by attrs for class BaseConditionV1. """ ... @@ -57,7 +62,13 @@ class AllConditionV1(BaseConditionV1): ... """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, conditions: Optional[Union[BaseComponent, List[BaseComponent]]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + conditions: Optional[Union[BaseComponent, List[BaseComponent]]] = None + ) -> None: """Method generated by attrs for class AllConditionV1. """ ... @@ -79,7 +90,13 @@ class AnyConditionV1(BaseConditionV1): hint: Validation error message that the user will see. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, conditions: Optional[Union[BaseComponent, List[BaseComponent]]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + conditions: Optional[Union[BaseComponent, List[BaseComponent]]] = None + ) -> None: """Method generated by attrs for class AnyConditionV1. """ ... @@ -114,7 +131,15 @@ class DistanceConditionV1(BaseConditionV1): ... """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, from_: Optional[Union[BaseComponent, str]] = None, to_: Optional[Union[BaseComponent, str]] = None, max: Optional[Union[BaseComponent, float]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + from_: Optional[Union[BaseComponent, str]] = None, + to_: Optional[Union[BaseComponent, str]] = None, + max: Optional[Union[BaseComponent, float]] = None + ) -> None: """Method generated by attrs for class DistanceConditionV1. """ ... @@ -140,7 +165,13 @@ class EmptyConditionV1(BaseConditionV1): hint: Validation error message that the user will see. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, data: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + data: Optional[Any] = None + ) -> None: """Method generated by attrs for class EmptyConditionV1. """ ... @@ -175,7 +206,14 @@ class EqualsConditionV1(BaseConditionV1): * Use helpers and conditions to get the value. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, to: Optional[Any] = None, data: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + to: Optional[Any] = None, + data: Optional[Any] = None + ) -> None: """Method generated by attrs for class EqualsConditionV1. """ ... @@ -199,7 +237,13 @@ class LinkOpenedConditionV1(BaseConditionV1): url: The link that must be clicked. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, url: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + url: Optional[Any] = None + ) -> None: """Method generated by attrs for class LinkOpenedConditionV1. """ ... @@ -219,7 +263,13 @@ class NotConditionV1(BaseConditionV1): hint: Validation error message that the user will see. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, condition: Optional[BaseComponent] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + condition: Optional[BaseComponent] = None + ) -> None: """Method generated by attrs for class NotConditionV1. """ ... @@ -239,7 +289,12 @@ class PlayedConditionV1(BaseConditionV1): hint: Validation error message that the user will see. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None + ) -> None: """Method generated by attrs for class PlayedConditionV1. """ ... @@ -258,7 +313,12 @@ class PlayedFullyConditionV1(BaseConditionV1): hint: Validation error message that the user will see. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None + ) -> None: """Method generated by attrs for class PlayedFullyConditionV1. """ ... @@ -289,7 +349,13 @@ class RequiredConditionV1(BaseConditionV1): ... """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, data: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + data: Optional[Any] = None + ) -> None: """Method generated by attrs for class RequiredConditionV1. """ ... @@ -315,7 +381,14 @@ class SchemaConditionV1(BaseConditionV1): schema: The schema for validating data. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, data: Optional[Any] = None, schema: Optional[Dict] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + data: Optional[Any] = None, + schema: Optional[Dict] = None + ) -> None: """Method generated by attrs for class SchemaConditionV1. """ ... @@ -336,7 +409,14 @@ class SubArrayConditionV1(BaseConditionV1): parent: The array where data is searched for. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, data: Optional[Any] = None, parent: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + data: Optional[Any] = None, + parent: Optional[Any] = None + ) -> None: """Method generated by attrs for class SubArrayConditionV1. """ ... diff --git a/src/client/project/template_builder/data.pyi b/src/client/project/template_builder/data.pyi index 28ef48dd..647b58ad 100644 --- a/src/client/project/template_builder/data.pyi +++ b/src/client/project/template_builder/data.pyi @@ -9,7 +9,12 @@ class BaseData(BaseComponent): """Components used for working with data: input, output, or intermediate. """ - def __init__(self, *, path: Optional[Any] = None, default: Optional[Any] = None) -> None: + def __init__( + self, + *, + path: Optional[Any] = None, + default: Optional[Any] = None + ) -> None: """Method generated by attrs for class BaseData. """ ... @@ -31,7 +36,12 @@ class InputData(BaseData): some placeholders, for example, in the field.text component. """ - def __init__(self, *, path: Optional[Any] = None, default: Optional[Any] = None) -> None: + def __init__( + self, + *, + path: Optional[Any] = None, + default: Optional[Any] = None + ) -> None: """Method generated by attrs for class InputData. """ ... @@ -52,7 +62,12 @@ class InternalData(BaseData): some placeholders, for example, in the field.text component. """ - def __init__(self, *, path: Optional[Any] = None, default: Optional[Any] = None) -> None: + def __init__( + self, + *, + path: Optional[Any] = None, + default: Optional[Any] = None + ) -> None: """Method generated by attrs for class InternalData. """ ... @@ -73,7 +88,12 @@ class LocalData(BaseData): some placeholders, for example, in the field.text component. """ - def __init__(self, *, path: Optional[Any] = None, default: Optional[Any] = None) -> None: + def __init__( + self, + *, + path: Optional[Any] = None, + default: Optional[Any] = None + ) -> None: """Method generated by attrs for class LocalData. """ ... @@ -108,7 +128,12 @@ class OutputData(BaseData): some placeholders, for example, in the field.text component. """ - def __init__(self, *, path: Optional[Any] = None, default: Optional[Any] = None) -> None: + def __init__( + self, + *, + path: Optional[Any] = None, + default: Optional[Any] = None + ) -> None: """Method generated by attrs for class OutputData. """ ... @@ -129,7 +154,12 @@ class RelativeData(BaseData): some placeholders, for example, in the field.text component. """ - def __init__(self, *, path: Optional[Any] = None, default: Optional[Any] = None) -> None: + def __init__( + self, + *, + path: Optional[Any] = None, + default: Optional[Any] = None + ) -> None: """Method generated by attrs for class RelativeData. """ ... diff --git a/src/client/project/template_builder/fields.pyi b/src/client/project/template_builder/fields.pyi index 281bb3c4..4e63dc01 100644 --- a/src/client/project/template_builder/fields.pyi +++ b/src/client/project/template_builder/fields.pyi @@ -18,7 +18,15 @@ class BaseFieldV1(VersionedBaseComponent): """Fields for entering data, such as a text field or drop-down list. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None + ) -> None: """Method generated by attrs for class BaseFieldV1. """ ... @@ -45,7 +53,16 @@ class ButtonRadioFieldV1(BaseFieldV1): value_to_set: The value of the output data when the button is clicked. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, value_to_set: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + value_to_set: Optional[Any] = None + ) -> None: """Method generated by attrs for class ButtonRadioFieldV1. """ ... @@ -68,7 +85,13 @@ class GroupFieldOption(BaseTemplate): value: Returned value. """ - def __init__(self, *, label: Optional[Any] = None, value: Optional[Any] = None, hint: Optional[Any] = None) -> None: + def __init__( + self, + *, + label: Optional[Any] = None, + value: Optional[Any] = None, + hint: Optional[Any] = None + ) -> None: """Method generated by attrs for class GroupFieldOption. """ ... @@ -106,7 +129,16 @@ class ButtonRadioGroupFieldV1(BaseFieldV1): ... """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] = None + ) -> None: """Method generated by attrs for class ButtonRadioGroupFieldV1. """ ... @@ -134,7 +166,17 @@ class CheckboxFieldV1(BaseFieldV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, disabled: Optional[Union[BaseComponent, bool]] = None, preserve_false: Optional[Union[BaseComponent, bool]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + disabled: Optional[Union[BaseComponent, bool]] = None, + preserve_false: Optional[Union[BaseComponent, bool]] = None + ) -> None: """Method generated by attrs for class CheckboxFieldV1. """ ... @@ -164,7 +206,18 @@ class CheckboxGroupFieldV1(BaseFieldV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] = None, disabled: Optional[Union[BaseComponent, bool]] = None, preserve_false: Optional[Union[BaseComponent, bool]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] = None, + disabled: Optional[Union[BaseComponent, bool]] = None, + preserve_false: Optional[Union[BaseComponent, bool]] = None + ) -> None: """Method generated by attrs for class CheckboxGroupFieldV1. """ ... @@ -209,7 +262,20 @@ class DateFieldV1(BaseFieldV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, format: Optional[Any] = None, block_list: Optional[Union[BaseComponent, List[Any]]] = None, max: Optional[Any] = None, min: Optional[Any] = None, placeholder: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + format: Optional[Any] = None, + block_list: Optional[Union[BaseComponent, List[Any]]] = None, + max: Optional[Any] = None, + min: Optional[Any] = None, + placeholder: Optional[Any] = None + ) -> None: """Method generated by attrs for class DateFieldV1. """ ... @@ -239,7 +305,16 @@ class EmailFieldV1(BaseFieldV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, placeholder: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + placeholder: Optional[Any] = None + ) -> None: """Method generated by attrs for class EmailFieldV1. """ ... @@ -274,7 +349,17 @@ class FileFieldV1(BaseFieldV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, accept: Optional[Union[BaseComponent, List[Union[BaseComponent, str]]]] = None, multiple: Optional[Union[BaseComponent, bool]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + accept: Optional[Union[BaseComponent, List[Union[BaseComponent, str]]]] = None, + multiple: Optional[Union[BaseComponent, bool]] = None + ) -> None: """Method generated by attrs for class FileFieldV1. """ ... @@ -331,7 +416,12 @@ class ImageAnnotationFieldV1(BaseFieldV1): selecting areas. """ - def __init__(self, *, label: Optional[Union[BaseComponent, str]] = None, value: Optional[Union[BaseComponent, str]] = None) -> None: + def __init__( + self, + *, + label: Optional[Union[BaseComponent, str]] = None, + value: Optional[Union[BaseComponent, str]] = None + ) -> None: """Method generated by attrs for class ImageAnnotationFieldV1.Label. """ ... @@ -348,7 +438,22 @@ class ImageAnnotationFieldV1(BaseFieldV1): POLYGON = 'polygon' RECTANGLE = 'rectangle' - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, disabled: Optional[Union[BaseComponent, bool]] = None, full_height: Optional[Union[BaseComponent, bool]] = None, image: Optional[Union[BaseComponent, str]] = None, labels: Optional[Union[BaseComponent, List[Union[BaseComponent, Label]]]] = None, min_width: Optional[Union[BaseComponent, float]] = None, ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None, shapes: Optional[Union[BaseComponent, Dict[Union[BaseComponent, Shape], Union[BaseComponent, bool]]]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + disabled: Optional[Union[BaseComponent, bool]] = None, + full_height: Optional[Union[BaseComponent, bool]] = None, + image: Optional[Union[BaseComponent, str]] = None, + labels: Optional[Union[BaseComponent, List[Union[BaseComponent, Label]]]] = None, + min_width: Optional[Union[BaseComponent, float]] = None, + ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None, + shapes: Optional[Union[BaseComponent, Dict[Union[BaseComponent, Shape], Union[BaseComponent, bool]]]] = None + ) -> None: """Method generated by attrs for class ImageAnnotationFieldV1. """ ... @@ -397,7 +502,21 @@ class ListFieldV1(BaseFieldV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, render: Optional[BaseComponent] = None, button_label: Optional[Any] = None, direction: Optional[Union[BaseComponent, ListDirection]] = None, editable: Optional[Any] = None, max_length: Optional[Union[BaseComponent, float]] = None, size: Optional[Union[BaseComponent, ListSize]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + render: Optional[BaseComponent] = None, + button_label: Optional[Any] = None, + direction: Optional[Union[BaseComponent, ListDirection]] = None, + editable: Optional[Any] = None, + max_length: Optional[Union[BaseComponent, float]] = None, + size: Optional[Union[BaseComponent, ListSize]] = None + ) -> None: """Method generated by attrs for class ListFieldV1. """ ... @@ -455,7 +574,14 @@ class MediaFileFieldV1(BaseFieldV1): video: Adds a button for uploading videos. """ - def __init__(self, *, file_system: Optional[Union[BaseComponent, bool]] = None, gallery: Optional[Union[BaseComponent, bool]] = None, photo: Optional[Union[BaseComponent, bool]] = None, video: Optional[Union[BaseComponent, bool]] = None) -> None: + def __init__( + self, + *, + file_system: Optional[Union[BaseComponent, bool]] = None, + gallery: Optional[Union[BaseComponent, bool]] = None, + photo: Optional[Union[BaseComponent, bool]] = None, + video: Optional[Union[BaseComponent, bool]] = None + ) -> None: """Method generated by attrs for class MediaFileFieldV1.Accept. """ ... @@ -466,7 +592,17 @@ class MediaFileFieldV1(BaseFieldV1): photo: Optional[Union[BaseComponent, bool]] video: Optional[Union[BaseComponent, bool]] - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, accept: Optional[Union[BaseComponent, Accept]] = None, multiple: Optional[Union[BaseComponent, bool]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + accept: Optional[Union[BaseComponent, Accept]] = None, + multiple: Optional[Union[BaseComponent, bool]] = None + ) -> None: """Method generated by attrs for class MediaFileFieldV1. """ ... @@ -502,7 +638,18 @@ class NumberFieldV1(BaseFieldV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, maximum: Optional[Union[BaseComponent, int]] = None, minimum: Optional[Union[BaseComponent, int]] = None, placeholder: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + maximum: Optional[Union[BaseComponent, int]] = None, + minimum: Optional[Union[BaseComponent, int]] = None, + placeholder: Optional[Any] = None + ) -> None: """Method generated by attrs for class NumberFieldV1. """ ... @@ -531,7 +678,16 @@ class PhoneNumberFieldV1(BaseFieldV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, placeholder: Optional[Union[BaseComponent, str]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + placeholder: Optional[Union[BaseComponent, str]] = None + ) -> None: """Method generated by attrs for class PhoneNumberFieldV1. """ ... @@ -574,7 +730,17 @@ class RadioGroupFieldV1(BaseFieldV1): ... """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] = None, disabled: Optional[Union[BaseComponent, bool]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] = None, + disabled: Optional[Union[BaseComponent, bool]] = None + ) -> None: """Method generated by attrs for class RadioGroupFieldV1. """ ... @@ -615,7 +781,12 @@ class SelectFieldV1(BaseFieldV1): value: The value to write to the data in the data property. """ - def __init__(self, *, label: Optional[Any] = None, value: Optional[Any] = None) -> None: + def __init__( + self, + *, + label: Optional[Any] = None, + value: Optional[Any] = None + ) -> None: """Method generated by attrs for class SelectFieldV1.Option. """ ... @@ -624,7 +795,17 @@ class SelectFieldV1(BaseFieldV1): label: Optional[Any] value: Optional[Any] - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, options: Optional[Union[BaseComponent, Option]] = None, placeholder: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + options: Optional[Union[BaseComponent, Option]] = None, + placeholder: Optional[Any] = None + ) -> None: """Method generated by attrs for class SelectFieldV1. """ ... @@ -651,7 +832,17 @@ class TextFieldV1(BaseFieldV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, disabled: Optional[Union[BaseComponent, bool]] = None, placeholder: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + disabled: Optional[Union[BaseComponent, bool]] = None, + placeholder: Optional[Any] = None + ) -> None: """Method generated by attrs for class TextFieldV1. """ ... @@ -687,7 +878,19 @@ class TextareaFieldV1(BaseFieldV1): rows: The height of the text box in lines. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, disabled: Optional[Union[BaseComponent, bool]] = None, placeholder: Optional[Any] = None, resizable: Optional[Union[BaseComponent, bool]] = None, rows: Optional[Union[BaseComponent, float]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[BaseComponent] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + disabled: Optional[Union[BaseComponent, bool]] = None, + placeholder: Optional[Any] = None, + resizable: Optional[Union[BaseComponent, bool]] = None, + rows: Optional[Union[BaseComponent, float]] = None + ) -> None: """Method generated by attrs for class TextareaFieldV1. """ ... diff --git a/src/client/project/template_builder/helpers.pyi b/src/client/project/template_builder/helpers.pyi index 8fa64bc9..841981e7 100644 --- a/src/client/project/template_builder/helpers.pyi +++ b/src/client/project/template_builder/helpers.pyi @@ -36,7 +36,12 @@ class ConcatArraysHelperV1(BaseHelperV1): items: Arrays to combine. """ - def __init__(self, *, version: Optional[str] = '1.0.0', items: Optional[Union[BaseComponent, List[Any]]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + items: Optional[Union[BaseComponent, List[Any]]] = None + ) -> None: """Method generated by attrs for class ConcatArraysHelperV1. """ ... @@ -67,7 +72,12 @@ class Entries2ObjectHelperV1(BaseHelperV1): """ class Entry(BaseTemplate): - def __init__(self, *, key: Optional[Union[BaseComponent, str]] = None, value: Optional[Any] = None) -> None: + def __init__( + self, + *, + key: Optional[Union[BaseComponent, str]] = None, + value: Optional[Any] = None + ) -> None: """Method generated by attrs for class Entries2ObjectHelperV1.Entry. """ ... @@ -76,7 +86,12 @@ class Entries2ObjectHelperV1(BaseHelperV1): key: Optional[Union[BaseComponent, str]] value: Optional[Any] - def __init__(self, *, version: Optional[str] = '1.0.0', entries: Optional[Union[BaseComponent, List[Union[BaseComponent, Entry]]]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + entries: Optional[Union[BaseComponent, List[Union[BaseComponent, Entry]]]] = None + ) -> None: """Method generated by attrs for class Entries2ObjectHelperV1. """ ... @@ -113,7 +128,14 @@ class IfHelperV1(BaseHelperV1): ... """ - def __init__(self, *, version: Optional[str] = '1.0.0', condition: Optional[BaseComponent] = None, then: Optional[Any] = None, else_: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + condition: Optional[BaseComponent] = None, + then: Optional[Any] = None, + else_: Optional[Any] = None + ) -> None: """Method generated by attrs for class IfHelperV1. """ ... @@ -134,7 +156,13 @@ class JoinHelperV1(BaseHelperV1): items: Array of strings to join. """ - def __init__(self, *, version: Optional[str] = '1.0.0', items: Optional[Union[BaseComponent, List[Union[BaseComponent, str]]]] = None, by: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + items: Optional[Union[BaseComponent, List[Union[BaseComponent, str]]]] = None, + by: Optional[Any] = None + ) -> None: """Method generated by attrs for class JoinHelperV1. """ ... @@ -168,7 +196,12 @@ class Object2EntriesHelperV1(BaseHelperV1): data: The object to convert. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[Any] = None + ) -> None: """Method generated by attrs for class Object2EntriesHelperV1. """ ... @@ -190,7 +223,14 @@ class ReplaceHelperV1(BaseHelperV1): replace: The value to insert in place of the matches of the find value. """ - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[Any] = None, find: Optional[Union[BaseComponent, str]] = None, replace: Optional[Union[BaseComponent, str]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[Any] = None, + find: Optional[Union[BaseComponent, str]] = None, + replace: Optional[Union[BaseComponent, str]] = None + ) -> None: """Method generated by attrs for class ReplaceHelperV1. """ ... @@ -227,7 +267,13 @@ class SearchQueryHelperV1(BaseHelperV1): YANDEX_NEWS = 'yandex/news' GOOGLE_NEWS = 'google/news' - def __init__(self, *, version: Optional[str] = '1.0.0', query: Optional[Any] = None, engine: Optional[Union[BaseComponent, Engine]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + query: Optional[Any] = None, + engine: Optional[Union[BaseComponent, Engine]] = None + ) -> None: """Method generated by attrs for class SearchQueryHelperV1. """ ... @@ -270,7 +316,12 @@ class SwitchHelperV1(BaseHelperV1): result: The element that is returned if the condition from the condition property is true (returns true). """ - def __init__(self, *, condition: Optional[BaseComponent] = None, result: Optional[Any] = None) -> None: + def __init__( + self, + *, + condition: Optional[BaseComponent] = None, + result: Optional[Any] = None + ) -> None: """Method generated by attrs for class SwitchHelperV1.Case. """ ... @@ -279,7 +330,13 @@ class SwitchHelperV1(BaseHelperV1): condition: Optional[BaseComponent] result: Optional[Any] - def __init__(self, *, version: Optional[str] = '1.0.0', cases: Optional[Union[BaseComponent, List[Union[BaseComponent, Case]]]] = None, default: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + cases: Optional[Union[BaseComponent, List[Union[BaseComponent, Case]]]] = None, + default: Optional[Any] = None + ) -> None: """Method generated by attrs for class SwitchHelperV1. """ ... @@ -310,7 +367,13 @@ class TextTransformHelperV1(BaseHelperV1): LOWERCASE = 'lowercase' CAPITALIZE = 'capitalize' - def __init__(self, *, version: Optional[str] = '1.0.0', data: Optional[Any] = None, transformation: Optional[Union[BaseComponent, Transformation]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + data: Optional[Any] = None, + transformation: Optional[Union[BaseComponent, Transformation]] = None + ) -> None: """Method generated by attrs for class TextTransformHelperV1. """ ... @@ -336,7 +399,13 @@ class TransformHelperV1(BaseHelperV1): * Use a reference to another configuration element. Example: {"$ref": "vars.myarray"}. """ - def __init__(self, *, version: Optional[str] = '1.0.0', into: Optional[Any] = None, items: Optional[Union[BaseComponent, List[Any]]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + into: Optional[Any] = None, + items: Optional[Union[BaseComponent, List[Any]]] = None + ) -> None: """Method generated by attrs for class TransformHelperV1. """ ... @@ -358,7 +427,12 @@ class YandexDiskProxyHelperV1(BaseHelperV1): path: Path to the file in the /<Proxy name>/<File name>.<type> format """ - def __init__(self, *, version: Optional[str] = '1.0.0', path: Optional[Union[BaseComponent, str]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + path: Optional[Union[BaseComponent, str]] = None + ) -> None: """Method generated by attrs for class YandexDiskProxyHelperV1. """ ... diff --git a/src/client/project/template_builder/layouts.pyi b/src/client/project/template_builder/layouts.pyi index add1b66c..fd2a65ab 100644 --- a/src/client/project/template_builder/layouts.pyi +++ b/src/client/project/template_builder/layouts.pyi @@ -17,7 +17,12 @@ class BaseLayoutV1(VersionedBaseComponent): If you have more than one element in the interface, these components will help you arrange them the way you want. """ - def __init__(self, *, version: Optional[str] = '1.0.0', validation: Optional[BaseComponent] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + validation: Optional[BaseComponent] = None + ) -> None: """Method generated by attrs for class BaseLayoutV1. """ ... @@ -41,7 +46,15 @@ class BarsLayoutV1(BaseLayoutV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', validation: Optional[BaseComponent] = None, content: Optional[BaseComponent] = None, bar_after: Optional[BaseComponent] = None, bar_before: Optional[BaseComponent] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + validation: Optional[BaseComponent] = None, + content: Optional[BaseComponent] = None, + bar_after: Optional[BaseComponent] = None, + bar_before: Optional[BaseComponent] = None + ) -> None: """Method generated by attrs for class BarsLayoutV1. """ ... @@ -87,7 +100,17 @@ class ColumnsLayoutV1(BaseLayoutV1): MIDDLE = 'middle' TOP = 'top' - def __init__(self, *, version: Optional[str] = '1.0.0', validation: Optional[BaseComponent] = None, items: Optional[Union[BaseComponent, List[BaseComponent]]] = None, full_height: Optional[Union[BaseComponent, bool]] = None, min_width: Optional[Union[BaseComponent, float]] = None, ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None, vertical_align: Optional[Union[BaseComponent, VerticalAlign]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + validation: Optional[BaseComponent] = None, + items: Optional[Union[BaseComponent, List[BaseComponent]]] = None, + full_height: Optional[Union[BaseComponent, bool]] = None, + min_width: Optional[Union[BaseComponent, float]] = None, + ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None, + vertical_align: Optional[Union[BaseComponent, VerticalAlign]] = None + ) -> None: """Method generated by attrs for class ColumnsLayoutV1. """ ... @@ -116,7 +139,15 @@ class SideBySideLayoutV1(BaseLayoutV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', validation: Optional[BaseComponent] = None, controls: Optional[BaseComponent] = None, items: Optional[Union[BaseComponent, List[BaseComponent]]] = None, min_item_width: Optional[Union[BaseComponent, float]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + validation: Optional[BaseComponent] = None, + controls: Optional[BaseComponent] = None, + items: Optional[Union[BaseComponent, List[BaseComponent]]] = None, + min_item_width: Optional[Union[BaseComponent, float]] = None + ) -> None: """Method generated by attrs for class SideBySideLayoutV1. """ ... @@ -154,7 +185,17 @@ class SidebarLayoutV1(BaseLayoutV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', validation: Optional[BaseComponent] = None, content: Optional[BaseComponent] = None, controls: Optional[BaseComponent] = None, controls_width: Optional[Union[BaseComponent, float]] = None, extra_controls: Optional[BaseComponent] = None, min_width: Optional[Union[BaseComponent, float]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + validation: Optional[BaseComponent] = None, + content: Optional[BaseComponent] = None, + controls: Optional[BaseComponent] = None, + controls_width: Optional[Union[BaseComponent, float]] = None, + extra_controls: Optional[BaseComponent] = None, + min_width: Optional[Union[BaseComponent, float]] = None + ) -> None: """Method generated by attrs for class SidebarLayoutV1. """ ... diff --git a/src/client/project/template_builder/plugins.pyi b/src/client/project/template_builder/plugins.pyi index a97d61d1..286a521f 100644 --- a/src/client/project/template_builder/plugins.pyi +++ b/src/client/project/template_builder/plugins.pyi @@ -10,7 +10,7 @@ from typing import ( List, Optional, Union, - overload, + overload ) class BasePluginV1(VersionedBaseComponent): @@ -44,7 +44,49 @@ class HotkeysPluginV1(BasePluginV1): ... """ - def __init__(self, *, version: Optional[str] = '1.0.0', key_a: Optional[Any] = None, key_b: Optional[Any] = None, key_c: Optional[Any] = None, key_d: Optional[Any] = None, key_e: Optional[Any] = None, key_f: Optional[Any] = None, key_g: Optional[Any] = None, key_h: Optional[Any] = None, key_i: Optional[Any] = None, key_j: Optional[Any] = None, key_k: Optional[Any] = None, key_l: Optional[Any] = None, key_m: Optional[Any] = None, key_n: Optional[Any] = None, key_o: Optional[Any] = None, key_p: Optional[Any] = None, key_q: Optional[Any] = None, key_r: Optional[Any] = None, key_s: Optional[Any] = None, key_t: Optional[Any] = None, key_u: Optional[Any] = None, key_v: Optional[Any] = None, key_w: Optional[Any] = None, key_x: Optional[Any] = None, key_y: Optional[Any] = None, key_z: Optional[Any] = None, key_0: Optional[Any] = None, key_1: Optional[Any] = None, key_2: Optional[Any] = None, key_3: Optional[Any] = None, key_4: Optional[Any] = None, key_5: Optional[Any] = None, key_6: Optional[Any] = None, key_7: Optional[Any] = None, key_8: Optional[Any] = None, key_9: Optional[Any] = None, key_up: Optional[Any] = None, key_down: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + key_a: Optional[Any] = None, + key_b: Optional[Any] = None, + key_c: Optional[Any] = None, + key_d: Optional[Any] = None, + key_e: Optional[Any] = None, + key_f: Optional[Any] = None, + key_g: Optional[Any] = None, + key_h: Optional[Any] = None, + key_i: Optional[Any] = None, + key_j: Optional[Any] = None, + key_k: Optional[Any] = None, + key_l: Optional[Any] = None, + key_m: Optional[Any] = None, + key_n: Optional[Any] = None, + key_o: Optional[Any] = None, + key_p: Optional[Any] = None, + key_q: Optional[Any] = None, + key_r: Optional[Any] = None, + key_s: Optional[Any] = None, + key_t: Optional[Any] = None, + key_u: Optional[Any] = None, + key_v: Optional[Any] = None, + key_w: Optional[Any] = None, + key_x: Optional[Any] = None, + key_y: Optional[Any] = None, + key_z: Optional[Any] = None, + key_0: Optional[Any] = None, + key_1: Optional[Any] = None, + key_2: Optional[Any] = None, + key_3: Optional[Any] = None, + key_4: Optional[Any] = None, + key_5: Optional[Any] = None, + key_6: Optional[Any] = None, + key_7: Optional[Any] = None, + key_8: Optional[Any] = None, + key_9: Optional[Any] = None, + key_up: Optional[Any] = None, + key_down: Optional[Any] = None + ) -> None: """Method generated by attrs for class HotkeysPluginV1. """ ... @@ -119,7 +161,15 @@ class TriggerPluginV1(BasePluginV1): ... """ - def __init__(self, *, version: Optional[str] = '1.0.0', action: Optional[BaseComponent] = None, condition: Optional[BaseComponent] = None, fire_immediately: Optional[Union[BaseComponent, bool]] = None, on_change_of: Optional[BaseComponent] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + action: Optional[BaseComponent] = None, + condition: Optional[BaseComponent] = None, + fire_immediately: Optional[Union[BaseComponent, bool]] = None, + on_change_of: Optional[BaseComponent] = None + ) -> None: """Method generated by attrs for class TriggerPluginV1. """ ... @@ -136,8 +186,6 @@ class TolokaPluginV1(BasePluginV1): """A plugin with extra settings for tasks in Toloka. Attributes: - kind: Layout direction. - task_width: Width of the block with the task. By default, the task is displayed at full width. layout: Settings for the task appearance in Toloka. notifications: Notifications shown at the top of the page. @@ -145,21 +193,14 @@ class TolokaPluginV1(BasePluginV1): How to set the task width on the task page. >>> task_width_plugin = tb.plugins.TolokaPluginV1( - >>> layout = tb.plugins.TolokaPluginV1.TolokaPluginLayout( - >>> kind='scroll', - >>> task_width=400, - >>> ) + >>> kind='scroll', + >>> task_width=400, >>> ) ... """ class TolokaPluginLayout(BaseTemplate): """How to display task. - - Attributes: - kind: Layout direction. - task_width: Width of the block with the task. By default, the task is displayed at full width. - """ class Kind(Enum): @@ -173,7 +214,12 @@ class TolokaPluginV1(BasePluginV1): PAGER = 'pager' SCROLL = 'scroll' - def __init__(self, *, kind: Optional[Kind] = ..., task_width: Optional[float] = None) -> None: + def __init__( + self, + *, + kind: Optional[Kind] = None, + task_width: Optional[float] = None + ) -> None: """Method generated by attrs for class TolokaPluginV1.TolokaPluginLayout. """ ... @@ -183,13 +229,26 @@ class TolokaPluginV1(BasePluginV1): task_width: Optional[float] @overload - def __init__(self, *, version: Optional[str] = '1.0.0', kind: Optional[TolokaPluginLayout.Kind] = None, task_width: Optional[float] = None, notifications: Optional[Union[BaseComponent, List[BaseComponent]]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + kind: Optional[TolokaPluginLayout.Kind] = None, + task_width: Optional[float] = None, + notifications: Optional[Union[BaseComponent, List[BaseComponent]]] = None + ) -> None: """Method generated by attrs for class TolokaPluginV1. """ ... @overload - def __init__(self, *, version: Optional[str] = '1.0.0', layout: Optional[Union[BaseComponent, TolokaPluginLayout]] = ..., notifications: Optional[Union[BaseComponent, List[BaseComponent]]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + layout: Optional[Union[BaseComponent, TolokaPluginLayout]] = ..., + notifications: Optional[Union[BaseComponent, List[BaseComponent]]] = None + ) -> None: """Method generated by attrs for class TolokaPluginV1. """ ... diff --git a/src/client/project/template_builder/view.pyi b/src/client/project/template_builder/view.pyi index 8a26b293..e5ecc099 100644 --- a/src/client/project/template_builder/view.pyi +++ b/src/client/project/template_builder/view.pyi @@ -18,7 +18,14 @@ class BaseViewV1(VersionedBaseComponent): """Elements displayed in the interface, such as text, list, audio player, or image. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None + ) -> None: """Method generated by attrs for class BaseViewV1. """ ... @@ -41,7 +48,15 @@ class ActionButtonViewV1(BaseViewV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, action: Optional[BaseComponent] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + action: Optional[BaseComponent] = None + ) -> None: """Method generated by attrs for class ActionButtonViewV1. """ ... @@ -81,7 +96,16 @@ class AlertViewV1(BaseViewV1): SUCCESS = 'success' WARNING = 'warning' - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, content: Optional[BaseComponent] = None, theme: Optional[Union[BaseComponent, Theme]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + content: Optional[BaseComponent] = None, + theme: Optional[Union[BaseComponent, Theme]] = None + ) -> None: """Method generated by attrs for class AlertViewV1. """ ... @@ -107,7 +131,16 @@ class AudioViewV1(BaseViewV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, url: Optional[Any] = None, loop: Optional[Union[BaseComponent, bool]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + url: Optional[Any] = None, + loop: Optional[Union[BaseComponent, bool]] = None + ) -> None: """Method generated by attrs for class AudioViewV1. """ ... @@ -138,7 +171,16 @@ class CollapseViewV1(BaseViewV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, content: Optional[BaseComponent] = None, default_opened: Optional[Union[BaseComponent, bool]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + content: Optional[BaseComponent] = None, + default_opened: Optional[Union[BaseComponent, bool]] = None + ) -> None: """Method generated by attrs for class CollapseViewV1. """ ... @@ -169,7 +211,19 @@ class DeviceFrameViewV1(BaseViewV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, content: Optional[BaseComponent] = None, full_height: Optional[Union[BaseComponent, bool]] = None, max_width: Optional[Union[BaseComponent, float]] = None, min_width: Optional[Union[BaseComponent, float]] = None, ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + content: Optional[BaseComponent] = None, + full_height: Optional[Union[BaseComponent, bool]] = None, + max_width: Optional[Union[BaseComponent, float]] = None, + min_width: Optional[Union[BaseComponent, float]] = None, + ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None + ) -> None: """Method generated by attrs for class DeviceFrameViewV1. """ ... @@ -196,7 +250,14 @@ class DividerViewV1(BaseViewV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None + ) -> None: """Method generated by attrs for class DividerViewV1. """ ... @@ -219,7 +280,15 @@ class GroupViewV1(BaseViewV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, content: Optional[BaseComponent] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + content: Optional[BaseComponent] = None + ) -> None: """Method generated by attrs for class GroupViewV1. """ ... @@ -247,7 +316,19 @@ class IframeViewV1(BaseViewV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, url: Optional[Union[BaseComponent, str]] = None, full_height: Optional[Union[BaseComponent, bool]] = None, max_width: Optional[Union[BaseComponent, float]] = None, min_width: Optional[Union[BaseComponent, float]] = None, ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + url: Optional[Union[BaseComponent, str]] = None, + full_height: Optional[Union[BaseComponent, bool]] = None, + max_width: Optional[Union[BaseComponent, float]] = None, + min_width: Optional[Union[BaseComponent, float]] = None, + ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None + ) -> None: """Method generated by attrs for class IframeViewV1. """ ... @@ -290,7 +371,24 @@ class ImageViewV1(BaseViewV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, url: Optional[Any] = None, full_height: Optional[Union[BaseComponent, bool]] = None, max_width: Optional[Union[BaseComponent, float]] = None, min_width: Optional[Union[BaseComponent, float]] = None, no_border: Optional[Union[BaseComponent, bool]] = None, no_lazy_load: Optional[Union[BaseComponent, bool]] = None, popup: Optional[Union[BaseComponent, bool]] = None, ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None, rotatable: Optional[Union[BaseComponent, bool]] = None, scrollable: Optional[Union[BaseComponent, bool]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + url: Optional[Any] = None, + full_height: Optional[Union[BaseComponent, bool]] = None, + max_width: Optional[Union[BaseComponent, float]] = None, + min_width: Optional[Union[BaseComponent, float]] = None, + no_border: Optional[Union[BaseComponent, bool]] = None, + no_lazy_load: Optional[Union[BaseComponent, bool]] = None, + popup: Optional[Union[BaseComponent, bool]] = None, + ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None, + rotatable: Optional[Union[BaseComponent, bool]] = None, + scrollable: Optional[Union[BaseComponent, bool]] = None + ) -> None: """Method generated by attrs for class ImageViewV1. """ ... @@ -337,7 +435,14 @@ class LabeledListViewV1(BaseViewV1): label: A label displayed next to a list item. """ - def __init__(self, *, content: Optional[BaseComponent] = None, label: Optional[Any] = None, center_label: Optional[Union[BaseComponent, bool]] = None, hint: Optional[Any] = None) -> None: + def __init__( + self, + *, + content: Optional[BaseComponent] = None, + label: Optional[Any] = None, + center_label: Optional[Union[BaseComponent, bool]] = None, + hint: Optional[Any] = None + ) -> None: """Method generated by attrs for class LabeledListViewV1.Item. """ ... @@ -348,7 +453,16 @@ class LabeledListViewV1(BaseViewV1): center_label: Optional[Union[BaseComponent, bool]] hint: Optional[Any] - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, items: Optional[Union[BaseComponent, List[Union[BaseComponent, Item]]]] = None, min_width: Optional[Union[BaseComponent, float]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + items: Optional[Union[BaseComponent, List[Union[BaseComponent, Item]]]] = None, + min_width: Optional[Union[BaseComponent, float]] = None + ) -> None: """Method generated by attrs for class LabeledListViewV1. """ ... @@ -380,7 +494,16 @@ class LinkViewV1(BaseViewV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, url: Optional[Any] = None, content: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + url: Optional[Any] = None, + content: Optional[Any] = None + ) -> None: """Method generated by attrs for class LinkViewV1. """ ... @@ -433,7 +556,13 @@ class LinkGroupViewV1(BaseViewV1): url: Link address """ - def __init__(self, *, content: Optional[Union[BaseComponent, str]] = None, theme: Optional[Union[BaseComponent, str]] = None, url: Optional[Union[BaseComponent, str]] = None) -> None: + def __init__( + self, + *, + content: Optional[Union[BaseComponent, str]] = None, + theme: Optional[Union[BaseComponent, str]] = None, + url: Optional[Union[BaseComponent, str]] = None + ) -> None: """Method generated by attrs for class LinkGroupViewV1.Link. """ ... @@ -443,7 +572,15 @@ class LinkGroupViewV1(BaseViewV1): theme: Optional[Union[BaseComponent, str]] url: Optional[Union[BaseComponent, str]] - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, links: Optional[Union[BaseComponent, List[Union[BaseComponent, Link]]]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + links: Optional[Union[BaseComponent, List[Union[BaseComponent, Link]]]] = None + ) -> None: """Method generated by attrs for class LinkGroupViewV1. """ ... @@ -469,7 +606,17 @@ class ListViewV1(BaseViewV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, items: Optional[Union[BaseComponent, List[BaseComponent]]] = None, direction: Optional[Union[BaseComponent, ListDirection]] = None, size: Optional[Union[BaseComponent, ListSize]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + items: Optional[Union[BaseComponent, List[BaseComponent]]] = None, + direction: Optional[Union[BaseComponent, ListDirection]] = None, + size: Optional[Union[BaseComponent, ListSize]] = None + ) -> None: """Method generated by attrs for class ListViewV1. """ ... @@ -511,7 +658,15 @@ class MarkdownViewV1(BaseViewV1): ... """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, content: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + content: Optional[Any] = None + ) -> None: """Method generated by attrs for class MarkdownViewV1. """ ... @@ -542,7 +697,15 @@ class TextViewV1(BaseViewV1): ... """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, content: Optional[Any] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + content: Optional[Any] = None + ) -> None: """Method generated by attrs for class TextViewV1. """ ... @@ -576,7 +739,17 @@ class VideoViewV1(BaseViewV1): validation: Validation based on condition. """ - def __init__(self, *, version: Optional[str] = '1.0.0', hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, full_height: Optional[Union[BaseComponent, bool]] = None, max_width: Optional[Union[BaseComponent, float]] = None, min_width: Optional[Union[BaseComponent, float]] = None) -> None: + def __init__( + self, + *, + version: Optional[str] = '1.0.0', + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + full_height: Optional[Union[BaseComponent, bool]] = None, + max_width: Optional[Union[BaseComponent, float]] = None, + min_width: Optional[Union[BaseComponent, float]] = None + ) -> None: """Method generated by attrs for class VideoViewV1. """ ... diff --git a/src/client/project/view_spec.pyi b/src/client/project/view_spec.pyi index a6000e8b..c50b5933 100644 --- a/src/client/project/view_spec.pyi +++ b/src/client/project/view_spec.pyi @@ -2,12 +2,12 @@ from enum import Enum from toloka.client.primitives.base import BaseTolokaObject from toloka.client.project.template_builder import TemplateBuilder from toloka.client.project.template_builder.base import BaseComponent - from typing import ( Any, Dict, List, - Optional + Optional, + overload ) class ViewSpec(BaseTolokaObject): @@ -29,7 +29,19 @@ class ViewSpec(BaseTolokaObject): show_title: Show the project name in task titles. """ - def __init__(self, *, show_finish: Optional[bool] = None, show_fullscreen: Optional[bool] = None, show_instructions: Optional[bool] = None, show_message: Optional[bool] = None, show_reward: Optional[bool] = None, show_skip: Optional[bool] = None, show_submit: Optional[bool] = None, show_timer: Optional[bool] = None, show_title: Optional[bool] = None) -> None: + def __init__( + self, + *, + show_finish: Optional[bool] = None, + show_fullscreen: Optional[bool] = None, + show_instructions: Optional[bool] = None, + show_message: Optional[bool] = None, + show_reward: Optional[bool] = None, + show_skip: Optional[bool] = None, + show_submit: Optional[bool] = None, + show_timer: Optional[bool] = None, + show_title: Optional[bool] = None + ) -> None: """Method generated by attrs for class ViewSpec.Settings. """ ... @@ -74,7 +86,7 @@ class ClassicViewSpec(ViewSpec): script: JavaScript interface for the task. markup: Task interface. styles: CSS task interface. - asserts: Linked files such as: + assets: Linked files such as: * CSS styles * JavaScript libraries * Toloka assets with the $TOLOKA_ASSETS prefix @@ -82,22 +94,38 @@ class ClassicViewSpec(ViewSpec): """ class Assets(BaseTolokaObject): - """style_urls: Links to CSS libraries. - script_urls: Links to JavaScript libraries and Toloka assets. - Toloka assets: - * "$TOLOKA_ASSETS/js/toloka-handlebars-templates.js" — Handlebars. Ssee the description on the template - engine website here http://handlebarsjs.com/ - * "$TOLOKA_ASSETS/js/image-annotation.js" — Image labeling interface. See image with area selection in - the Requester's guide here https://yandex.ru/support/toloka-requester/concepts/t-components/image-annotation.html/?lang=en - Note that the image labeling interface should only be connected together with the Handlebars helpers. - The order of connection matters: - >>> scipt_utls = [ - >>> "$TOLOKA_ASSETS/js/toloka-handlebars-templates.js", - >>> "$TOLOKA_ASSETS/js/image-annotation.js", - >>> ] + """Linked files with assets. + + Attributes: + style_urls: Links to CSS libraries. + script_urls: Links to JavaScript libraries and Toloka assets. + Toloka assets: + * "$TOLOKA_ASSETS/js/toloka-handlebars-templates.js" — Handlebars. See the description on the template + engine website here http://handlebarsjs.com/ + * "$TOLOKA_ASSETS/js/image-annotation.js" — Image labeling interface. See image with area selection in + the Requester's guide here https://yandex.ru/support/toloka-requester/concepts/t-components/image-annotation.html/?lang=en + Note that the image labeling interface should only be connected together with the Handlebars helpers. + The order of connection matters. + + Examples: + >>> from toloka.client.project.view_spec import ClassicViewSpec + >>> view_spec = ClassicViewSpec( + >>> ..., + >>> assets = ClassicViewSpec.Assets( + >>> script_utls = [ + >>> "$TOLOKA_ASSETS/js/toloka-handlebars-templates.js", + >>> "$TOLOKA_ASSETS/js/image-annotation.js", + >>> ] + >>> ) + >>> ) """ - def __init__(self, *, style_urls: Optional[List[str]] = None, script_urls: Optional[List[str]] = None) -> None: + def __init__( + self, + *, + style_urls: Optional[List[str]] = None, + script_urls: Optional[List[str]] = None + ) -> None: """Method generated by attrs for class ClassicViewSpec.Assets. """ ... @@ -106,7 +134,15 @@ class ClassicViewSpec(ViewSpec): style_urls: Optional[List[str]] script_urls: Optional[List[str]] - def __init__(self, *, settings: Optional[ViewSpec.Settings] = None, script: Optional[str] = None, markup: Optional[str] = None, styles: Optional[str] = None, assets: Optional[Assets] = None) -> None: + def __init__( + self, + *, + settings: Optional[ViewSpec.Settings] = None, + script: Optional[str] = None, + markup: Optional[str] = None, + styles: Optional[str] = None, + assets: Optional[Assets] = None + ) -> None: """Method generated by attrs for class ClassicViewSpec. """ ... @@ -142,7 +178,28 @@ class TemplateBuilderViewSpec(ViewSpec): ... """ - def __init__(self, *, settings: Optional[ViewSpec.Settings] = None, view: Optional[BaseComponent] = None, plugins: Optional[List[BaseComponent]] = None, vars: Optional[Dict[str, Any]] = None, core_version: Optional[str] = '1.0.0') -> None: + @overload + def __init__( + self, + *, + settings: Optional[ViewSpec.Settings] = None, + view: Optional[BaseComponent] = None, + plugins: Optional[List[BaseComponent]] = None, + vars: Optional[Dict[str, Any]] = None, + core_version: Optional[str] = '1.0.0' + ) -> None: + """Method generated by attrs for class TemplateBuilderViewSpec. + """ + ... + + @overload + def __init__( + self, + *, + settings: Optional[ViewSpec.Settings] = None, + config: Optional[TemplateBuilder] = None, + core_version: Optional[str] = '1.0.0' + ) -> None: """Method generated by attrs for class TemplateBuilderViewSpec. """ ... diff --git a/src/client/quality_control.pyi b/src/client/quality_control.pyi index c4461971..00349ecd 100644 --- a/src/client/quality_control.pyi +++ b/src/client/quality_control.pyi @@ -76,7 +76,12 @@ class QualityControl(BaseTolokaObject): task_distribution_function: Distribution of tasks with majority opinion verification. """ - def __init__(self, *, target_overlap: Optional[int] = None, task_distribution_function: Optional[TaskDistributionFunction] = None) -> None: + def __init__( + self, + *, + target_overlap: Optional[int] = None, + task_distribution_function: Optional[TaskDistributionFunction] = None + ) -> None: """Method generated by attrs for class QualityControl.CheckpointsConfig.Settings. """ ... @@ -85,7 +90,13 @@ class QualityControl(BaseTolokaObject): target_overlap: Optional[int] task_distribution_function: Optional[TaskDistributionFunction] - def __init__(self, *, real_settings: Optional[Settings] = None, golden_settings: Optional[Settings] = None, training_settings: Optional[Settings] = None) -> None: + def __init__( + self, + *, + real_settings: Optional[Settings] = None, + golden_settings: Optional[Settings] = None, + training_settings: Optional[Settings] = None + ) -> None: """Method generated by attrs for class QualityControl.CheckpointsConfig. """ ... @@ -119,7 +130,12 @@ class QualityControl(BaseTolokaObject): conditions: Conditions (for example, skipping 10 sets of tasks in a row). """ - def __init__(self, *, action: Optional[RuleAction] = None, conditions: Optional[List[RuleCondition]] = None) -> None: + def __init__( + self, + *, + action: Optional[RuleAction] = None, + conditions: Optional[List[RuleCondition]] = None + ) -> None: """Method generated by attrs for class QualityControl.QualityControlConfig.RuleConfig. """ ... @@ -128,7 +144,12 @@ class QualityControl(BaseTolokaObject): action: Optional[RuleAction] conditions: Optional[List[RuleCondition]] - def __init__(self, *, rules: Optional[List[RuleConfig]] = None, collector_config: Optional[CollectorConfig] = None) -> None: + def __init__( + self, + *, + rules: Optional[List[RuleConfig]] = None, + collector_config: Optional[CollectorConfig] = None + ) -> None: """Method generated by attrs for class QualityControl.QualityControlConfig. """ ... @@ -146,7 +167,12 @@ class QualityControl(BaseTolokaObject): for admission to the main tasks. The user's first responses in tasks are used for counting. """ - def __init__(self, *, training_pool_id: Optional[str] = None, training_passing_skill_value: Optional[int] = None) -> None: + def __init__( + self, + *, + training_pool_id: Optional[str] = None, + training_passing_skill_value: Optional[int] = None + ) -> None: """Method generated by attrs for class QualityControl.TrainingRequirement. """ ... @@ -155,12 +181,24 @@ class QualityControl(BaseTolokaObject): training_pool_id: Optional[str] training_passing_skill_value: Optional[int] - def __init__(self, *, training_requirement: Optional[TrainingRequirement] = None, captcha_frequency: Optional[CaptchaFrequency] = None, configs: Optional[List[QualityControlConfig]] = ..., checkpoints_config: Optional[CheckpointsConfig] = None) -> None: + def __init__( + self, + *, + training_requirement: Optional[TrainingRequirement] = None, + captcha_frequency: Optional[CaptchaFrequency] = None, + configs: Optional[List[QualityControlConfig]] = ..., + checkpoints_config: Optional[CheckpointsConfig] = None + ) -> None: """Method generated by attrs for class QualityControl. """ ... - def add_action(self, collector: CollectorConfig, action: RuleAction, conditions: List[RuleCondition]): + def add_action( + self, + collector: CollectorConfig, + action: RuleAction, + conditions: List[RuleCondition] + ): """Adds new QualityControlConfig to QualityControl object. Usually in pool. See example in QualityControl class. diff --git a/src/client/requester.pyi b/src/client/requester.pyi index 98bde82c..896c643a 100644 --- a/src/client/requester.pyi +++ b/src/client/requester.pyi @@ -17,7 +17,12 @@ class Requester(BaseTolokaObject): """ class Company(BaseTolokaObject): - def __init__(self, *, id: Optional[str] = None, superintendent_id: Optional[str] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + superintendent_id: Optional[str] = None + ) -> None: """Method generated by attrs for class Requester.Company. """ ... @@ -26,7 +31,14 @@ class Requester(BaseTolokaObject): id: Optional[str] superintendent_id: Optional[str] - def __init__(self, *, id: Optional[str] = None, balance: Optional[Decimal] = None, public_name: Optional[Dict[str, str]] = None, company: Optional[Company] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + balance: Optional[Decimal] = None, + public_name: Optional[Dict[str, str]] = None, + company: Optional[Company] = None + ) -> None: """Method generated by attrs for class Requester. """ ... diff --git a/src/client/search_requests.pyi b/src/client/search_requests.pyi index 4c57d665..01af389b 100644 --- a/src/client/search_requests.pyi +++ b/src/client/search_requests.pyi @@ -58,7 +58,12 @@ class BaseSortItems(BaseTolokaObject): ... @classmethod - def for_fields(cls, name: str, sort_fields: List[str], docstring: Optional[str] = None): ... + def for_fields( + cls, + name: str, + sort_fields: List[str], + docstring: Optional[str] = None + ): ... @classmethod def structure(cls, items): ... @@ -108,7 +113,18 @@ class ProjectSearchRequest(BaseSearchRequest): id: str created: datetime - def __init__(self, status: Optional[Project.ProjectStatus] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> None: + def __init__( + self, + status: Optional[Project.ProjectStatus] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None + ) -> None: """Method generated by attrs for class ProjectSearchRequest. """ ... @@ -156,7 +172,11 @@ class ProjectSortItems(BaseSortItems): PUBLIC_NAME = 'public_name' PRIVATE_COMMENT = 'private_comment' - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -203,7 +223,23 @@ class PoolSearchRequest(BaseSearchRequest): created: datetime last_started: datetime - def __init__(self, status: Optional[Pool.Status] = None, project_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, last_started_lt: Optional[datetime] = None, last_started_lte: Optional[datetime] = None, last_started_gt: Optional[datetime] = None, last_started_gte: Optional[datetime] = None) -> None: + def __init__( + self, + status: Optional[Pool.Status] = None, + project_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + last_started_lt: Optional[datetime] = None, + last_started_lte: Optional[datetime] = None, + last_started_gt: Optional[datetime] = None, + last_started_gte: Optional[datetime] = None + ) -> None: """Method generated by attrs for class PoolSearchRequest. """ ... @@ -254,7 +290,11 @@ class PoolSortItems(BaseSortItems): CREATED = 'created' LAST_STARTED = 'last_started' - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -301,7 +341,23 @@ class TrainingSearchRequest(BaseSearchRequest): created: datetime last_started: datetime - def __init__(self, status: Optional[Training.Status] = None, project_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, last_started_lt: Optional[datetime] = None, last_started_lte: Optional[datetime] = None, last_started_gt: Optional[datetime] = None, last_started_gte: Optional[datetime] = None) -> None: + def __init__( + self, + status: Optional[Training.Status] = None, + project_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + last_started_lt: Optional[datetime] = None, + last_started_lte: Optional[datetime] = None, + last_started_gt: Optional[datetime] = None, + last_started_gte: Optional[datetime] = None + ) -> None: """Method generated by attrs for class TrainingSearchRequest. """ ... @@ -352,7 +408,11 @@ class TrainingSortItems(BaseSortItems): CREATED = 'created' LAST_STARTED = 'last_started' - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -389,7 +449,18 @@ class SkillSearchRequest(BaseSearchRequest): id: str created: datetime - def __init__(self, name: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> None: + def __init__( + self, + name: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None + ) -> None: """Method generated by attrs for class SkillSearchRequest. """ ... @@ -433,7 +504,11 @@ class SkillSortItems(BaseSortItems): ID = 'id' CREATED = 'created' - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -486,7 +561,26 @@ class AssignmentSearchRequest(BaseSearchRequest): created: datetime submitted: datetime - def __init__(self, status: Union[str, Assignment.Status, List[Union[str, Assignment.Status]]] = None, task_id: Optional[str] = None, task_suite_id: Optional[str] = None, pool_id: Optional[str] = None, user_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, submitted_lt: Optional[datetime] = None, submitted_lte: Optional[datetime] = None, submitted_gt: Optional[datetime] = None, submitted_gte: Optional[datetime] = None) -> None: + def __init__( + self, + status: Union[str, Assignment.Status, List[Union[str, Assignment.Status]]] = None, + task_id: Optional[str] = None, + task_suite_id: Optional[str] = None, + pool_id: Optional[str] = None, + user_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + submitted_lt: Optional[datetime] = None, + submitted_lte: Optional[datetime] = None, + submitted_gt: Optional[datetime] = None, + submitted_gte: Optional[datetime] = None + ) -> None: """Method generated by attrs for class AssignmentSearchRequest. """ ... @@ -542,7 +636,11 @@ class AssignmentSortItems(BaseSortItems): CREATED = 'created' SUBMITTED = 'submitted' - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -573,7 +671,13 @@ class AggregatedSolutionSearchRequest(BaseSearchRequest): class CompareFields: task_id: str - def __init__(self, task_id_lt: Optional[str] = None, task_id_lte: Optional[str] = None, task_id_gt: Optional[str] = None, task_id_gte: Optional[str] = None) -> None: + def __init__( + self, + task_id_lt: Optional[str] = None, + task_id_lte: Optional[str] = None, + task_id_gt: Optional[str] = None, + task_id_gte: Optional[str] = None + ) -> None: """Method generated by attrs for class AggregatedSolutionSearchRequest. """ ... @@ -602,7 +706,11 @@ class AggregatedSolutionSortItems(BaseSortItems): TASK_ID = 'task_id' - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -645,7 +753,23 @@ class TaskSearchRequest(BaseSearchRequest): created: datetime overlap: int - def __init__(self, pool_id: Optional[str] = None, overlap: Optional[int] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, overlap_lt: Optional[int] = None, overlap_lte: Optional[int] = None, overlap_gt: Optional[int] = None, overlap_gte: Optional[int] = None) -> None: + def __init__( + self, + pool_id: Optional[str] = None, + overlap: Optional[int] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + overlap_lt: Optional[int] = None, + overlap_lte: Optional[int] = None, + overlap_gt: Optional[int] = None, + overlap_gte: Optional[int] = None + ) -> None: """Method generated by attrs for class TaskSearchRequest. """ ... @@ -694,7 +818,11 @@ class TaskSortItems(BaseSortItems): ID = 'id' CREATED = 'created' - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -739,7 +867,24 @@ class TaskSuiteSearchRequest(BaseSearchRequest): created: datetime overlap: int - def __init__(self, task_id: Optional[str] = None, pool_id: Optional[str] = None, overlap: Optional[int] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, overlap_lt: Optional[int] = None, overlap_lte: Optional[int] = None, overlap_gt: Optional[int] = None, overlap_gte: Optional[int] = None) -> None: + def __init__( + self, + task_id: Optional[str] = None, + pool_id: Optional[str] = None, + overlap: Optional[int] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + overlap_lt: Optional[int] = None, + overlap_lte: Optional[int] = None, + overlap_gt: Optional[int] = None, + overlap_gte: Optional[int] = None + ) -> None: """Method generated by attrs for class TaskSuiteSearchRequest. """ ... @@ -789,7 +934,11 @@ class TaskSuiteSortItems(BaseSortItems): ID = 'id' CREATED = 'created' - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -832,7 +981,24 @@ class AttachmentSearchRequest(BaseSearchRequest): id: str created: datetime - def __init__(self, name: Optional[str] = None, type: Optional[Attachment.Type] = None, user_id: Optional[str] = None, assignment_id: Optional[str] = None, pool_id: Optional[str] = None, owner_id: Optional[str] = None, owner_company_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> None: + def __init__( + self, + name: Optional[str] = None, + type: Optional[Attachment.Type] = None, + user_id: Optional[str] = None, + assignment_id: Optional[str] = None, + pool_id: Optional[str] = None, + owner_id: Optional[str] = None, + owner_company_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None + ) -> None: """Method generated by attrs for class AttachmentSearchRequest. """ ... @@ -882,7 +1048,11 @@ class AttachmentSortItems(BaseSortItems): ID = 'id' CREATED = 'created' - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -926,7 +1096,24 @@ class UserSkillSearchRequest(BaseSearchRequest): created: datetime modified: datetime - def __init__(self, name: Optional[str] = None, user_id: Optional[str] = None, skill_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None, modified_lt: Optional[datetime] = None, modified_lte: Optional[datetime] = None, modified_gt: Optional[datetime] = None, modified_gte: Optional[datetime] = None) -> None: + def __init__( + self, + name: Optional[str] = None, + user_id: Optional[str] = None, + skill_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None, + modified_lt: Optional[datetime] = None, + modified_lte: Optional[datetime] = None, + modified_gt: Optional[datetime] = None, + modified_gte: Optional[datetime] = None + ) -> None: """Method generated by attrs for class UserSkillSearchRequest. """ ... @@ -976,7 +1163,11 @@ class UserSkillSortItems(BaseSortItems): ID = 'id' CREATED = 'created' - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -1019,7 +1210,21 @@ class UserRestrictionSearchRequest(BaseSearchRequest): id: str created: datetime - def __init__(self, scope: Optional[UserRestriction.Scope] = None, user_id: Optional[str] = None, project_id: Optional[str] = None, pool_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> None: + def __init__( + self, + scope: Optional[UserRestriction.Scope] = None, + user_id: Optional[str] = None, + project_id: Optional[str] = None, + pool_id: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None + ) -> None: """Method generated by attrs for class UserRestrictionSearchRequest. """ ... @@ -1066,7 +1271,11 @@ class UserRestrictionSortItems(BaseSortItems): ID = 'id' CREATED = 'created' - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -1104,7 +1313,19 @@ class UserBonusSearchRequest(BaseSearchRequest): id: str created: datetime - def __init__(self, user_id: Optional[str] = None, private_comment: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> None: + def __init__( + self, + user_id: Optional[str] = None, + private_comment: Optional[str] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None + ) -> None: """Method generated by attrs for class UserBonusSearchRequest. """ ... @@ -1149,7 +1370,11 @@ class UserBonusSortItems(BaseSortItems): ID = 'id' CREATED = 'created' - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -1187,7 +1412,19 @@ class MessageThreadSearchRequest(BaseSearchRequest): id: str created: datetime - def __init__(self, folder: Union[str, Folder, List[Union[str, Folder]]] = None, folder_ne: Union[str, Folder, List[Union[str, Folder]]] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> None: + def __init__( + self, + folder: Union[str, Folder, List[Union[str, Folder]]] = None, + folder_ne: Union[str, Folder, List[Union[str, Folder]]] = None, + id_lt: Optional[str] = None, + id_lte: Optional[str] = None, + id_gt: Optional[str] = None, + id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, + created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, + created_gte: Optional[datetime] = None + ) -> None: """Method generated by attrs for class MessageThreadSearchRequest. """ ... @@ -1227,7 +1464,11 @@ class MessageThreadSortItems(BaseSortItems): ID = 'id' CREATED = 'created' - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -1247,6 +1488,7 @@ class MessageThreadSortItems(BaseSortItems): class WebhookSubscriptionSearchRequest(BaseSearchRequest): """Parameters for searching webhook-subscriptions. + Attributes: event_type: Event type. pool_id: ID of the pool for which subscription information is requested. @@ -1264,9 +1506,13 @@ class WebhookSubscriptionSearchRequest(BaseSearchRequest): id: str created: datetime - - - def __init__(self, event_type: Optional[WebhookSubscription.EventType] = None, pool_id: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, id_gt: Optional[str] = None, id_gte: Optional[str] = None, created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None) -> None: + def __init__(self, + event_type: Optional[WebhookSubscription.EventType] = None, pool_id: Optional[str] = None, + id_lt: Optional[str] = None, id_lte: Optional[str] = None, + id_gt: Optional[str] = None, id_gte: Optional[str] = None, + created_lt: Optional[datetime] = None, created_lte: Optional[datetime] = None, + created_gt: Optional[datetime] = None, created_gte: Optional[datetime] = None + ) -> None: """Method generated by attrs for class WebhookSubscriptionSearchRequest. """ ... @@ -1283,14 +1529,24 @@ class WebhookSubscriptionSearchRequest(BaseSearchRequest): created_gt: Optional[datetime] created_gte: Optional[datetime] + class WebhookSubscriptionSortItems(BaseSortItems): """Parameters for sorting webhook-subscriptions search results + You can specify multiple parameters. To change the sorting direction (sort in descending order), add a hyphen before the parameter. For example, sort=-id. + Attributes: items: Fields by which to sort. Possible values: - * id - Thread ID in ascending order. - * created - Creation date in UTC format yyyy-MM-DD (ascending). + * id - Subscription ID (in ascending order). + * created - Date of creation of the subscription in UTC in the format YYYY-MM-DD (ascending). + + Example: + How to specify and use SortItems. + + >>> sort = toloka.client.search_requests.WebhookSubscriptionSortItems(['-created', 'id']) + >>> result = toloka_client.find_webhook_subscriptions(event_type=some_event_type, pool_id=my_pretty_pool_id, sort=sort, limit=10) + ... """ class SortItem(BaseSortItem): @@ -1301,9 +1557,11 @@ class WebhookSubscriptionSortItems(BaseSortItems): ID = 'id' CREATED = 'created' - - - def __init__(self, field: Optional[SortField] = None, order: Optional[SortOrder] = ...) -> None: + def __init__( + self, + field: Optional[SortField] = None, + order: Optional[SortOrder] = ... + ) -> None: """Method generated by attrs for class SortItem. """ ... @@ -1312,8 +1570,6 @@ class WebhookSubscriptionSortItems(BaseSortItems): field: Optional[SortField] order: Optional[SortOrder] - - def __init__(self, items=None) -> None: """Method generated by attrs for class WebhookSubscriptionSortItems. """ diff --git a/src/client/search_results.py b/src/client/search_results.py index 52f3ba94..13e30a27 100644 --- a/src/client/search_results.py +++ b/src/client/search_results.py @@ -11,7 +11,8 @@ 'TrainingSearchResult', 'UserBonusSearchResult', 'UserRestrictionSearchResult', - 'UserSkillSearchResult' + 'UserSkillSearchResult', + 'WebhookSubscriptionSearchResult' ] from typing import Type, List, Optional from .aggregation import AggregatedSolution diff --git a/src/client/search_results.pyi b/src/client/search_results.pyi index efe7c2a6..2cc1a624 100644 --- a/src/client/search_results.pyi +++ b/src/client/search_results.pyi @@ -30,7 +30,12 @@ class AggregatedSolutionSearchResult(BaseTolokaObject): * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[AggregatedSolution]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[AggregatedSolution]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class AggregatedSolutionSearchResult. """ ... @@ -52,7 +57,12 @@ class AssignmentSearchResult(BaseTolokaObject): * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[Assignment]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[Assignment]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class AssignmentSearchResult. """ ... @@ -74,7 +84,12 @@ class AttachmentSearchResult(BaseTolokaObject): * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[Attachment]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[Attachment]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class AttachmentSearchResult. """ ... @@ -96,7 +111,12 @@ class MessageThreadSearchResult(BaseTolokaObject): * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[MessageThread]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[MessageThread]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class MessageThreadSearchResult. """ ... @@ -118,7 +138,12 @@ class ProjectSearchResult(BaseTolokaObject): * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[Project]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[Project]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class ProjectSearchResult. """ ... @@ -140,7 +165,12 @@ class PoolSearchResult(BaseTolokaObject): * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[Pool]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[Pool]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class PoolSearchResult. """ ... @@ -162,7 +192,12 @@ class SkillSearchResult(BaseTolokaObject): * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[Skill]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[Skill]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class SkillSearchResult. """ ... @@ -184,7 +219,12 @@ class TaskSearchResult(BaseTolokaObject): * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[Task]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[Task]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class TaskSearchResult. """ ... @@ -206,7 +246,12 @@ class TaskSuiteSearchResult(BaseTolokaObject): * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[TaskSuite]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[TaskSuite]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class TaskSuiteSearchResult. """ ... @@ -228,7 +273,12 @@ class TrainingSearchResult(BaseTolokaObject): * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[Training]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[Training]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class TrainingSearchResult. """ ... @@ -250,7 +300,12 @@ class UserBonusSearchResult(BaseTolokaObject): * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[UserBonus]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[UserBonus]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class UserBonusSearchResult. """ ... @@ -272,7 +327,12 @@ class UserRestrictionSearchResult(BaseTolokaObject): * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[UserRestriction]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[UserRestriction]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class UserRestrictionSearchResult. """ ... @@ -294,7 +354,12 @@ class UserSkillSearchResult(BaseTolokaObject): * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[UserSkill]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[UserSkill]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class UserSkillSearchResult. """ ... @@ -305,17 +370,24 @@ class UserSkillSearchResult(BaseTolokaObject): class WebhookSubscriptionSearchResult(BaseTolokaObject): - """The list of found user skills and whether there is something else on the original request - It's better to use TolokaClient.get_webhook_results(), + """The list of found subscriptions and whether there is something else on the original request + + It's better to use TolokaClient.get_webhook_subscriptions(), which already implements the correct handling of the search result. + Attributes: - items: List of found webhook-subscriptions + items: List of found subscriptions has_more: Whether the list is complete: * True - Not all elements are included in the output due to restrictions in the limit parameter. * False - The output lists all the items. """ - def __init__(self, *, items: Optional[List[WebhookSubscription]] = None, has_more: Optional[bool] = None) -> None: + def __init__( + self, + *, + items: Optional[List[WebhookSubscription]] = None, + has_more: Optional[bool] = None + ) -> None: """Method generated by attrs for class WebhookSubscriptionSearchResult. """ ... diff --git a/src/client/skill.pyi b/src/client/skill.pyi index 10705707..eff48610 100644 --- a/src/client/skill.pyi +++ b/src/client/skill.pyi @@ -53,7 +53,19 @@ class Skill(BaseTolokaObject): ... """ - def __init__(self, *, name: Optional[str] = None, private_comment: Optional[str] = None, hidden: Optional[bool] = None, skill_ttl_hours: Optional[int] = None, training: Optional[bool] = None, public_name: Optional[Dict[str, str]] = None, public_requester_description: Optional[Dict[str, str]] = None, id: Optional[str] = None, created: Optional[datetime] = None) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + private_comment: Optional[str] = None, + hidden: Optional[bool] = None, + skill_ttl_hours: Optional[int] = None, + training: Optional[bool] = None, + public_name: Optional[Dict[str, str]] = None, + public_requester_description: Optional[Dict[str, str]] = None, + id: Optional[str] = None, + created: Optional[datetime] = None + ) -> None: """Method generated by attrs for class Skill. """ ... diff --git a/src/client/task.pyi b/src/client/task.pyi index d2665666..ea48f30f 100644 --- a/src/client/task.pyi +++ b/src/client/task.pyi @@ -43,7 +43,12 @@ class BaseTask(BaseTolokaObject): counted to the user. The more correct the answer in correctValues, the higher its weight. """ - def __init__(self, *, output_values: Optional[Dict[str, Any]] = None, correctness_weight: Optional[float] = None) -> None: + def __init__( + self, + *, + output_values: Optional[Dict[str, Any]] = None, + correctness_weight: Optional[float] = None + ) -> None: """Method generated by attrs for class BaseTask.KnownSolution. """ ... @@ -52,7 +57,15 @@ class BaseTask(BaseTolokaObject): output_values: Optional[Dict[str, Any]] correctness_weight: Optional[float] - def __init__(self, *, input_values: Optional[Dict[str, Any]] = None, known_solutions: Optional[List[KnownSolution]] = None, message_on_unknown_solution: Optional[str] = None, id: Optional[str] = None, origin_task_id: Optional[str] = None) -> None: + def __init__( + self, + *, + input_values: Optional[Dict[str, Any]] = None, + known_solutions: Optional[List[KnownSolution]] = None, + message_on_unknown_solution: Optional[str] = None, + id: Optional[str] = None, + origin_task_id: Optional[str] = None + ) -> None: """Method generated by attrs for class BaseTask. """ ... @@ -95,7 +108,12 @@ class Task(InfiniteOverlapParametersMixin, BaseTask): """ class BaselineSolution(BaseTolokaObject): - def __init__(self, *, output_values: Optional[Dict[str, Any]] = None, confidence_weight: Optional[float] = None) -> None: + def __init__( + self, + *, + output_values: Optional[Dict[str, Any]] = None, + confidence_weight: Optional[float] = None + ) -> None: """Method generated by attrs for class Task.BaselineSolution. """ ... @@ -104,7 +122,26 @@ class Task(InfiniteOverlapParametersMixin, BaseTask): output_values: Optional[Dict[str, Any]] confidence_weight: Optional[float] - def __init__(self, *, input_values: Optional[Dict[str, Any]] = None, known_solutions: Optional[List[BaseTask.KnownSolution]] = None, message_on_unknown_solution: Optional[str] = None, id: Optional[str] = None, infinite_overlap=None, overlap=None, pool_id: Optional[str] = None, remaining_overlap: Optional[int] = None, reserved_for: Optional[List[str]] = None, unavailable_for: Optional[List[str]] = None, traits_all_of: Optional[List[str]] = None, traits_any_of: Optional[List[str]] = None, traits_none_of_any: Optional[List[str]] = None, origin_task_id: Optional[str] = None, created: Optional[datetime] = None, baseline_solutions: Optional[List[BaselineSolution]] = None) -> None: + def __init__( + self, + *, + input_values: Optional[Dict[str, Any]] = None, + known_solutions: Optional[List[BaseTask.KnownSolution]] = None, + message_on_unknown_solution: Optional[str] = None, + id: Optional[str] = None, + infinite_overlap=None, + overlap=None, + pool_id: Optional[str] = None, + remaining_overlap: Optional[int] = None, + reserved_for: Optional[List[str]] = None, + unavailable_for: Optional[List[str]] = None, + traits_all_of: Optional[List[str]] = None, + traits_any_of: Optional[List[str]] = None, + traits_none_of_any: Optional[List[str]] = None, + origin_task_id: Optional[str] = None, + created: Optional[datetime] = None, + baseline_solutions: Optional[List[BaselineSolution]] = None + ) -> None: """Method generated by attrs for class Task. """ ... @@ -140,7 +177,12 @@ class CreateTaskParameters(Parameters): open_pool: Open the pool immediately after creating a task suite, if the pool is closed. """ - def __init__(self, *, allow_defaults: Optional[bool] = None, open_pool: Optional[bool] = None) -> None: + def __init__( + self, + *, + allow_defaults: Optional[bool] = None, + open_pool: Optional[bool] = None + ) -> None: """Method generated by attrs for class CreateTaskParameters. """ ... @@ -151,7 +193,13 @@ class CreateTaskParameters(Parameters): class CreateTaskAsyncParameters(CreateTaskParameters): - def __init__(self, *, allow_defaults: Optional[bool] = None, open_pool: Optional[bool] = None, operation_id: Optional[UUID] = None) -> None: + def __init__( + self, + *, + allow_defaults: Optional[bool] = None, + open_pool: Optional[bool] = None, + operation_id: Optional[UUID] = None + ) -> None: """Method generated by attrs for class CreateTaskAsyncParameters. """ ... @@ -179,7 +227,15 @@ class CreateTasksParameters(CreateTaskParameters): A maximum of 5000 tasks can be sent in a single request. """ - def __init__(self, *, allow_defaults: Optional[bool] = None, open_pool: Optional[bool] = None, skip_invalid_items: Optional[bool] = None, operation_id: Optional[UUID] = None, async_mode: Optional[bool] = True) -> None: + def __init__( + self, + *, + allow_defaults: Optional[bool] = None, + open_pool: Optional[bool] = None, + skip_invalid_items: Optional[bool] = None, + operation_id: Optional[UUID] = None, + async_mode: Optional[bool] = True + ) -> None: """Method generated by attrs for class CreateTasksParameters. """ ... @@ -202,7 +258,12 @@ class TaskOverlapPatch(BaseTolokaObject): * False - Leave the overlap specified for the task or pool. Default Behaviour. """ - def __init__(self, *, overlap: Optional[int] = None, infinite_overlap: Optional[bool] = None) -> None: + def __init__( + self, + *, + overlap: Optional[int] = None, + infinite_overlap: Optional[bool] = None + ) -> None: """Method generated by attrs for class TaskOverlapPatch. """ ... @@ -219,7 +280,13 @@ class TaskPatch(TaskOverlapPatch): baseline_solutions: """ - def __init__(self, *, overlap: Optional[int] = None, infinite_overlap: Optional[bool] = None, baseline_solutions: Optional[List[Task.BaselineSolution]] = None) -> None: + def __init__( + self, + *, + overlap: Optional[int] = None, + infinite_overlap: Optional[bool] = None, + baseline_solutions: Optional[List[Task.BaselineSolution]] = None + ) -> None: """Method generated by attrs for class TaskPatch. """ ... diff --git a/src/client/task_distribution_function.pyi b/src/client/task_distribution_function.pyi index 06fa75db..f25c7f34 100644 --- a/src/client/task_distribution_function.pyi +++ b/src/client/task_distribution_function.pyi @@ -41,7 +41,13 @@ class TaskDistributionFunction(BaseTolokaObject): For example, if you set frequency: 3 tasks number 1, 4, 7 and so on will be distributed tasks. """ - def __init__(self, *, from_: Optional[int] = None, to: Optional[int] = None, frequency: Optional[int] = None) -> None: + def __init__( + self, + *, + from_: Optional[int] = None, + to: Optional[int] = None, + frequency: Optional[int] = None + ) -> None: """Method generated by attrs for class TaskDistributionFunction.Interval. """ ... @@ -58,7 +64,14 @@ class TaskDistributionFunction(BaseTolokaObject): PROJECT = 'PROJECT' POOL = 'POOL' - def __init__(self, *, scope: Optional[Scope] = None, distribution: Optional[Distribution] = None, window_days: Optional[int] = None, intervals: Optional[List[Interval]] = None) -> None: + def __init__( + self, + *, + scope: Optional[Scope] = None, + distribution: Optional[Distribution] = None, + window_days: Optional[int] = None, + intervals: Optional[List[Interval]] = None + ) -> None: """Method generated by attrs for class TaskDistributionFunction. """ ... diff --git a/src/client/task_suite.pyi b/src/client/task_suite.pyi index 9e011f61..5e0d7111 100644 --- a/src/client/task_suite.pyi +++ b/src/client/task_suite.pyi @@ -43,13 +43,41 @@ class TaskSuite(InfiniteOverlapParametersMixin, BaseTolokaObject): created: The UTC date and time when the task suite was created. Read Only field. """ - def __init__(self, *, infinite_overlap=None, overlap=None, pool_id: Optional[str] = None, tasks: Optional[List[BaseTask]] = ..., reserved_for: Optional[List[str]] = None, unavailable_for: Optional[List[str]] = None, issuing_order_override: Optional[float] = None, mixed: Optional[bool] = None, traits_all_of: Optional[List[str]] = None, traits_any_of: Optional[List[str]] = None, traits_none_of_any: Optional[List[str]] = None, longitude: Optional[float] = None, latitude: Optional[float] = None, id: Optional[str] = None, remaining_overlap: Optional[int] = None, automerged: Optional[bool] = None, created: Optional[datetime] = None) -> None: + def __init__( + self, + *, + infinite_overlap=None, + overlap=None, + pool_id: Optional[str] = None, + tasks: Optional[List[BaseTask]] = ..., + reserved_for: Optional[List[str]] = None, + unavailable_for: Optional[List[str]] = None, + issuing_order_override: Optional[float] = None, + mixed: Optional[bool] = None, + traits_all_of: Optional[List[str]] = None, + traits_any_of: Optional[List[str]] = None, + traits_none_of_any: Optional[List[str]] = None, + longitude: Optional[float] = None, + latitude: Optional[float] = None, + id: Optional[str] = None, + remaining_overlap: Optional[int] = None, + automerged: Optional[bool] = None, + created: Optional[datetime] = None + ) -> None: """Method generated by attrs for class TaskSuite. """ ... @overload - def add_base_task(self, *, input_values: Optional[Dict[str, Any]] = None, known_solutions: Optional[List[BaseTask.KnownSolution]] = None, message_on_unknown_solution: Optional[str] = None, id: Optional[str] = None, origin_task_id: Optional[str] = None) -> 'TaskSuite': ... + def add_base_task( + self, + *, + input_values: Optional[Dict[str, Any]] = None, + known_solutions: Optional[List[BaseTask.KnownSolution]] = None, + message_on_unknown_solution: Optional[str] = None, + id: Optional[str] = None, + origin_task_id: Optional[str] = None + ) -> 'TaskSuite': ... @overload def add_base_task(self, base_task: BaseTask) -> 'TaskSuite': ... @@ -94,7 +122,15 @@ class TaskSuiteCreateRequestParameters(Parameters): You can send a maximum of 5000 task sets in a single request. """ - def __init__(self, *, operation_id: Optional[UUID] = None, skip_invalid_items: Optional[bool] = None, allow_defaults: Optional[bool] = None, open_pool: Optional[bool] = None, async_mode: Optional[bool] = True) -> None: + def __init__( + self, + *, + operation_id: Optional[UUID] = None, + skip_invalid_items: Optional[bool] = None, + allow_defaults: Optional[bool] = None, + open_pool: Optional[bool] = None, + async_mode: Optional[bool] = True + ) -> None: """Method generated by attrs for class TaskSuiteCreateRequestParameters. """ ... @@ -131,7 +167,14 @@ class TaskSuitePatch(InfiniteOverlapParametersMixin, BaseTolokaObject): open_pool: Open the pool immediately after changing a task suite, if the pool is closed. """ - def __init__(self, *, infinite_overlap=None, overlap=None, issuing_order_override: Optional[float] = None, open_pool: Optional[bool] = None) -> None: + def __init__( + self, + *, + infinite_overlap=None, + overlap=None, + issuing_order_override: Optional[float] = None, + open_pool: Optional[bool] = None + ) -> None: """Method generated by attrs for class TaskSuitePatch. """ ... diff --git a/src/client/training.pyi b/src/client/training.pyi index 84711858..7a31df86 100644 --- a/src/client/training.pyi +++ b/src/client/training.pyi @@ -83,7 +83,29 @@ class Training(BaseTolokaObject): ARCHIVED = 'ARCHIVED' LOCKED = 'LOCKED' - def __init__(self, *, project_id: Optional[str] = None, private_name: Optional[str] = None, may_contain_adult_content: Optional[bool] = None, assignment_max_duration_seconds: Optional[int] = None, mix_tasks_in_creation_order: Optional[bool] = None, shuffle_tasks_in_task_suite: Optional[bool] = None, training_tasks_in_task_suite_count: Optional[int] = None, task_suites_required_to_pass: Optional[int] = None, retry_training_after_days: Optional[int] = None, inherited_instructions: Optional[bool] = None, public_instructions: Optional[str] = None, metadata: Optional[Dict[str, List[str]]] = None, owner: Optional[Owner] = None, id: Optional[str] = None, status: Optional[Status] = None, last_close_reason: Optional[CloseReason] = None, created: Optional[datetime] = None, last_started: Optional[datetime] = None, last_stopped: Optional[datetime] = None) -> None: + def __init__( + self, + *, + project_id: Optional[str] = None, + private_name: Optional[str] = None, + may_contain_adult_content: Optional[bool] = None, + assignment_max_duration_seconds: Optional[int] = None, + mix_tasks_in_creation_order: Optional[bool] = None, + shuffle_tasks_in_task_suite: Optional[bool] = None, + training_tasks_in_task_suite_count: Optional[int] = None, + task_suites_required_to_pass: Optional[int] = None, + retry_training_after_days: Optional[int] = None, + inherited_instructions: Optional[bool] = None, + public_instructions: Optional[str] = None, + metadata: Optional[Dict[str, List[str]]] = None, + owner: Optional[Owner] = None, + id: Optional[str] = None, + status: Optional[Status] = None, + last_close_reason: Optional[CloseReason] = None, + created: Optional[datetime] = None, + last_started: Optional[datetime] = None, + last_stopped: Optional[datetime] = None + ) -> None: """Method generated by attrs for class Training. """ ... @@ -97,7 +119,13 @@ class Training(BaseTolokaObject): def is_open(self) -> bool: ... @overload - def set_owner(self, *, id: Optional[str] = None, myself: Optional[bool] = None, company_id: Optional[str] = None): + def set_owner( + self, + *, + id: Optional[str] = None, + myself: Optional[bool] = None, + company_id: Optional[str] = None + ): """A shortcut setter for owner """ ... diff --git a/src/client/user_bonus.pyi b/src/client/user_bonus.pyi index 242d1994..11455a52 100644 --- a/src/client/user_bonus.pyi +++ b/src/client/user_bonus.pyi @@ -60,7 +60,19 @@ class UserBonus(BaseTolokaObject): ... """ - def __init__(self, *, user_id: Optional[str] = None, amount: Optional[Decimal] = None, private_comment: Optional[str] = None, public_title: Optional[Any] = None, public_message: Optional[Any] = None, without_message: Optional[bool] = None, assignment_id: Optional[str] = None, id: Optional[str] = None, created: Optional[datetime] = None) -> None: + def __init__( + self, + *, + user_id: Optional[str] = None, + amount: Optional[Decimal] = None, + private_comment: Optional[str] = None, + public_title: Optional[Any] = None, + public_message: Optional[Any] = None, + without_message: Optional[bool] = None, + assignment_id: Optional[str] = None, + id: Optional[str] = None, + created: Optional[datetime] = None + ) -> None: """Method generated by attrs for class UserBonus. """ ... @@ -91,7 +103,12 @@ class UserBonusCreateRequestParameters(Parameters): * False - Default behaviour. Stop the operation and don't award bonuses if at least one object didn't pass validation. """ - def __init__(self, *, operation_id: Optional[str] = None, skip_invalid_items: Optional[bool] = None) -> None: + def __init__( + self, + *, + operation_id: Optional[str] = None, + skip_invalid_items: Optional[bool] = None + ) -> None: """Method generated by attrs for class UserBonusCreateRequestParameters. """ ... diff --git a/src/client/user_restriction.pyi b/src/client/user_restriction.pyi index 41bec089..b3ea4733 100644 --- a/src/client/user_restriction.pyi +++ b/src/client/user_restriction.pyi @@ -62,7 +62,15 @@ class UserRestriction(BaseTolokaObject): PROJECT = 'PROJECT' POOL = 'POOL' - def __init__(self, *, user_id: Optional[str] = None, private_comment: Optional[str] = None, will_expire: Optional[datetime] = None, id: Optional[str] = None, created: Optional[datetime] = None) -> None: + def __init__( + self, + *, + user_id: Optional[str] = None, + private_comment: Optional[str] = None, + will_expire: Optional[datetime] = None, + id: Optional[str] = None, + created: Optional[datetime] = None + ) -> None: """Method generated by attrs for class UserRestriction. """ ... @@ -79,7 +87,15 @@ class AllProjectsUserRestriction(UserRestriction): """Forbid the performer from doing tasks from all your projects """ - def __init__(self, *, user_id: Optional[str] = None, private_comment: Optional[str] = None, will_expire: Optional[datetime] = None, id: Optional[str] = None, created: Optional[datetime] = None) -> None: + def __init__( + self, + *, + user_id: Optional[str] = None, + private_comment: Optional[str] = None, + will_expire: Optional[datetime] = None, + id: Optional[str] = None, + created: Optional[datetime] = None + ) -> None: """Method generated by attrs for class AllProjectsUserRestriction. """ ... @@ -99,7 +115,16 @@ class PoolUserRestriction(UserRestriction): pool_id: Pool identifier to which access will be denied. """ - def __init__(self, *, user_id: Optional[str] = None, private_comment: Optional[str] = None, will_expire: Optional[datetime] = None, id: Optional[str] = None, created: Optional[datetime] = None, pool_id: Optional[str] = None) -> None: + def __init__( + self, + *, + user_id: Optional[str] = None, + private_comment: Optional[str] = None, + will_expire: Optional[datetime] = None, + id: Optional[str] = None, + created: Optional[datetime] = None, + pool_id: Optional[str] = None + ) -> None: """Method generated by attrs for class PoolUserRestriction. """ ... @@ -120,7 +145,16 @@ class ProjectUserRestriction(UserRestriction): project_id: Project identifier to which access will be denied. """ - def __init__(self, *, user_id: Optional[str] = None, private_comment: Optional[str] = None, will_expire: Optional[datetime] = None, id: Optional[str] = None, created: Optional[datetime] = None, project_id: Optional[str] = None) -> None: + def __init__( + self, + *, + user_id: Optional[str] = None, + private_comment: Optional[str] = None, + will_expire: Optional[datetime] = None, + id: Optional[str] = None, + created: Optional[datetime] = None, + project_id: Optional[str] = None + ) -> None: """Method generated by attrs for class ProjectUserRestriction. """ ... @@ -138,7 +172,15 @@ class SystemUserRestriction(UserRestriction): """DEPRECATED """ - def __init__(self, *, user_id: Optional[str] = None, private_comment: Optional[str] = None, will_expire: Optional[datetime] = None, id: Optional[str] = None, created: Optional[datetime] = None) -> None: + def __init__( + self, + *, + user_id: Optional[str] = None, + private_comment: Optional[str] = None, + will_expire: Optional[datetime] = None, + id: Optional[str] = None, + created: Optional[datetime] = None + ) -> None: """Method generated by attrs for class SystemUserRestriction. """ ... diff --git a/src/client/user_skill.pyi b/src/client/user_skill.pyi index 80a988d5..8ec66d04 100644 --- a/src/client/user_skill.pyi +++ b/src/client/user_skill.pyi @@ -19,7 +19,13 @@ class SetUserSkillRequest(BaseTolokaObject): value: Fractional value of the skill. Minimum - 0, maximum - 100. """ - def __init__(self, *, skill_id: Optional[str] = None, user_id: Optional[str] = None, value: Optional[Decimal] = None) -> None: + def __init__( + self, + *, + skill_id: Optional[str] = None, + user_id: Optional[str] = None, + value: Optional[Decimal] = None + ) -> None: """Method generated by attrs for class SetUserSkillRequest. """ ... @@ -43,7 +49,17 @@ class UserSkill(BaseTolokaObject): modified: Date and time of the last skill change for the performer. """ - def __init__(self, *, id: Optional[str] = None, skill_id: Optional[str] = None, user_id: Optional[str] = None, value: Optional[int] = None, exact_value: Optional[Decimal] = None, created: Optional[datetime] = None, modified: Optional[datetime] = None) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + skill_id: Optional[str] = None, + user_id: Optional[str] = None, + value: Optional[int] = None, + exact_value: Optional[Decimal] = None, + created: Optional[datetime] = None, + modified: Optional[datetime] = None + ) -> None: """Method generated by attrs for class UserSkill. """ ... diff --git a/src/client/webhook_subscription.pyi b/src/client/webhook_subscription.pyi index 47892ca0..50325c06 100644 --- a/src/client/webhook_subscription.pyi +++ b/src/client/webhook_subscription.pyi @@ -3,8 +3,8 @@ from enum import Enum from toloka.client.primitives.base import BaseTolokaObject from typing import ( Any, - Optional, - Dict + Dict, + Optional ) class WebhookSubscription(BaseTolokaObject): @@ -41,7 +41,16 @@ class WebhookSubscription(BaseTolokaObject): ASSIGNMENT_APPROVED = 'ASSIGNMENT_APPROVED' ASSIGNMENT_REJECTED = 'ASSIGNMENT_REJECTED' - def __init__(self, *, webhook_url: Optional[str] = None, event_type: Optional[EventType] = None, pool_id: Optional[str] = None, secret_key: Optional[str] = None, id: Optional[str] = None, created: Optional[datetime] = None) -> None: + def __init__( + self, + *, + webhook_url: Optional[str] = None, + event_type: Optional[EventType] = None, + pool_id: Optional[str] = None, + secret_key: Optional[str] = None, + id: Optional[str] = None, + created: Optional[datetime] = None + ) -> None: """Method generated by attrs for class WebhookSubscription. """ ... From 31b23dbbec49906cc228d026da36167ded93f1d1 Mon Sep 17 00:00:00 2001 From: Stepan Nosov Date: Wed, 14 Jul 2021 13:31:33 +0300 Subject: [PATCH 3/8] allow positional arguments in template builder ![review](https://codereview.in.yandex-team.ru/badges/review-complete-green.svg) [![tulinev](https://codereview.in.yandex-team.ru/badges/tulinev-ok-green.svg)](https://staff.yandex-team.ru/tulinev) ref:559eeebbcc733a4d740ce28cf47104a82d937a2c --- .../project/template_builder/__init__.py | 2 + .../project/template_builder/__init__.pyi | 2 + .../project/template_builder/actions.py | 26 +- .../project/template_builder/actions.pyi | 49 ++-- src/client/project/template_builder/base.py | 25 +- src/client/project/template_builder/base.pyi | 23 +- .../project/template_builder/conditions.py | 52 ++-- .../project/template_builder/conditions.pyi | 133 +++++---- src/client/project/template_builder/data.py | 21 +- src/client/project/template_builder/data.pyi | 6 - src/client/project/template_builder/fields.py | 175 +++++++----- .../project/template_builder/fields.pyi | 253 +++++++++-------- .../project/template_builder/helpers.py | 16 +- .../project/template_builder/helpers.pyi | 75 +++--- .../project/template_builder/layouts.py | 38 +-- .../project/template_builder/layouts.pyi | 57 ++-- .../project/template_builder/plugins.py | 100 +++---- .../project/template_builder/plugins.pyi | 35 ++- src/client/project/template_builder/view.py | 146 +++++----- src/client/project/template_builder/view.pyi | 254 +++++------------- .../template_builder/test_template_builder.py | 130 +++++---- 21 files changed, 798 insertions(+), 820 deletions(-) diff --git a/src/client/project/template_builder/__init__.py b/src/client/project/template_builder/__init__.py index b94bc0d8..93be31e8 100644 --- a/src/client/project/template_builder/__init__.py +++ b/src/client/project/template_builder/__init__.py @@ -22,6 +22,7 @@ 'ToggleActionV1', 'AllConditionV1', 'AnyConditionV1', + 'DistanceConditionV1', 'EmptyConditionV1', 'EqualsConditionV1', 'LinkOpenedConditionV1', @@ -113,6 +114,7 @@ from .conditions import ( AllConditionV1, AnyConditionV1, + DistanceConditionV1, EmptyConditionV1, EqualsConditionV1, LinkOpenedConditionV1, diff --git a/src/client/project/template_builder/__init__.pyi b/src/client/project/template_builder/__init__.pyi index 09dd1c88..aceea68b 100644 --- a/src/client/project/template_builder/__init__.pyi +++ b/src/client/project/template_builder/__init__.pyi @@ -21,6 +21,7 @@ __all__ = [ 'ToggleActionV1', 'AllConditionV1', 'AnyConditionV1', + 'DistanceConditionV1', 'EmptyConditionV1', 'EqualsConditionV1', 'LinkOpenedConditionV1', @@ -103,6 +104,7 @@ from toloka.client.project.template_builder.base import BaseComponent from toloka.client.project.template_builder.conditions import ( AllConditionV1, AnyConditionV1, + DistanceConditionV1, EmptyConditionV1, EqualsConditionV1, LinkOpenedConditionV1, diff --git a/src/client/project/template_builder/actions.py b/src/client/project/template_builder/actions.py index b243f3f6..3d1f7e6e 100644 --- a/src/client/project/template_builder/actions.py +++ b/src/client/project/template_builder/actions.py @@ -12,10 +12,18 @@ from enum import Enum, unique from typing import List, Any -from .base import BaseTemplate, ComponentType, RefComponent, BaseComponent, VersionedBaseComponent, base_component_or - - -class BaseActionV1(VersionedBaseComponent): +from ...primitives.base import attribute +from .base import ( + BaseTemplate, + ComponentType, + RefComponent, + BaseComponent, + VersionedBaseComponentMetaclass, + base_component_or +) + + +class BaseActionV1(BaseComponent, metaclass=VersionedBaseComponentMetaclass): """Perform various actions, such as showing notifications. """ @@ -48,12 +56,12 @@ class Payload(BaseTemplate): Attributes: content: Message text + theme: The background color of the message. delay: The duration of the delay (in milliseconds) before the message appears. duration: The duration of the message activity (in milliseconds), which includes the duration of the delay before displaying it. For example, if duration is 1000 and delay is 400, the message will be displayed for 600 milliseconds. - theme: The background color of the message. """ @unique @@ -74,8 +82,8 @@ class Theme(Enum): content: base_component_or(Any) theme: base_component_or(Theme) - delay: base_component_or(float) - duration: base_component_or(float) + delay: base_component_or(float) = attribute(kw_only=True) + duration: base_component_or(float) = attribute(kw_only=True) payload: base_component_or(Payload) @@ -122,8 +130,8 @@ class RotateActionV1(BaseActionV1, spec_value=ComponentType.ACTION_ROTATE): By default it rotates to the right, but you can specify the direction in the payload property. Attributes: - payload: Sets the direction of rotation. view: Points to the component to perform the action with. + payload: Sets the direction of rotation. """ @unique @@ -131,8 +139,8 @@ class Payload(Enum): LEFT = 'left' RIGHT = 'right' - payload: base_component_or(Payload) view: base_component_or(RefComponent) + payload: base_component_or(Payload) class SetActionV1(BaseActionV1, spec_value=ComponentType.ACTION_SET): diff --git a/src/client/project/template_builder/actions.pyi b/src/client/project/template_builder/actions.pyi index 076a7799..28a0764a 100644 --- a/src/client/project/template_builder/actions.pyi +++ b/src/client/project/template_builder/actions.pyi @@ -2,8 +2,7 @@ from enum import Enum from toloka.client.project.template_builder.base import ( BaseComponent, BaseTemplate, - RefComponent, - VersionedBaseComponent + RefComponent ) from typing import ( Any, @@ -13,7 +12,7 @@ from typing import ( Union ) -class BaseActionV1(VersionedBaseComponent): +class BaseActionV1(BaseComponent): """Perform various actions, such as showing notifications. """ @@ -37,9 +36,9 @@ class BulkActionV1(BaseActionV1): def __init__( self, + payload: Optional[Union[BaseComponent, List[BaseComponent]]] = None, *, - version: Optional[str] = '1.0.0', - payload: Optional[Union[BaseComponent, List[BaseComponent]]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class BulkActionV1. """ @@ -63,12 +62,12 @@ class NotifyActionV1(BaseActionV1): Attributes: content: Message text + theme: The background color of the message. delay: The duration of the delay (in milliseconds) before the message appears. duration: The duration of the message activity (in milliseconds), which includes the duration of the delay before displaying it. For example, if duration is 1000 and delay is 400, the message will be displayed for 600 milliseconds. - theme: The background color of the message. """ class Theme(Enum): @@ -88,9 +87,9 @@ class NotifyActionV1(BaseActionV1): def __init__( self, - *, content: Optional[Any] = None, theme: Optional[Union[BaseComponent, Theme]] = None, + *, delay: Optional[Union[BaseComponent, float]] = None, duration: Optional[Union[BaseComponent, float]] = None ) -> None: @@ -106,9 +105,9 @@ class NotifyActionV1(BaseActionV1): def __init__( self, + payload: Optional[Union[BaseComponent, Payload]] = None, *, - version: Optional[str] = '1.0.0', - payload: Optional[Union[BaseComponent, Payload]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class NotifyActionV1. """ @@ -131,9 +130,9 @@ class OpenCloseActionV1(BaseActionV1): def __init__( self, + view: Optional[Union[BaseComponent, RefComponent]] = None, *, - version: Optional[str] = '1.0.0', - view: Optional[Union[BaseComponent, RefComponent]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class OpenCloseActionV1. """ @@ -154,9 +153,9 @@ class OpenLinkActionV1(BaseActionV1): def __init__( self, + payload: Optional[Any] = None, *, - version: Optional[str] = '1.0.0', - payload: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class OpenLinkActionV1. """ @@ -179,9 +178,9 @@ class PlayPauseActionV1(BaseActionV1): def __init__( self, + view: Optional[Union[BaseComponent, RefComponent]] = None, *, - version: Optional[str] = '1.0.0', - view: Optional[Union[BaseComponent, RefComponent]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class PlayPauseActionV1. """ @@ -197,8 +196,8 @@ class RotateActionV1(BaseActionV1): By default it rotates to the right, but you can specify the direction in the payload property. Attributes: - payload: Sets the direction of rotation. view: Points to the component to perform the action with. + payload: Sets the direction of rotation. """ class Payload(Enum): @@ -210,10 +209,10 @@ class RotateActionV1(BaseActionV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', + view: Optional[Union[BaseComponent, RefComponent]] = None, payload: Optional[Union[BaseComponent, Payload]] = None, - view: Optional[Union[BaseComponent, RefComponent]] = None + *, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class RotateActionV1. """ @@ -221,8 +220,8 @@ class RotateActionV1(BaseActionV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - payload: Optional[Union[BaseComponent, Payload]] view: Optional[Union[BaseComponent, RefComponent]] + payload: Optional[Union[BaseComponent, Payload]] class SetActionV1(BaseActionV1): @@ -235,10 +234,10 @@ class SetActionV1(BaseActionV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, - payload: Optional[Any] = None + payload: Optional[Any] = None, + *, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class SetActionV1. """ @@ -259,9 +258,9 @@ class ToggleActionV1(BaseActionV1): def __init__( self, + data: Optional[BaseComponent] = None, *, - version: Optional[str] = '1.0.0', - data: Optional[BaseComponent] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class ToggleActionV1. """ diff --git a/src/client/project/template_builder/base.py b/src/client/project/template_builder/base.py index 8ad531d7..e8cf5789 100644 --- a/src/client/project/template_builder/base.py +++ b/src/client/project/template_builder/base.py @@ -1,10 +1,11 @@ __all__ = [ 'ComponentType', + 'BaseTemplateMetaclass', 'BaseTemplate', 'BaseComponent', 'BaseComponentOr', 'base_component_or', - 'VersionedBaseComponent', + 'VersionedBaseComponentMetaclass', 'UnknownComponent', 'RefComponent', 'ListDirection', @@ -99,7 +100,12 @@ class ComponentType(Enum): VIEW_VIDEO = 'view.video' -class BaseTemplate(BaseTolokaObject): +class BaseTemplateMetaclass(BaseTolokaObjectMetaclass): + def __new__(mcs, *args, kw_only=False, **kwargs): + return super().__new__(mcs, *args, kw_only=kw_only, **kwargs) + + +class BaseTemplate(BaseTolokaObject, metaclass=BaseTemplateMetaclass): @classmethod def structure(cls, data: dict): @@ -147,14 +153,23 @@ def base_component_or(type_: Type, class_name_suffix: Optional[str] = None): return base_component_or._cache[type_] -class VersionedBaseComponent(BaseComponent): +class VersionedBaseComponentMetaclass(BaseTemplateMetaclass): def _validate_v1(self, attribute, value: str) -> str: if not value.startswith('1.'): raise ValueError('only v1 components are supported') return value - version: str = attribute(default='1.0.0', validator=_validate_v1, on_setattr=_validate_v1) + def __new__(mcs, name, bases, namespace, **kwargs): + if 'version' not in namespace: + namespace['version'] = attribute( + default='1.0.0', + validator=VersionedBaseComponentMetaclass._validate_v1, + on_setattr=VersionedBaseComponentMetaclass._validate_v1, + kw_only=True + ) + namespace.setdefault('__annotations__', {})['version'] = str + return super().__new__(mcs, name, bases, namespace, **kwargs) class UnknownComponent(BaseTemplate): @@ -167,7 +182,7 @@ class RefComponent(BaseTemplate): This helps make your configuration shorter and makes it easier for you to edit duplicate chunks of code. You can insert a code snippet from another part of the configuration anywhere inside the configuration. To do this, - use the structure RefComponent(ref="path.to.element"). + use the structure RefComponent("path.to.element"). This is useful when you need to insert the same snippet at multiple places in your code. For example, if you need to run the same action using multiple buttons, put this action in a variable and call it using RefComponent. diff --git a/src/client/project/template_builder/base.pyi b/src/client/project/template_builder/base.pyi index 5ca7ef5e..9a2b0019 100644 --- a/src/client/project/template_builder/base.pyi +++ b/src/client/project/template_builder/base.pyi @@ -1,5 +1,8 @@ from enum import Enum -from toloka.client.primitives.base import BaseTolokaObject +from toloka.client.primitives.base import ( + BaseTolokaObject, + BaseTolokaObjectMetaclass +) from typing import ( Any, Dict, @@ -89,6 +92,10 @@ class ComponentType(Enum): VIEW_VIDEO = 'view.video' +class BaseTemplateMetaclass(BaseTolokaObjectMetaclass): + ... + + class BaseTemplate(BaseTolokaObject): def __init__(self) -> None: """Method generated by attrs for class BaseTemplate. @@ -128,14 +135,8 @@ class BaseComponentOr(BaseTolokaObject): def base_component_or(type_: Type, class_name_suffix: Optional[str] = None): ... -class VersionedBaseComponent(BaseComponent): - def __init__(self, *, version: Optional[str] = '1.0.0') -> None: - """Method generated by attrs for class VersionedBaseComponent. - """ - ... - - _unexpected: Optional[Dict[str, Any]] - version: Optional[str] +class VersionedBaseComponentMetaclass(BaseTemplateMetaclass): + ... class UnknownComponent(BaseTemplate): @@ -153,13 +154,13 @@ class RefComponent(BaseTemplate): This helps make your configuration shorter and makes it easier for you to edit duplicate chunks of code. You can insert a code snippet from another part of the configuration anywhere inside the configuration. To do this, - use the structure RefComponent(ref="path.to.element"). + use the structure RefComponent("path.to.element"). This is useful when you need to insert the same snippet at multiple places in your code. For example, if you need to run the same action using multiple buttons, put this action in a variable and call it using RefComponent. """ - def __init__(self, *, ref: Optional[str] = None) -> None: + def __init__(self, ref: Optional[str] = None) -> None: """Method generated by attrs for class RefComponent. """ ... diff --git a/src/client/project/template_builder/conditions.py b/src/client/project/template_builder/conditions.py index 675ec2a7..08351dd6 100644 --- a/src/client/project/template_builder/conditions.py +++ b/src/client/project/template_builder/conditions.py @@ -17,16 +17,24 @@ from ...primitives.base import attribute -from .base import BaseComponent, ComponentType, VersionedBaseComponent, base_component_or +from .base import BaseComponent, ComponentType, VersionedBaseComponentMetaclass, base_component_or -class BaseConditionV1(VersionedBaseComponent): +class BaseConditionV1Metaclass(VersionedBaseComponentMetaclass): + def __new__(mcs, name, bases, namespace, **kwargs): + if 'hint' not in namespace: + namespace['hint'] = attribute(kw_only=True) + namespace.setdefault('__annotations__', {})['hint'] = base_component_or(Any) + return super().__new__(mcs, name, bases, namespace, **kwargs) + + +class BaseConditionV1(BaseComponent, metaclass=BaseConditionV1Metaclass): """Check an expression against a condition. For example, you can check that a text field is filled in. """ - hint: base_component_or(Any) + pass class AllConditionV1(BaseConditionV1, spec_value=ComponentType.CONDITION_ALL): @@ -44,15 +52,15 @@ class AllConditionV1(BaseConditionV1, spec_value=ComponentType.CONDITION_ALL): How to check several conditions. >>> coordinates_validation = tb.conditions.AllConditionV1( - >>> conditions=[ + >>> [ >>> tb.conditions.RequiredConditionV1( - >>> data=tb.data.OutputData(path='performer_coordinates'), + >>> tb.data.OutputData('performer_coordinates'), >>> hint="Couldn't get your coordinates. Please enable geolocation.", >>> ), >>> tb.conditions.DistanceConditionV1( - >>> x=tb.data.LocationData(), - >>> y=tb.data.InputData(path='coordinates'), - >>> max=500, + >>> tb.data.LocationData(), + >>> tb.data.InputData('coordinates'), + >>> 500, >>> hint='You are too far from the destination coordinates.', >>> ), >>> ], @@ -93,9 +101,9 @@ class DistanceConditionV1(BaseConditionV1, spec_value=ComponentType.CONDITION_YA How to check that performer is in the right place. >>> distance_condition = tb.conditions.DistanceConditionV1( - >>> from_=tb.data.LocationData(), - >>> to_=tb.data.InputData(path='coordinates'), - >>> max=500, + >>> tb.data.LocationData(), + >>> tb.data.InputData('coordinates'), + >>> 500, >>> hint='You are too far from the destination coordinates.', >>> ), ... @@ -130,6 +138,12 @@ class EqualsConditionV1(BaseConditionV1, spec_value=ComponentType.CONDITION_EQUA When substituting values, you can refer to data.* or another element using $ref. You can also use helpers and conditions to get the value. Attributes: + to: The value to compare with the original. + How to pass a value: + * Specify the value itself, like the number 42 or a string. + * Get the value from your data. + * Refer to another element using $ref. + * Use helpers and conditions to get the value. data: Original value. If not specified, it uses the value returned by the parent component (the component that contains condition.equals). How to pass a value: @@ -138,12 +152,6 @@ class EqualsConditionV1(BaseConditionV1, spec_value=ComponentType.CONDITION_EQUA * Refer to another element using $ref. * Use helpers and conditions to get the value. hint: Validation error message that the user will see. - to: The value to compare with the original. - How to pass a value: - * Specify the value itself, like the number 42 or a string. - * Get the value from your data. - * Refer to another element using $ref. - * Use helpers and conditions to get the value. """ to: base_component_or(Any) @@ -158,8 +166,8 @@ class LinkOpenedConditionV1(BaseConditionV1, spec_value=ComponentType.CONDITION_ This condition can be used in the view.link component and also anywhere you can use (conditions). Attributes: - hint: Validation error message that the user will see. url: The link that must be clicked. + hint: Validation error message that the user will see. """ url: base_component_or(Any) @@ -215,8 +223,8 @@ class RequiredConditionV1(BaseConditionV1, spec_value=ComponentType.CONDITION_RE How to check that image is uploaded. >>> image = tb.fields.MediaFileFieldV1( - >>> data=tb.data.OutputData(path='image'), - >>> accept=tb.fields.MediaFileFieldV1.Accept(photo=True, gallery=True), + >>> tb.data.OutputData('image'), + >>> tb.fields.MediaFileFieldV1.Accept(photo=True, gallery=True), >>> validation=tb.conditions.RequiredConditionV1(hint='Your must upload photo.'), >>> ) ... @@ -236,8 +244,8 @@ class SchemaConditionV1(BaseConditionV1, spec_value=ComponentType.CONDITION_SCHE * If you already have a prepared JSON Schema configuration for the check and you want to use it. Attributes: data: Data that should be checked. - hint: Validation error message that the user will see. schema: The schema for validating data. + hint: Validation error message that the user will see. """ data: base_component_or(Any) @@ -249,8 +257,8 @@ class SubArrayConditionV1(BaseConditionV1, spec_value=ComponentType.CONDITION_SU Attributes: data: Subarray that is checked for in parent. - hint: Validation error message that the user will see. parent: The array where data is searched for. + hint: Validation error message that the user will see. """ data: base_component_or(Any) diff --git a/src/client/project/template_builder/conditions.pyi b/src/client/project/template_builder/conditions.pyi index 1538a04d..33e3d542 100644 --- a/src/client/project/template_builder/conditions.pyi +++ b/src/client/project/template_builder/conditions.pyi @@ -1,7 +1,4 @@ -from toloka.client.project.template_builder.base import ( - BaseComponent, - VersionedBaseComponent -) +from toloka.client.project.template_builder.base import BaseComponent from typing import ( Any, Dict, @@ -10,7 +7,7 @@ from typing import ( Union ) -class BaseConditionV1(VersionedBaseComponent): +class BaseConditionV1(BaseComponent): """Check an expression against a condition. For example, you can check that a text field is filled in. @@ -19,16 +16,16 @@ class BaseConditionV1(VersionedBaseComponent): def __init__( self, *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None + hint: Optional[Any] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class BaseConditionV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] hint: Optional[Any] + version: Optional[str] class AllConditionV1(BaseConditionV1): @@ -46,15 +43,15 @@ class AllConditionV1(BaseConditionV1): How to check several conditions. >>> coordinates_validation = tb.conditions.AllConditionV1( - >>> conditions=[ + >>> [ >>> tb.conditions.RequiredConditionV1( - >>> data=tb.data.OutputData(path='performer_coordinates'), + >>> tb.data.OutputData('performer_coordinates'), >>> hint="Couldn't get your coordinates. Please enable geolocation.", >>> ), >>> tb.conditions.DistanceConditionV1( - >>> x=tb.data.LocationData(), - >>> y=tb.data.InputData(path='coordinates'), - >>> max=500, + >>> tb.data.LocationData(), + >>> tb.data.InputData('coordinates'), + >>> 500, >>> hint='You are too far from the destination coordinates.', >>> ), >>> ], @@ -64,18 +61,18 @@ class AllConditionV1(BaseConditionV1): def __init__( self, + conditions: Optional[Union[BaseComponent, List[BaseComponent]]] = None, *, - version: Optional[str] = '1.0.0', hint: Optional[Any] = None, - conditions: Optional[Union[BaseComponent, List[BaseComponent]]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class AllConditionV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] hint: Optional[Any] + version: Optional[str] conditions: Optional[Union[BaseComponent, List[BaseComponent]]] @@ -92,18 +89,18 @@ class AnyConditionV1(BaseConditionV1): def __init__( self, + conditions: Optional[Union[BaseComponent, List[BaseComponent]]] = None, *, - version: Optional[str] = '1.0.0', hint: Optional[Any] = None, - conditions: Optional[Union[BaseComponent, List[BaseComponent]]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class AnyConditionV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] hint: Optional[Any] + version: Optional[str] conditions: Optional[Union[BaseComponent, List[BaseComponent]]] @@ -123,9 +120,9 @@ class DistanceConditionV1(BaseConditionV1): How to check that performer is in the right place. >>> distance_condition = tb.conditions.DistanceConditionV1( - >>> from_=tb.data.LocationData(), - >>> to_=tb.data.InputData(path='coordinates'), - >>> max=500, + >>> tb.data.LocationData(), + >>> tb.data.InputData('coordinates'), + >>> 500, >>> hint='You are too far from the destination coordinates.', >>> ), ... @@ -133,20 +130,20 @@ class DistanceConditionV1(BaseConditionV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, from_: Optional[Union[BaseComponent, str]] = None, to_: Optional[Union[BaseComponent, str]] = None, - max: Optional[Union[BaseComponent, float]] = None + max: Optional[Union[BaseComponent, float]] = None, + *, + hint: Optional[Any] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class DistanceConditionV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] hint: Optional[Any] + version: Optional[str] from_: Optional[Union[BaseComponent, str]] to_: Optional[Union[BaseComponent, str]] max: Optional[Union[BaseComponent, float]] @@ -167,18 +164,18 @@ class EmptyConditionV1(BaseConditionV1): def __init__( self, + data: Optional[Any] = None, *, - version: Optional[str] = '1.0.0', hint: Optional[Any] = None, - data: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class EmptyConditionV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] hint: Optional[Any] + version: Optional[str] data: Optional[Any] @@ -190,6 +187,12 @@ class EqualsConditionV1(BaseConditionV1): When substituting values, you can refer to data.* or another element using $ref. You can also use helpers and conditions to get the value. Attributes: + to: The value to compare with the original. + How to pass a value: + * Specify the value itself, like the number 42 or a string. + * Get the value from your data. + * Refer to another element using $ref. + * Use helpers and conditions to get the value. data: Original value. If not specified, it uses the value returned by the parent component (the component that contains condition.equals). How to pass a value: @@ -198,29 +201,23 @@ class EqualsConditionV1(BaseConditionV1): * Refer to another element using $ref. * Use helpers and conditions to get the value. hint: Validation error message that the user will see. - to: The value to compare with the original. - How to pass a value: - * Specify the value itself, like the number 42 or a string. - * Get the value from your data. - * Refer to another element using $ref. - * Use helpers and conditions to get the value. """ def __init__( self, + to: Optional[Any] = None, + data: Optional[Any] = None, *, - version: Optional[str] = '1.0.0', hint: Optional[Any] = None, - to: Optional[Any] = None, - data: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class EqualsConditionV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] hint: Optional[Any] + version: Optional[str] to: Optional[Any] data: Optional[Any] @@ -233,24 +230,24 @@ class LinkOpenedConditionV1(BaseConditionV1): This condition can be used in the view.link component and also anywhere you can use (conditions). Attributes: - hint: Validation error message that the user will see. url: The link that must be clicked. + hint: Validation error message that the user will see. """ def __init__( self, + url: Optional[Any] = None, *, - version: Optional[str] = '1.0.0', hint: Optional[Any] = None, - url: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class LinkOpenedConditionV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] hint: Optional[Any] + version: Optional[str] url: Optional[Any] @@ -265,18 +262,18 @@ class NotConditionV1(BaseConditionV1): def __init__( self, + condition: Optional[BaseComponent] = None, *, - version: Optional[str] = '1.0.0', hint: Optional[Any] = None, - condition: Optional[BaseComponent] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class NotConditionV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] hint: Optional[Any] + version: Optional[str] condition: Optional[BaseComponent] @@ -292,16 +289,16 @@ class PlayedConditionV1(BaseConditionV1): def __init__( self, *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None + hint: Optional[Any] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class PlayedConditionV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] hint: Optional[Any] + version: Optional[str] class PlayedFullyConditionV1(BaseConditionV1): @@ -316,16 +313,16 @@ class PlayedFullyConditionV1(BaseConditionV1): def __init__( self, *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None + hint: Optional[Any] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class PlayedFullyConditionV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] hint: Optional[Any] + version: Optional[str] class RequiredConditionV1(BaseConditionV1): @@ -342,8 +339,8 @@ class RequiredConditionV1(BaseConditionV1): How to check that image is uploaded. >>> image = tb.fields.MediaFileFieldV1( - >>> data=tb.data.OutputData(path='image'), - >>> accept=tb.fields.MediaFileFieldV1.Accept(photo=True, gallery=True), + >>> tb.data.OutputData('image'), + >>> tb.fields.MediaFileFieldV1.Accept(photo=True, gallery=True), >>> validation=tb.conditions.RequiredConditionV1(hint='Your must upload photo.'), >>> ) ... @@ -351,18 +348,18 @@ class RequiredConditionV1(BaseConditionV1): def __init__( self, + data: Optional[Any] = None, *, - version: Optional[str] = '1.0.0', hint: Optional[Any] = None, - data: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class RequiredConditionV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] hint: Optional[Any] + version: Optional[str] data: Optional[Any] @@ -377,25 +374,25 @@ class SchemaConditionV1(BaseConditionV1): * If you already have a prepared JSON Schema configuration for the check and you want to use it. Attributes: data: Data that should be checked. - hint: Validation error message that the user will see. schema: The schema for validating data. + hint: Validation error message that the user will see. """ def __init__( self, + data: Optional[Any] = None, + schema: Optional[Dict] = None, *, - version: Optional[str] = '1.0.0', hint: Optional[Any] = None, - data: Optional[Any] = None, - schema: Optional[Dict] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class SchemaConditionV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] hint: Optional[Any] + version: Optional[str] data: Optional[Any] schema: Optional[Dict] @@ -405,24 +402,24 @@ class SubArrayConditionV1(BaseConditionV1): Attributes: data: Subarray that is checked for in parent. - hint: Validation error message that the user will see. parent: The array where data is searched for. + hint: Validation error message that the user will see. """ def __init__( self, + data: Optional[Any] = None, + parent: Optional[Any] = None, *, - version: Optional[str] = '1.0.0', hint: Optional[Any] = None, - data: Optional[Any] = None, - parent: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class SubArrayConditionV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] hint: Optional[Any] + version: Optional[str] data: Optional[Any] parent: Optional[Any] diff --git a/src/client/project/template_builder/data.py b/src/client/project/template_builder/data.py index 42135c32..996e62e5 100644 --- a/src/client/project/template_builder/data.py +++ b/src/client/project/template_builder/data.py @@ -9,16 +9,29 @@ ] from typing import Any -from .base import BaseComponent, ComponentType, base_component_or +from ...primitives.base import attribute +from .base import BaseComponent, ComponentType, base_component_or, BaseTemplateMetaclass -class BaseData(BaseComponent): +class BaseDataMetaclass(BaseTemplateMetaclass): + def __new__(mcs, name, bases, namespace, **kwargs): + + if 'path' not in namespace: + namespace['path'] = attribute() + namespace.setdefault('__annotations__', {})['path'] = base_component_or(Any) + if 'default' not in namespace: + namespace['default'] = attribute() + namespace.setdefault('__annotations__', {})['default'] = base_component_or(Any) + + return super().__new__(mcs, name, bases, namespace, **kwargs) + + +class BaseData(BaseComponent, metaclass=BaseDataMetaclass): """Components used for working with data: input, output, or intermediate. """ - path: base_component_or(Any) - default: base_component_or(Any) + pass class InputData(BaseData, spec_value=ComponentType.DATA_INPUT): diff --git a/src/client/project/template_builder/data.pyi b/src/client/project/template_builder/data.pyi index 647b58ad..d6952da7 100644 --- a/src/client/project/template_builder/data.pyi +++ b/src/client/project/template_builder/data.pyi @@ -11,7 +11,6 @@ class BaseData(BaseComponent): def __init__( self, - *, path: Optional[Any] = None, default: Optional[Any] = None ) -> None: @@ -38,7 +37,6 @@ class InputData(BaseData): def __init__( self, - *, path: Optional[Any] = None, default: Optional[Any] = None ) -> None: @@ -64,7 +62,6 @@ class InternalData(BaseData): def __init__( self, - *, path: Optional[Any] = None, default: Optional[Any] = None ) -> None: @@ -90,7 +87,6 @@ class LocalData(BaseData): def __init__( self, - *, path: Optional[Any] = None, default: Optional[Any] = None ) -> None: @@ -130,7 +126,6 @@ class OutputData(BaseData): def __init__( self, - *, path: Optional[Any] = None, default: Optional[Any] = None ) -> None: @@ -156,7 +151,6 @@ class RelativeData(BaseData): def __init__( self, - *, path: Optional[Any] = None, default: Optional[Any] = None ) -> None: diff --git a/src/client/project/template_builder/fields.py b/src/client/project/template_builder/fields.py index f06d1a81..3e6d836c 100644 --- a/src/client/project/template_builder/fields.py +++ b/src/client/project/template_builder/fields.py @@ -23,19 +23,43 @@ from ...primitives.base import attribute -from .base import BaseComponent, ListDirection, ListSize, ComponentType, BaseTemplate, VersionedBaseComponent,\ +from .base import ( + BaseComponent, + ListDirection, + ListSize, + ComponentType, + BaseTemplate, + VersionedBaseComponentMetaclass, base_component_or - - -class BaseFieldV1(VersionedBaseComponent): +) + + +class BaseFieldV1Metaclass(VersionedBaseComponentMetaclass): + def __new__(mcs, name, bases, namespace, **kwargs): + annotations = namespace.setdefault('__annotations__', {}) + if 'data' not in namespace: + namespace['data'] = attribute() + annotation = {'data': BaseComponent} + annotations = {**annotation, **annotations} + if 'hint' not in namespace: + namespace['hint'] = attribute(kw_only=True) + annotations['hint'] = base_component_or(Any) + if 'label' not in namespace: + namespace['label'] = attribute(kw_only=True) + annotations['label'] = base_component_or(Any) + if 'validation' not in namespace: + namespace['validation'] = attribute(kw_only=True) + annotations['validation'] = BaseComponent + namespace['__annotations__'] = annotations + return super().__new__(mcs, name, bases, namespace, **kwargs) + + +class BaseFieldV1(BaseComponent, metaclass=BaseFieldV1Metaclass): """Fields for entering data, such as a text field or drop-down list. """ - data: BaseComponent - hint: base_component_or(Any) - label: base_component_or(Any) - validation: BaseComponent + pass class ButtonRadioFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_BUTTON_RADIO): @@ -46,10 +70,10 @@ class ButtonRadioFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_BUTTON_RADI The size of the button depends on the size of the label. Attributes: data: Data with values that will be processed or changed. + value_to_set: The value of the output data when the button is clicked. label: Label above the component. hint: Hint text. validation: Validation based on condition. - value_to_set: The value of the output data when the button is clicked. """ value_to_set: base_component_or(Any) = attribute(origin='valueToSet') @@ -59,14 +83,14 @@ class GroupFieldOption(BaseTemplate): """Option. Attributes: - hint: Additional information. - label: The text on the object. value: Returned value. + label: The text on the object. + hint: Additional information. """ - label: base_component_or(Any) value: base_component_or(Any) - hint: base_component_or(Any) + label: base_component_or(Any) + hint: base_component_or(Any) = attribute(kw_only=True) class ButtonRadioGroupFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_BUTTON_RADIO_GROUP): @@ -77,20 +101,20 @@ class ButtonRadioGroupFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_BUTTON The size of the button is determined by the length of the text on it. Attributes: data: Data with values that will be processed or changed. + options: Array of information about the buttons. label: Label above the component. hint: Hint text. - options: Array of information about the buttons. validation: Validation based on condition. Example: How to add buttons for classification task. >>> classification_buttons = tb.fields.ButtonRadioGroupFieldV1( - >>> options=[ - >>> tb.fields.GroupFieldOption(label='Cat', value='cat'), - >>> tb.fields.GroupFieldOption(label='Dog', value='dog'), + >>> tb.data.OutputData(path='class'), + >>> [ + >>> tb.fields.GroupFieldOption('Cat', 'cat'), + >>> tb.fields.GroupFieldOption('Dog', 'dog'), >>> ], - >>> data=tb.data.OutputData(path='class'), >>> validation=tb.conditions.RequiredConditionV1(hint='Choose one of the answer options'), >>> ) ... @@ -113,8 +137,8 @@ class CheckboxFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_CHECKBOX): validation: Validation based on condition. """ - disabled: base_component_or(bool) - preserve_false: base_component_or(bool) = attribute(origin='preserveFalse') + disabled: base_component_or(bool) = attribute(kw_only=True) + preserve_false: base_component_or(bool) = attribute(origin='preserveFalse', kw_only=True) class CheckboxGroupFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_CHECKBOX_GROUP): @@ -122,10 +146,10 @@ class CheckboxGroupFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_CHECKBOX_ Attributes: data: Data with values that will be processed or changed. + options: Options, where value is the key that the option controls, and label is the text near the option. label: Label above the component. disabled: If `true', the options are inactive. hint: Hint text. - options: Options, where value is the key that the option controls, and label is the text near the option. preserve_false: Property that specifies whether to return false values in the results. By default, if the component returns false, this result will not be added to the output. To add false to the results, specify "preserveFalse": true. @@ -133,8 +157,8 @@ class CheckboxGroupFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_CHECKBOX_ """ options: base_component_or(List[base_component_or(GroupFieldOption)], 'ListBaseComponentOrGroupFieldOption') - disabled: base_component_or(bool) - preserve_false: base_component_or(bool) = attribute(origin='preserveFalse') + disabled: base_component_or(bool) = attribute(kw_only=True) + preserve_false: base_component_or(bool) = attribute(origin='preserveFalse', kw_only=True) class DateFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_DATE): @@ -143,12 +167,12 @@ class DateFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_DATE): You can set a list of dates that the user cannot select. Attributes: data: Data with values that will be processed or changed. - label: Label above the component. - block_list: List of dates that the user cannot select. - * block_list[]: Date that the user cannot select. format: Format of the date entered by the user: * date-time — date and time. * date — date only. + label: Label above the component. + block_list: List of dates that the user cannot select. + * block_list[]: Date that the user cannot select. hint: Hint text. max: The latest date and time in the YYYY-MM-DD hh:mm format that the user can select. Where: * YYYY is the year. @@ -167,10 +191,13 @@ class DateFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_DATE): """ format: base_component_or(Any) - block_list: base_component_or(List[base_component_or(Any)], 'ListBaseComponentOrAny') = attribute(origin='') - max: base_component_or(Any) - min: base_component_or(Any) - placeholder: base_component_or(Any) + block_list: base_component_or(List[base_component_or(Any)], 'ListBaseComponentOrAny') = attribute( + origin='blockList', + kw_only=True + ) + max: base_component_or(Any) = attribute(kw_only=True) + min: base_component_or(Any) = attribute(kw_only=True) + placeholder: base_component_or(Any) = attribute(kw_only=True) class EmailFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_EMAIL): @@ -185,7 +212,7 @@ class EmailFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_EMAIL): validation: Validation based on condition. """ - placeholder: Any + placeholder: Any = attribute(kw_only=True) class FileFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_FILE): @@ -198,10 +225,10 @@ class FileFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_FILE): devices and makes it easier to upload photos and videos. Attributes: data: Data with values that will be processed or changed. - label: Label above the component. accept: A list of file types that can be uploaded. By default, you can upload any files. Specify the types in the format (https://developer.mozilla.org/en-US/docs/Web/HTTP/BasicsofHTTP/MIME_types). For example, you can allow only images to be uploaded by adding the image/jpeg and image/png types. + label: Label above the component. hint: Hint text. multiple: Determines whether multiple files can be uploaded: * false (default) — forbidden. @@ -210,7 +237,7 @@ class FileFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_FILE): """ accept: base_component_or(List[base_component_or(str)], 'ListBaseComponentOrStr') - multiple: base_component_or(bool) + multiple: base_component_or(bool) = attribute(kw_only=True) class ImageAnnotationFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_IMAGE_ANNOTATION): @@ -222,6 +249,7 @@ class ImageAnnotationFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_IMAGE_A selection modes and hide the rest. Attributes: data: Data with values that will be processed or changed. + image: The image you want to select areas in. label: Label above the component. disabled: Determines whether adding and deleting areas is allowed: * false (default) — Allowed. @@ -231,7 +259,6 @@ class ImageAnnotationFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_IMAGE_A full_height: If true, the element takes up all the vertical free space. The element is set to a minimum height of 400 pixels. hint: Hint text. - image: The image you want to select areas in. labels: Used to classify areas. You can add several area types. When adding an area type, a button to select it appears in the interface, and when setting a new value, a new area selection color is added. @@ -264,14 +291,14 @@ class Shape(Enum): POLYGON = 'polygon' RECTANGLE = 'rectangle' - disabled: base_component_or(bool) - full_height: base_component_or(bool) = attribute(origin='fullHeight') image: base_component_or(str) - labels: base_component_or(List[base_component_or(Label)], 'ListBaseComponentOrLabel') - min_width: base_component_or(float) = attribute(origin='minWidth') - ratio: base_component_or(List[base_component_or(float)], 'ListBaseComponentOrFloat') + disabled: base_component_or(bool) = attribute(kw_only=True) + full_height: base_component_or(bool) = attribute(origin='fullHeight', kw_only=True) + labels: base_component_or(List[base_component_or(Label)], 'ListBaseComponentOrLabel') = attribute(kw_only=True) + min_width: base_component_or(float) = attribute(origin='minWidth', kw_only=True) + ratio: base_component_or(List[base_component_or(float)], 'ListBaseComponentOrFloat') = attribute(kw_only=True) shapes: base_component_or(Dict[base_component_or(Shape), base_component_or(bool)], - 'DictBaseComponentOrShapeBaseComponentOrBool') + 'DictBaseComponentOrShapeBaseComponentOrBool') = attribute(kw_only=True) class ListFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_LIST): @@ -289,6 +316,9 @@ class ListFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_LIST): property to block users from changing a component, like when a certain event occurs. Attributes: data: Data with values that will be processed or changed. + render: Interface template for list items, such as a text field. + In nested field.* components, use data.relative for recording responses, otherwise all the list items will + have the same value. label: Label above the component. button_label: Text on the button for adding list items. direction: The direction of the list. @@ -296,19 +326,16 @@ class ListFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_LIST): By default it is true (allowed). hint: Hint text. max_length: Maximum number of list items. - render: Interface template for list items, such as a text field. - In nested field.* components, use data.relative for recording responses, otherwise all the list items will - have the same value. size: The distance between list items. Acceptable values in ascending order: s, m (default). validation: Validation based on condition. """ render: BaseComponent - button_label: base_component_or(Any) - direction: base_component_or(ListDirection) - editable: base_component_or(Any) - max_length: base_component_or(float) - size: base_component_or(ListSize) + button_label: base_component_or(Any) = attribute(kw_only=True) + direction: base_component_or(ListDirection) = attribute(kw_only=True) + editable: base_component_or(bool) = attribute(kw_only=True) + max_length: base_component_or(float) = attribute(kw_only=True) + size: base_component_or(ListSize) = attribute(kw_only=True) class MediaFileFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_MEDIA_FILE): @@ -320,9 +347,9 @@ class MediaFileFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_MEDIA_FILE): field.file for a more flexible configuration of the file types. Attributes: data: Data with values that will be processed or changed. - label: Label above the component. accept: Adds different buttons for four types of uploads. Pass the true value for the ones that you need. For example, if you need a button for uploading files from the gallery, add the "gallery": true property + label: Label above the component. hint: Hint text. multiple: Determines whether multiple files can be uploaded: validation: Validation based on condition. @@ -350,13 +377,13 @@ class Accept(BaseTemplate): video: Adds a button for uploading videos. """ - file_system: base_component_or(bool) = attribute(origin='fileSystem') - gallery: base_component_or(bool) - photo: base_component_or(bool) - video: base_component_or(bool) + file_system: base_component_or(bool) = attribute(origin='fileSystem', kw_only=True) + gallery: base_component_or(bool) = attribute(kw_only=True) + photo: base_component_or(bool) = attribute(kw_only=True) + video: base_component_or(bool) = attribute(kw_only=True) accept: base_component_or(Accept) - multiple: base_component_or(bool) + multiple: base_component_or(bool) = attribute(kw_only=True) class NumberFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_NUMBER): @@ -380,9 +407,9 @@ class NumberFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_NUMBER): validation: Validation based on condition. """ - maximum: base_component_or(int) - minimum: base_component_or(int) - placeholder: base_component_or(Any) + maximum: base_component_or(int) = attribute(kw_only=True) + minimum: base_component_or(int) = attribute(kw_only=True) + placeholder: base_component_or(Any) = attribute(kw_only=True) class PhoneNumberFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_PHONE_NUMBER): @@ -398,7 +425,7 @@ class PhoneNumberFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_PHONE_NUMBE validation: Validation based on condition. """ - placeholder: base_component_or(str) + placeholder: base_component_or(str) = attribute(kw_only=True) class RadioGroupFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_RADIO_GROUP): @@ -409,29 +436,29 @@ class RadioGroupFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_RADIO_GROUP) The minimum number of buttons is one. Any type of data can be returned. Attributes: data: Data with values that will be processed or changed. + options: List of options to choose from label: Label above the component. disabled: This property prevents clicking the button. If the value is true, the button is not active (the user will not be able to click it). hint: Hint text. - options: List of options to choose from validation: Validation based on condition. Example: How to add label selector to interface. >>> radio_group_field = tb.fields.RadioGroupFieldV1( - >>> data=tb.data.OutputData(path='result'), - >>> validation=tb.conditions.RequiredConditionV1(), - >>> options=[ - >>> tb.fields.GroupFieldOption(label='Cat', value='cat'), - >>> tb.fields.GroupFieldOption(label='Dog', value='dog'), - >>> ] + >>> tb.data.OutputData(path='result'), + >>> [ + >>> tb.fields.GroupFieldOption('Cat', 'cat'), + >>> tb.fields.GroupFieldOption('Dog', 'dog'), + >>> ], + >>> validation=tb.conditions.RequiredConditionV1() >>> ) ... """ options: base_component_or(List[base_component_or(GroupFieldOption)], 'ListBaseComponentOrGroupFieldOption') - disabled: base_component_or(bool) + disabled: base_component_or(bool) = attribute(kw_only=True) class SelectFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_SELECT): @@ -445,9 +472,9 @@ class SelectFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_SELECT): To allow selecting multiple options, use the field.checkbox-group component. Attributes: data: Data with values that will be processed or changed. + options: Options to choose from. label: Label above the component. hint: Hint text. - options: Options to choose from. placeholder: The text that will be displayed if none of the options is selected. validation: Validation based on condition. """ @@ -464,7 +491,7 @@ class Option(BaseTemplate): value: base_component_or(Any) options: base_component_or(Option) - placeholder: base_component_or(Any) + placeholder: base_component_or(Any) = attribute(kw_only=True) class TextFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_TEXT): @@ -479,8 +506,8 @@ class TextFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_TEXT): validation: Validation based on condition. """ - disabled: base_component_or(bool) - placeholder: base_component_or(Any) + disabled: base_component_or(bool) = attribute(kw_only=True) + placeholder: base_component_or(Any) = attribute(kw_only=True) class TextareaFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_TEXTAREA): @@ -504,7 +531,7 @@ class TextareaFieldV1(BaseFieldV1, spec_value=ComponentType.FIELD_TEXTAREA): rows: The height of the text box in lines. """ - disabled: base_component_or(bool) - placeholder: base_component_or(Any) - resizable: base_component_or(bool) - rows: base_component_or(float) + disabled: base_component_or(bool) = attribute(kw_only=True) + placeholder: base_component_or(Any) = attribute(kw_only=True) + resizable: base_component_or(bool) = attribute(kw_only=True) + rows: base_component_or(float) = attribute(kw_only=True) diff --git a/src/client/project/template_builder/fields.pyi b/src/client/project/template_builder/fields.pyi index 4e63dc01..7aa8a615 100644 --- a/src/client/project/template_builder/fields.pyi +++ b/src/client/project/template_builder/fields.pyi @@ -3,8 +3,7 @@ from toloka.client.project.template_builder.base import ( BaseComponent, BaseTemplate, ListDirection, - ListSize, - VersionedBaseComponent + ListSize ) from typing import ( Any, @@ -14,29 +13,29 @@ from typing import ( Union ) -class BaseFieldV1(VersionedBaseComponent): +class BaseFieldV1(BaseComponent): """Fields for entering data, such as a text field or drop-down list. """ def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, + *, hint: Optional[Any] = None, label: Optional[Any] = None, - validation: Optional[BaseComponent] = None + validation: Optional[BaseComponent] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class BaseFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] class ButtonRadioFieldV1(BaseFieldV1): @@ -47,32 +46,32 @@ class ButtonRadioFieldV1(BaseFieldV1): The size of the button depends on the size of the label. Attributes: data: Data with values that will be processed or changed. + value_to_set: The value of the output data when the button is clicked. label: Label above the component. hint: Hint text. validation: Validation based on condition. - value_to_set: The value of the output data when the button is clicked. """ def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, + value_to_set: Optional[Any] = None, + *, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, - value_to_set: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class ButtonRadioFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] value_to_set: Optional[Any] @@ -80,16 +79,16 @@ class GroupFieldOption(BaseTemplate): """Option. Attributes: - hint: Additional information. - label: The text on the object. value: Returned value. + label: The text on the object. + hint: Additional information. """ def __init__( self, - *, - label: Optional[Any] = None, value: Optional[Any] = None, + label: Optional[Any] = None, + *, hint: Optional[Any] = None ) -> None: """Method generated by attrs for class GroupFieldOption. @@ -97,8 +96,8 @@ class GroupFieldOption(BaseTemplate): ... _unexpected: Optional[Dict[str, Any]] - label: Optional[Any] value: Optional[Any] + label: Optional[Any] hint: Optional[Any] @@ -110,20 +109,20 @@ class ButtonRadioGroupFieldV1(BaseFieldV1): The size of the button is determined by the length of the text on it. Attributes: data: Data with values that will be processed or changed. + options: Array of information about the buttons. label: Label above the component. hint: Hint text. - options: Array of information about the buttons. validation: Validation based on condition. Example: How to add buttons for classification task. >>> classification_buttons = tb.fields.ButtonRadioGroupFieldV1( - >>> options=[ - >>> tb.fields.GroupFieldOption(label='Cat', value='cat'), - >>> tb.fields.GroupFieldOption(label='Dog', value='dog'), + >>> tb.data.OutputData(path='class'), + >>> [ + >>> tb.fields.GroupFieldOption('Cat', 'cat'), + >>> tb.fields.GroupFieldOption('Dog', 'dog'), >>> ], - >>> data=tb.data.OutputData(path='class'), >>> validation=tb.conditions.RequiredConditionV1(hint='Choose one of the answer options'), >>> ) ... @@ -131,24 +130,24 @@ class ButtonRadioGroupFieldV1(BaseFieldV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, + options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] = None, + *, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, - options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class ButtonRadioGroupFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] @@ -168,25 +167,25 @@ class CheckboxFieldV1(BaseFieldV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, + *, + disabled: Optional[Union[BaseComponent, bool]] = None, + preserve_false: Optional[Union[BaseComponent, bool]] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, - disabled: Optional[Union[BaseComponent, bool]] = None, - preserve_false: Optional[Union[BaseComponent, bool]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class CheckboxFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] disabled: Optional[Union[BaseComponent, bool]] preserve_false: Optional[Union[BaseComponent, bool]] @@ -196,10 +195,10 @@ class CheckboxGroupFieldV1(BaseFieldV1): Attributes: data: Data with values that will be processed or changed. + options: Options, where value is the key that the option controls, and label is the text near the option. label: Label above the component. disabled: If `true', the options are inactive. hint: Hint text. - options: Options, where value is the key that the option controls, and label is the text near the option. preserve_false: Property that specifies whether to return false values in the results. By default, if the component returns false, this result will not be added to the output. To add false to the results, specify "preserveFalse": true. @@ -208,26 +207,26 @@ class CheckboxGroupFieldV1(BaseFieldV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, + options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] = None, + *, + disabled: Optional[Union[BaseComponent, bool]] = None, + preserve_false: Optional[Union[BaseComponent, bool]] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, - options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] = None, - disabled: Optional[Union[BaseComponent, bool]] = None, - preserve_false: Optional[Union[BaseComponent, bool]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class CheckboxGroupFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] disabled: Optional[Union[BaseComponent, bool]] preserve_false: Optional[Union[BaseComponent, bool]] @@ -239,12 +238,12 @@ class DateFieldV1(BaseFieldV1): You can set a list of dates that the user cannot select. Attributes: data: Data with values that will be processed or changed. - label: Label above the component. - block_list: List of dates that the user cannot select. - * block_list[]: Date that the user cannot select. format: Format of the date entered by the user: * date-time — date and time. * date — date only. + label: Label above the component. + block_list: List of dates that the user cannot select. + * block_list[]: Date that the user cannot select. hint: Hint text. max: The latest date and time in the YYYY-MM-DD hh:mm format that the user can select. Where: * YYYY is the year. @@ -264,28 +263,28 @@ class DateFieldV1(BaseFieldV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, format: Optional[Any] = None, + *, block_list: Optional[Union[BaseComponent, List[Any]]] = None, max: Optional[Any] = None, min: Optional[Any] = None, - placeholder: Optional[Any] = None + placeholder: Optional[Any] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class DateFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] format: Optional[Any] block_list: Optional[Union[BaseComponent, List[Any]]] max: Optional[Any] @@ -307,24 +306,24 @@ class EmailFieldV1(BaseFieldV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, + *, + placeholder: Optional[Any] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, - placeholder: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class EmailFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] placeholder: Optional[Any] @@ -338,10 +337,10 @@ class FileFieldV1(BaseFieldV1): devices and makes it easier to upload photos and videos. Attributes: data: Data with values that will be processed or changed. - label: Label above the component. accept: A list of file types that can be uploaded. By default, you can upload any files. Specify the types in the format (https://developer.mozilla.org/en-US/docs/Web/HTTP/BasicsofHTTP/MIME_types). For example, you can allow only images to be uploaded by adding the image/jpeg and image/png types. + label: Label above the component. hint: Hint text. multiple: Determines whether multiple files can be uploaded: * false (default) — forbidden. @@ -351,25 +350,25 @@ class FileFieldV1(BaseFieldV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, + accept: Optional[Union[BaseComponent, List[Union[BaseComponent, str]]]] = None, + *, + multiple: Optional[Union[BaseComponent, bool]] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, - accept: Optional[Union[BaseComponent, List[Union[BaseComponent, str]]]] = None, - multiple: Optional[Union[BaseComponent, bool]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class FileFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] accept: Optional[Union[BaseComponent, List[Union[BaseComponent, str]]]] multiple: Optional[Union[BaseComponent, bool]] @@ -383,6 +382,7 @@ class ImageAnnotationFieldV1(BaseFieldV1): selection modes and hide the rest. Attributes: data: Data with values that will be processed or changed. + image: The image you want to select areas in. label: Label above the component. disabled: Determines whether adding and deleting areas is allowed: * false (default) — Allowed. @@ -392,7 +392,6 @@ class ImageAnnotationFieldV1(BaseFieldV1): full_height: If true, the element takes up all the vertical free space. The element is set to a minimum height of 400 pixels. hint: Hint text. - image: The image you want to select areas in. labels: Used to classify areas. You can add several area types. When adding an area type, a button to select it appears in the interface, and when setting a new value, a new area selection color is added. @@ -418,7 +417,6 @@ class ImageAnnotationFieldV1(BaseFieldV1): def __init__( self, - *, label: Optional[Union[BaseComponent, str]] = None, value: Optional[Union[BaseComponent, str]] = None ) -> None: @@ -440,33 +438,33 @@ class ImageAnnotationFieldV1(BaseFieldV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, + image: Optional[Union[BaseComponent, str]] = None, + *, disabled: Optional[Union[BaseComponent, bool]] = None, full_height: Optional[Union[BaseComponent, bool]] = None, - image: Optional[Union[BaseComponent, str]] = None, labels: Optional[Union[BaseComponent, List[Union[BaseComponent, Label]]]] = None, min_width: Optional[Union[BaseComponent, float]] = None, ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None, - shapes: Optional[Union[BaseComponent, Dict[Union[BaseComponent, Shape], Union[BaseComponent, bool]]]] = None + shapes: Optional[Union[BaseComponent, Dict[Union[BaseComponent, Shape], Union[BaseComponent, bool]]]] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class ImageAnnotationFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] + image: Optional[Union[BaseComponent, str]] disabled: Optional[Union[BaseComponent, bool]] full_height: Optional[Union[BaseComponent, bool]] - image: Optional[Union[BaseComponent, str]] labels: Optional[Union[BaseComponent, List[Union[BaseComponent, Label]]]] min_width: Optional[Union[BaseComponent, float]] ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] @@ -488,6 +486,9 @@ class ListFieldV1(BaseFieldV1): property to block users from changing a component, like when a certain event occurs. Attributes: data: Data with values that will be processed or changed. + render: Interface template for list items, such as a text field. + In nested field.* components, use data.relative for recording responses, otherwise all the list items will + have the same value. label: Label above the component. button_label: Text on the button for adding list items. direction: The direction of the list. @@ -495,42 +496,39 @@ class ListFieldV1(BaseFieldV1): By default it is true (allowed). hint: Hint text. max_length: Maximum number of list items. - render: Interface template for list items, such as a text field. - In nested field.* components, use data.relative for recording responses, otherwise all the list items will - have the same value. size: The distance between list items. Acceptable values in ascending order: s, m (default). validation: Validation based on condition. """ def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, render: Optional[BaseComponent] = None, + *, button_label: Optional[Any] = None, direction: Optional[Union[BaseComponent, ListDirection]] = None, - editable: Optional[Any] = None, + editable: Optional[Union[BaseComponent, bool]] = None, max_length: Optional[Union[BaseComponent, float]] = None, - size: Optional[Union[BaseComponent, ListSize]] = None + size: Optional[Union[BaseComponent, ListSize]] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class ListFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] render: Optional[BaseComponent] button_label: Optional[Any] direction: Optional[Union[BaseComponent, ListDirection]] - editable: Optional[Any] + editable: Optional[Union[BaseComponent, bool]] max_length: Optional[Union[BaseComponent, float]] size: Optional[Union[BaseComponent, ListSize]] @@ -544,9 +542,9 @@ class MediaFileFieldV1(BaseFieldV1): field.file for a more flexible configuration of the file types. Attributes: data: Data with values that will be processed or changed. - label: Label above the component. accept: Adds different buttons for four types of uploads. Pass the true value for the ones that you need. For example, if you need a button for uploading files from the gallery, add the "gallery": true property + label: Label above the component. hint: Hint text. multiple: Determines whether multiple files can be uploaded: validation: Validation based on condition. @@ -594,25 +592,25 @@ class MediaFileFieldV1(BaseFieldV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, + accept: Optional[Union[BaseComponent, Accept]] = None, + *, + multiple: Optional[Union[BaseComponent, bool]] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, - accept: Optional[Union[BaseComponent, Accept]] = None, - multiple: Optional[Union[BaseComponent, bool]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class MediaFileFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] accept: Optional[Union[BaseComponent, Accept]] multiple: Optional[Union[BaseComponent, bool]] @@ -640,26 +638,26 @@ class NumberFieldV1(BaseFieldV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, + *, + maximum: Optional[Union[BaseComponent, int]] = None, + minimum: Optional[Union[BaseComponent, int]] = None, + placeholder: Optional[Any] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, - maximum: Optional[Union[BaseComponent, int]] = None, - minimum: Optional[Union[BaseComponent, int]] = None, - placeholder: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class NumberFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] maximum: Optional[Union[BaseComponent, int]] minimum: Optional[Union[BaseComponent, int]] placeholder: Optional[Any] @@ -680,24 +678,24 @@ class PhoneNumberFieldV1(BaseFieldV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, + *, + placeholder: Optional[Union[BaseComponent, str]] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, - placeholder: Optional[Union[BaseComponent, str]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class PhoneNumberFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] placeholder: Optional[Union[BaseComponent, str]] @@ -709,48 +707,48 @@ class RadioGroupFieldV1(BaseFieldV1): The minimum number of buttons is one. Any type of data can be returned. Attributes: data: Data with values that will be processed or changed. + options: List of options to choose from label: Label above the component. disabled: This property prevents clicking the button. If the value is true, the button is not active (the user will not be able to click it). hint: Hint text. - options: List of options to choose from validation: Validation based on condition. Example: How to add label selector to interface. >>> radio_group_field = tb.fields.RadioGroupFieldV1( - >>> data=tb.data.OutputData(path='result'), - >>> validation=tb.conditions.RequiredConditionV1(), - >>> options=[ - >>> tb.fields.GroupFieldOption(label='Cat', value='cat'), - >>> tb.fields.GroupFieldOption(label='Dog', value='dog'), - >>> ] + >>> tb.data.OutputData(path='result'), + >>> [ + >>> tb.fields.GroupFieldOption('Cat', 'cat'), + >>> tb.fields.GroupFieldOption('Dog', 'dog'), + >>> ], + >>> validation=tb.conditions.RequiredConditionV1() >>> ) ... """ def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, + options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] = None, + *, + disabled: Optional[Union[BaseComponent, bool]] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, - options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] = None, - disabled: Optional[Union[BaseComponent, bool]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class RadioGroupFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] options: Optional[Union[BaseComponent, List[Union[BaseComponent, GroupFieldOption]]]] disabled: Optional[Union[BaseComponent, bool]] @@ -766,9 +764,9 @@ class SelectFieldV1(BaseFieldV1): To allow selecting multiple options, use the field.checkbox-group component. Attributes: data: Data with values that will be processed or changed. + options: Options to choose from. label: Label above the component. hint: Hint text. - options: Options to choose from. placeholder: The text that will be displayed if none of the options is selected. validation: Validation based on condition. """ @@ -783,7 +781,6 @@ class SelectFieldV1(BaseFieldV1): def __init__( self, - *, label: Optional[Any] = None, value: Optional[Any] = None ) -> None: @@ -797,25 +794,25 @@ class SelectFieldV1(BaseFieldV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, + options: Optional[Union[BaseComponent, Option]] = None, + *, + placeholder: Optional[Any] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, - options: Optional[Union[BaseComponent, Option]] = None, - placeholder: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class SelectFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] options: Optional[Union[BaseComponent, Option]] placeholder: Optional[Any] @@ -834,25 +831,25 @@ class TextFieldV1(BaseFieldV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, + *, + disabled: Optional[Union[BaseComponent, bool]] = None, + placeholder: Optional[Any] = None, hint: Optional[Any] = None, label: Optional[Any] = None, validation: Optional[BaseComponent] = None, - disabled: Optional[Union[BaseComponent, bool]] = None, - placeholder: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class TextFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] disabled: Optional[Union[BaseComponent, bool]] placeholder: Optional[Any] @@ -880,27 +877,27 @@ class TextareaFieldV1(BaseFieldV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[BaseComponent] = None, - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, + *, disabled: Optional[Union[BaseComponent, bool]] = None, placeholder: Optional[Any] = None, resizable: Optional[Union[BaseComponent, bool]] = None, - rows: Optional[Union[BaseComponent, float]] = None + rows: Optional[Union[BaseComponent, float]] = None, + hint: Optional[Any] = None, + label: Optional[Any] = None, + validation: Optional[BaseComponent] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class TextareaFieldV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] data: Optional[BaseComponent] hint: Optional[Any] label: Optional[Any] validation: Optional[BaseComponent] + version: Optional[str] disabled: Optional[Union[BaseComponent, bool]] placeholder: Optional[Any] resizable: Optional[Union[BaseComponent, bool]] diff --git a/src/client/project/template_builder/helpers.py b/src/client/project/template_builder/helpers.py index ebc94906..855f4712 100644 --- a/src/client/project/template_builder/helpers.py +++ b/src/client/project/template_builder/helpers.py @@ -17,10 +17,10 @@ from ...primitives.base import attribute -from .base import BaseComponent, ComponentType, BaseTemplate, VersionedBaseComponent, base_component_or +from .base import BaseComponent, ComponentType, BaseTemplate, VersionedBaseComponentMetaclass, base_component_or -class BaseHelperV1(VersionedBaseComponent): +class BaseHelperV1(BaseComponent, metaclass=VersionedBaseComponentMetaclass): """Perform various operations, such as if-then-else or switch-case. """ @@ -83,22 +83,22 @@ class IfHelperV1(BaseHelperV1, spec_value=ComponentType.HELPER_IF): comment field appear when a negative response is received, but nothing happens when a positive response is received. Attributes: condition: Condition to check. - else_: The element that is returned if the condition from the condition property is false (returns false). then: The element that is returned if the condition from the condition property is true (returns true). + else_: The element that is returned if the condition from the condition property is false (returns false). Example: How to show a part of the interface by condition. >>> hidden_ui = tb.helpers.IfHelperV1( - >>> condition=tb.conditions.EqualsConditionV1(data=tb.data.OutputData(path='show_me'), to='show'), - >>> then=tb.view.ListViewV1(items=[header, buttons, images]), + >>> tb.conditions.EqualsConditionV1(tb.data.OutputData('show_me'), 'show'), + >>> tb.view.ListViewV1([header, buttons, images]), >>> ) ... """ condition: BaseComponent then: base_component_or(Any) - else_: base_component_or(Any) = attribute(origin='else') + else_: base_component_or(Any) = attribute(origin='else', kw_only=True) class JoinHelperV1(BaseHelperV1, spec_value=ComponentType.HELPER_JOIN): @@ -106,8 +106,8 @@ class JoinHelperV1(BaseHelperV1, spec_value=ComponentType.HELPER_JOIN): You can add a delimiter to separate the strings, such as a space or comma. Attributes: - by: Delimiter for joining strings. You can use any number of characters in the delimiter. items: Array of strings to join. + by: Delimiter for joining strings. You can use any number of characters in the delimiter. """ items: base_component_or(List[base_component_or(str)], 'ListBaseComponentOrStr') @@ -162,8 +162,8 @@ class SearchQueryHelperV1(BaseHelperV1, spec_value=ComponentType.HELPER_SEARCH_Q The list of available search engines is specified in the engine enum. Attributes: - engine: Search engine. query: Search query. + engine: Search engine. """ @unique diff --git a/src/client/project/template_builder/helpers.pyi b/src/client/project/template_builder/helpers.pyi index 841981e7..95628ec2 100644 --- a/src/client/project/template_builder/helpers.pyi +++ b/src/client/project/template_builder/helpers.pyi @@ -1,8 +1,7 @@ from enum import Enum from toloka.client.project.template_builder.base import ( BaseComponent, - BaseTemplate, - VersionedBaseComponent + BaseTemplate ) from typing import ( Any, @@ -12,7 +11,7 @@ from typing import ( Union ) -class BaseHelperV1(VersionedBaseComponent): +class BaseHelperV1(BaseComponent): """Perform various operations, such as if-then-else or switch-case. """ @@ -38,9 +37,9 @@ class ConcatArraysHelperV1(BaseHelperV1): def __init__( self, + items: Optional[Union[BaseComponent, List[Any]]] = None, *, - version: Optional[str] = '1.0.0', - items: Optional[Union[BaseComponent, List[Any]]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class ConcatArraysHelperV1. """ @@ -74,7 +73,6 @@ class Entries2ObjectHelperV1(BaseHelperV1): class Entry(BaseTemplate): def __init__( self, - *, key: Optional[Union[BaseComponent, str]] = None, value: Optional[Any] = None ) -> None: @@ -88,9 +86,9 @@ class Entries2ObjectHelperV1(BaseHelperV1): def __init__( self, + entries: Optional[Union[BaseComponent, List[Union[BaseComponent, Entry]]]] = None, *, - version: Optional[str] = '1.0.0', - entries: Optional[Union[BaseComponent, List[Union[BaseComponent, Entry]]]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class Entries2ObjectHelperV1. """ @@ -115,26 +113,26 @@ class IfHelperV1(BaseHelperV1): comment field appear when a negative response is received, but nothing happens when a positive response is received. Attributes: condition: Condition to check. - else_: The element that is returned if the condition from the condition property is false (returns false). then: The element that is returned if the condition from the condition property is true (returns true). + else_: The element that is returned if the condition from the condition property is false (returns false). Example: How to show a part of the interface by condition. >>> hidden_ui = tb.helpers.IfHelperV1( - >>> condition=tb.conditions.EqualsConditionV1(data=tb.data.OutputData(path='show_me'), to='show'), - >>> then=tb.view.ListViewV1(items=[header, buttons, images]), + >>> tb.conditions.EqualsConditionV1(tb.data.OutputData('show_me'), 'show'), + >>> tb.view.ListViewV1([header, buttons, images]), >>> ) ... """ def __init__( self, - *, - version: Optional[str] = '1.0.0', condition: Optional[BaseComponent] = None, then: Optional[Any] = None, - else_: Optional[Any] = None + *, + else_: Optional[Any] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class IfHelperV1. """ @@ -152,16 +150,16 @@ class JoinHelperV1(BaseHelperV1): You can add a delimiter to separate the strings, such as a space or comma. Attributes: - by: Delimiter for joining strings. You can use any number of characters in the delimiter. items: Array of strings to join. + by: Delimiter for joining strings. You can use any number of characters in the delimiter. """ def __init__( self, - *, - version: Optional[str] = '1.0.0', items: Optional[Union[BaseComponent, List[Union[BaseComponent, str]]]] = None, - by: Optional[Any] = None + by: Optional[Any] = None, + *, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class JoinHelperV1. """ @@ -198,9 +196,9 @@ class Object2EntriesHelperV1(BaseHelperV1): def __init__( self, + data: Optional[Any] = None, *, - version: Optional[str] = '1.0.0', - data: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class Object2EntriesHelperV1. """ @@ -225,11 +223,11 @@ class ReplaceHelperV1(BaseHelperV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[Any] = None, find: Optional[Union[BaseComponent, str]] = None, - replace: Optional[Union[BaseComponent, str]] = None + replace: Optional[Union[BaseComponent, str]] = None, + *, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class ReplaceHelperV1. """ @@ -247,8 +245,8 @@ class SearchQueryHelperV1(BaseHelperV1): The list of available search engines is specified in the engine enum. Attributes: - engine: Search engine. query: Search query. + engine: Search engine. """ class Engine(Enum): @@ -269,10 +267,10 @@ class SearchQueryHelperV1(BaseHelperV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', query: Optional[Any] = None, - engine: Optional[Union[BaseComponent, Engine]] = None + engine: Optional[Union[BaseComponent, Engine]] = None, + *, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class SearchQueryHelperV1. """ @@ -318,7 +316,6 @@ class SwitchHelperV1(BaseHelperV1): def __init__( self, - *, condition: Optional[BaseComponent] = None, result: Optional[Any] = None ) -> None: @@ -332,10 +329,10 @@ class SwitchHelperV1(BaseHelperV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', cases: Optional[Union[BaseComponent, List[Union[BaseComponent, Case]]]] = None, - default: Optional[Any] = None + default: Optional[Any] = None, + *, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class SwitchHelperV1. """ @@ -369,10 +366,10 @@ class TextTransformHelperV1(BaseHelperV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', data: Optional[Any] = None, - transformation: Optional[Union[BaseComponent, Transformation]] = None + transformation: Optional[Union[BaseComponent, Transformation]] = None, + *, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class TextTransformHelperV1. """ @@ -401,10 +398,10 @@ class TransformHelperV1(BaseHelperV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', into: Optional[Any] = None, - items: Optional[Union[BaseComponent, List[Any]]] = None + items: Optional[Union[BaseComponent, List[Any]]] = None, + *, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class TransformHelperV1. """ @@ -429,9 +426,9 @@ class YandexDiskProxyHelperV1(BaseHelperV1): def __init__( self, + path: Optional[Union[BaseComponent, str]] = None, *, - version: Optional[str] = '1.0.0', - path: Optional[Union[BaseComponent, str]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class YandexDiskProxyHelperV1. """ diff --git a/src/client/project/template_builder/layouts.py b/src/client/project/template_builder/layouts.py index 765e422c..8384b9ba 100644 --- a/src/client/project/template_builder/layouts.py +++ b/src/client/project/template_builder/layouts.py @@ -10,16 +10,24 @@ from ...primitives.base import attribute -from .base import BaseComponent, ComponentType, VersionedBaseComponent, base_component_or +from .base import BaseComponent, ComponentType, VersionedBaseComponentMetaclass, base_component_or -class BaseLayoutV1(VersionedBaseComponent): +class BaseLayoutV1Metaclass(VersionedBaseComponentMetaclass): + def __new__(mcs, name, bases, namespace, **kwargs): + if 'validation' not in namespace: + namespace['validation'] = attribute(kw_only=True) + namespace.setdefault('__annotations__', {})['validation'] = BaseComponent + return super().__new__(mcs, name, bases, namespace, **kwargs) + + +class BaseLayoutV1(BaseComponent, metaclass=BaseLayoutV1Metaclass): """Options for positioning elements in the interface, such as in columns or side-by-side. If you have more than one element in the interface, these components will help you arrange them the way you want. """ - validation: BaseComponent + pass class BarsLayoutV1(BaseLayoutV1, spec_value=ComponentType.LAYOUT_BARS): @@ -30,15 +38,15 @@ class BarsLayoutV1(BaseLayoutV1, spec_value=ComponentType.LAYOUT_BARS): The top bar is located at the top edge of the component, and the bottom one is at the bottom edge. The content is placed between the bars and takes up all available space. Attributes: + content: The main content. bar_after: The bar displayed at the bottom edge of the component. bar_before: The bar displayed at the top edge of the component. - content: The main content. validation: Validation based on condition. """ content: BaseComponent - bar_after: BaseComponent = attribute(origin='barAfter') - bar_before: BaseComponent = attribute(origin='barBefore') + bar_after: BaseComponent = attribute(origin='barAfter', kw_only=True) + bar_before: BaseComponent = attribute(origin='barBefore', kw_only=True) class ColumnsLayoutV1(BaseLayoutV1, spec_value=ComponentType.LAYOUT_COLUMNS): @@ -46,9 +54,9 @@ class ColumnsLayoutV1(BaseLayoutV1, spec_value=ComponentType.LAYOUT_COLUMNS): Use it to customize the display of content: set the column width and adjust the vertical alignment of content. Attributes: + items: Columns to divide the interface into. full_height: Switches the component to column mode at full height and with individual scrolling. Otherwise, the height is determined by the height of the column that is filled in the most. - items: Columns to divide the interface into. min_width: The minimum width of the component; if it is narrower, columns are output sequentially, one by one. ratio: An array of values that specify the relative width of columns. For example, if you have 3 columns, the value [1,2,1] divides the space into 4 parts and the column in the middle is twice as large as the other @@ -76,10 +84,10 @@ class VerticalAlign(Enum): TOP = 'top' items: base_component_or(List[BaseComponent], 'ListBaseComponent') - full_height: base_component_or(bool) = attribute(origin='fullHeight') - min_width: base_component_or(float) = attribute(origin='minWidth') - ratio: base_component_or(List[base_component_or(float)], 'ListBaseComponentOrFloat') - vertical_align: base_component_or(VerticalAlign) = attribute(origin='verticalAlign') + full_height: base_component_or(bool) = attribute(origin='fullHeight', kw_only=True) + min_width: base_component_or(float) = attribute(origin='minWidth', kw_only=True) + ratio: base_component_or(List[base_component_or(float)], 'ListBaseComponentOrFloat') = attribute(kw_only=True) + vertical_align: base_component_or(VerticalAlign) = attribute(origin='verticalAlign', kw_only=True) class SideBySideLayoutV1(BaseLayoutV1, spec_value=ComponentType.LAYOUT_SIDE_BY_SIDE): @@ -98,7 +106,7 @@ class SideBySideLayoutV1(BaseLayoutV1, spec_value=ComponentType.LAYOUT_SIDE_BY_S controls: BaseComponent items: base_component_or(List[BaseComponent], 'ListBaseComponent') - min_item_width: base_component_or(float) = attribute(origin='minItemWidth') + min_item_width: base_component_or(float) = attribute(origin='minItemWidth', kw_only=True) class SidebarLayoutV1(BaseLayoutV1, spec_value=ComponentType.LAYOUT_SIDEBAR): @@ -128,6 +136,6 @@ class SidebarLayoutV1(BaseLayoutV1, spec_value=ComponentType.LAYOUT_SIDEBAR): content: BaseComponent controls: BaseComponent - controls_width: base_component_or(float) = attribute(origin='controlsWidth') - extra_controls: BaseComponent = attribute(origin='extraControls') - min_width: base_component_or(float) = attribute(origin='minWidth') + controls_width: base_component_or(float) = attribute(origin='controlsWidth', kw_only=True) + extra_controls: BaseComponent = attribute(origin='extraControls', kw_only=True) + min_width: base_component_or(float) = attribute(origin='minWidth', kw_only=True) diff --git a/src/client/project/template_builder/layouts.pyi b/src/client/project/template_builder/layouts.pyi index fd2a65ab..cd8cf340 100644 --- a/src/client/project/template_builder/layouts.pyi +++ b/src/client/project/template_builder/layouts.pyi @@ -1,8 +1,5 @@ from enum import Enum -from toloka.client.project.template_builder.base import ( - BaseComponent, - VersionedBaseComponent -) +from toloka.client.project.template_builder.base import BaseComponent from typing import ( Any, Dict, @@ -11,7 +8,7 @@ from typing import ( Union ) -class BaseLayoutV1(VersionedBaseComponent): +class BaseLayoutV1(BaseComponent): """Options for positioning elements in the interface, such as in columns or side-by-side. If you have more than one element in the interface, these components will help you arrange them the way you want. @@ -20,16 +17,16 @@ class BaseLayoutV1(VersionedBaseComponent): def __init__( self, *, - version: Optional[str] = '1.0.0', - validation: Optional[BaseComponent] = None + validation: Optional[BaseComponent] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class BaseLayoutV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] validation: Optional[BaseComponent] + version: Optional[str] class BarsLayoutV1(BaseLayoutV1): @@ -40,28 +37,28 @@ class BarsLayoutV1(BaseLayoutV1): The top bar is located at the top edge of the component, and the bottom one is at the bottom edge. The content is placed between the bars and takes up all available space. Attributes: + content: The main content. bar_after: The bar displayed at the bottom edge of the component. bar_before: The bar displayed at the top edge of the component. - content: The main content. validation: Validation based on condition. """ def __init__( self, - *, - version: Optional[str] = '1.0.0', - validation: Optional[BaseComponent] = None, content: Optional[BaseComponent] = None, + *, bar_after: Optional[BaseComponent] = None, - bar_before: Optional[BaseComponent] = None + bar_before: Optional[BaseComponent] = None, + validation: Optional[BaseComponent] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class BarsLayoutV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] validation: Optional[BaseComponent] + version: Optional[str] content: Optional[BaseComponent] bar_after: Optional[BaseComponent] bar_before: Optional[BaseComponent] @@ -72,9 +69,9 @@ class ColumnsLayoutV1(BaseLayoutV1): Use it to customize the display of content: set the column width and adjust the vertical alignment of content. Attributes: + items: Columns to divide the interface into. full_height: Switches the component to column mode at full height and with individual scrolling. Otherwise, the height is determined by the height of the column that is filled in the most. - items: Columns to divide the interface into. min_width: The minimum width of the component; if it is narrower, columns are output sequentially, one by one. ratio: An array of values that specify the relative width of columns. For example, if you have 3 columns, the value [1,2,1] divides the space into 4 parts and the column in the middle is twice as large as the other @@ -102,22 +99,22 @@ class ColumnsLayoutV1(BaseLayoutV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', - validation: Optional[BaseComponent] = None, items: Optional[Union[BaseComponent, List[BaseComponent]]] = None, + *, full_height: Optional[Union[BaseComponent, bool]] = None, min_width: Optional[Union[BaseComponent, float]] = None, ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None, - vertical_align: Optional[Union[BaseComponent, VerticalAlign]] = None + vertical_align: Optional[Union[BaseComponent, VerticalAlign]] = None, + validation: Optional[BaseComponent] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class ColumnsLayoutV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] validation: Optional[BaseComponent] + version: Optional[str] items: Optional[Union[BaseComponent, List[BaseComponent]]] full_height: Optional[Union[BaseComponent, bool]] min_width: Optional[Union[BaseComponent, float]] @@ -141,20 +138,20 @@ class SideBySideLayoutV1(BaseLayoutV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', - validation: Optional[BaseComponent] = None, controls: Optional[BaseComponent] = None, items: Optional[Union[BaseComponent, List[BaseComponent]]] = None, - min_item_width: Optional[Union[BaseComponent, float]] = None + *, + min_item_width: Optional[Union[BaseComponent, float]] = None, + validation: Optional[BaseComponent] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class SideBySideLayoutV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] validation: Optional[BaseComponent] + version: Optional[str] controls: Optional[BaseComponent] items: Optional[Union[BaseComponent, List[BaseComponent]]] min_item_width: Optional[Union[BaseComponent, float]] @@ -187,22 +184,22 @@ class SidebarLayoutV1(BaseLayoutV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', - validation: Optional[BaseComponent] = None, content: Optional[BaseComponent] = None, controls: Optional[BaseComponent] = None, + *, controls_width: Optional[Union[BaseComponent, float]] = None, extra_controls: Optional[BaseComponent] = None, - min_width: Optional[Union[BaseComponent, float]] = None + min_width: Optional[Union[BaseComponent, float]] = None, + validation: Optional[BaseComponent] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class SidebarLayoutV1. """ ... _unexpected: Optional[Dict[str, Any]] - version: Optional[str] validation: Optional[BaseComponent] + version: Optional[str] content: Optional[BaseComponent] controls: Optional[BaseComponent] controls_width: Optional[Union[BaseComponent, float]] diff --git a/src/client/project/template_builder/plugins.py b/src/client/project/template_builder/plugins.py index 40729846..edc44808 100644 --- a/src/client/project/template_builder/plugins.py +++ b/src/client/project/template_builder/plugins.py @@ -11,10 +11,10 @@ from ...primitives.base import attribute from ...util._codegen import expand -from .base import VersionedBaseComponent, BaseComponent, ComponentType, BaseTemplate, base_component_or +from .base import VersionedBaseComponentMetaclass, BaseComponent, ComponentType, BaseTemplate, base_component_or -class BasePluginV1(VersionedBaseComponent): +class BasePluginV1(BaseComponent, metaclass=VersionedBaseComponentMetaclass): """Plugins that provide expanded functionality. For example, you can use plugin.hotkeys to set up shortcuts. """ @@ -33,51 +33,51 @@ class HotkeysPluginV1(BasePluginV1, spec_value=ComponentType.PLUGIN_HOTKEYS): How to create hotkeys for classification buttons. >>> hot_keys_plugin = tb.HotkeysPluginV1( - >>> key_1=tb.SetActionV1(data=tb.OutputData(path='result'), payload='cat'), - >>> key_2=tb.SetActionV1(data=tb.OutputData(path='result'), payload='dog'), - >>> key_3=tb.SetActionV1(data=tb.OutputData(path='result'), payload='other'), + >>> key_1=tb.SetActionV1(tb.OutputData('result'), 'cat'), + >>> key_2=tb.SetActionV1(tb.OutputData('result'), 'dog'), + >>> key_3=tb.SetActionV1(tb.OutputData('result'), 'other'), >>> ) ... """ - key_a: base_component_or(Any) = attribute(default=None, origin='a') - key_b: base_component_or(Any) = attribute(default=None, origin='b') - key_c: base_component_or(Any) = attribute(default=None, origin='c') - key_d: base_component_or(Any) = attribute(default=None, origin='d') - key_e: base_component_or(Any) = attribute(default=None, origin='e') - key_f: base_component_or(Any) = attribute(default=None, origin='f') - key_g: base_component_or(Any) = attribute(default=None, origin='g') - key_h: base_component_or(Any) = attribute(default=None, origin='h') - key_i: base_component_or(Any) = attribute(default=None, origin='i') - key_j: base_component_or(Any) = attribute(default=None, origin='j') - key_k: base_component_or(Any) = attribute(default=None, origin='k') - key_l: base_component_or(Any) = attribute(default=None, origin='l') - key_m: base_component_or(Any) = attribute(default=None, origin='m') - key_n: base_component_or(Any) = attribute(default=None, origin='n') - key_o: base_component_or(Any) = attribute(default=None, origin='o') - key_p: base_component_or(Any) = attribute(default=None, origin='p') - key_q: base_component_or(Any) = attribute(default=None, origin='q') - key_r: base_component_or(Any) = attribute(default=None, origin='r') - key_s: base_component_or(Any) = attribute(default=None, origin='s') - key_t: base_component_or(Any) = attribute(default=None, origin='t') - key_u: base_component_or(Any) = attribute(default=None, origin='u') - key_v: base_component_or(Any) = attribute(default=None, origin='v') - key_w: base_component_or(Any) = attribute(default=None, origin='w') - key_x: base_component_or(Any) = attribute(default=None, origin='x') - key_y: base_component_or(Any) = attribute(default=None, origin='y') - key_z: base_component_or(Any) = attribute(default=None, origin='z') - key_0: base_component_or(Any) = attribute(default=None, origin='0') - key_1: base_component_or(Any) = attribute(default=None, origin='1') - key_2: base_component_or(Any) = attribute(default=None, origin='2') - key_3: base_component_or(Any) = attribute(default=None, origin='3') - key_4: base_component_or(Any) = attribute(default=None, origin='4') - key_5: base_component_or(Any) = attribute(default=None, origin='5') - key_6: base_component_or(Any) = attribute(default=None, origin='6') - key_7: base_component_or(Any) = attribute(default=None, origin='7') - key_8: base_component_or(Any) = attribute(default=None, origin='8') - key_9: base_component_or(Any) = attribute(default=None, origin='9') - key_up: base_component_or(Any) = attribute(default=None, origin='up') - key_down: base_component_or(Any) = attribute(default=None, origin='down') + key_a: base_component_or(Any) = attribute(default=None, origin='a', kw_only=True) + key_b: base_component_or(Any) = attribute(default=None, origin='b', kw_only=True) + key_c: base_component_or(Any) = attribute(default=None, origin='c', kw_only=True) + key_d: base_component_or(Any) = attribute(default=None, origin='d', kw_only=True) + key_e: base_component_or(Any) = attribute(default=None, origin='e', kw_only=True) + key_f: base_component_or(Any) = attribute(default=None, origin='f', kw_only=True) + key_g: base_component_or(Any) = attribute(default=None, origin='g', kw_only=True) + key_h: base_component_or(Any) = attribute(default=None, origin='h', kw_only=True) + key_i: base_component_or(Any) = attribute(default=None, origin='i', kw_only=True) + key_j: base_component_or(Any) = attribute(default=None, origin='j', kw_only=True) + key_k: base_component_or(Any) = attribute(default=None, origin='k', kw_only=True) + key_l: base_component_or(Any) = attribute(default=None, origin='l', kw_only=True) + key_m: base_component_or(Any) = attribute(default=None, origin='m', kw_only=True) + key_n: base_component_or(Any) = attribute(default=None, origin='n', kw_only=True) + key_o: base_component_or(Any) = attribute(default=None, origin='o', kw_only=True) + key_p: base_component_or(Any) = attribute(default=None, origin='p', kw_only=True) + key_q: base_component_or(Any) = attribute(default=None, origin='q', kw_only=True) + key_r: base_component_or(Any) = attribute(default=None, origin='r', kw_only=True) + key_s: base_component_or(Any) = attribute(default=None, origin='s', kw_only=True) + key_t: base_component_or(Any) = attribute(default=None, origin='t', kw_only=True) + key_u: base_component_or(Any) = attribute(default=None, origin='u', kw_only=True) + key_v: base_component_or(Any) = attribute(default=None, origin='v', kw_only=True) + key_w: base_component_or(Any) = attribute(default=None, origin='w', kw_only=True) + key_x: base_component_or(Any) = attribute(default=None, origin='x', kw_only=True) + key_y: base_component_or(Any) = attribute(default=None, origin='y', kw_only=True) + key_z: base_component_or(Any) = attribute(default=None, origin='z', kw_only=True) + key_0: base_component_or(Any) = attribute(default=None, origin='0', kw_only=True) + key_1: base_component_or(Any) = attribute(default=None, origin='1', kw_only=True) + key_2: base_component_or(Any) = attribute(default=None, origin='2', kw_only=True) + key_3: base_component_or(Any) = attribute(default=None, origin='3', kw_only=True) + key_4: base_component_or(Any) = attribute(default=None, origin='4', kw_only=True) + key_5: base_component_or(Any) = attribute(default=None, origin='5', kw_only=True) + key_6: base_component_or(Any) = attribute(default=None, origin='6', kw_only=True) + key_7: base_component_or(Any) = attribute(default=None, origin='7', kw_only=True) + key_8: base_component_or(Any) = attribute(default=None, origin='8', kw_only=True) + key_9: base_component_or(Any) = attribute(default=None, origin='9', kw_only=True) + key_up: base_component_or(Any) = attribute(default=None, origin='up', kw_only=True) + key_down: base_component_or(Any) = attribute(default=None, origin='down', kw_only=True) class TriggerPluginV1(BasePluginV1, spec_value=ComponentType.PLUGIN_TRIGGER): @@ -108,10 +108,10 @@ class TriggerPluginV1(BasePluginV1, spec_value=ComponentType.PLUGIN_TRIGGER): ... """ - action: BaseComponent - condition: BaseComponent - fire_immediately: base_component_or(bool) = attribute(origin='fireImmediately') - on_change_of: BaseComponent = attribute(origin='onChangeOf') + action: BaseComponent = attribute(kw_only=True) + condition: BaseComponent = attribute(kw_only=True) + fire_immediately: base_component_or(bool) = attribute(origin='fireImmediately', kw_only=True) + on_change_of: BaseComponent = attribute(origin='onChangeOf', kw_only=True) class TolokaPluginV1(BasePluginV1, spec_value=ComponentType.PLUGIN_TOLOKA): @@ -125,7 +125,7 @@ class TolokaPluginV1(BasePluginV1, spec_value=ComponentType.PLUGIN_TOLOKA): How to set the task width on the task page. >>> task_width_plugin = tb.plugins.TolokaPluginV1( - >>> kind='scroll', + >>> 'scroll', >>> task_width=400, >>> ) ... @@ -149,9 +149,9 @@ class Kind(Enum): SCROLL = 'scroll' kind: Kind - task_width: float = attribute(origin='taskWidth') + task_width: float = attribute(origin='taskWidth', kw_only=True) layout: base_component_or(TolokaPluginLayout) = attribute(factory=TolokaPluginLayout) - notifications: base_component_or(List[BaseComponent], 'ListBaseComponent') + notifications: base_component_or(List[BaseComponent], 'ListBaseComponent') = attribute(kw_only=True) TolokaPluginV1.__init__ = expand('layout', TolokaPluginV1.TolokaPluginLayout)(TolokaPluginV1.__init__) diff --git a/src/client/project/template_builder/plugins.pyi b/src/client/project/template_builder/plugins.pyi index 286a521f..e9fd331b 100644 --- a/src/client/project/template_builder/plugins.pyi +++ b/src/client/project/template_builder/plugins.pyi @@ -1,8 +1,7 @@ from enum import Enum from toloka.client.project.template_builder.base import ( BaseComponent, - BaseTemplate, - VersionedBaseComponent + BaseTemplate ) from typing import ( Any, @@ -13,7 +12,7 @@ from typing import ( overload ) -class BasePluginV1(VersionedBaseComponent): +class BasePluginV1(BaseComponent): """Plugins that provide expanded functionality. For example, you can use plugin.hotkeys to set up shortcuts. """ @@ -37,9 +36,9 @@ class HotkeysPluginV1(BasePluginV1): How to create hotkeys for classification buttons. >>> hot_keys_plugin = tb.HotkeysPluginV1( - >>> key_1=tb.SetActionV1(data=tb.OutputData(path='result'), payload='cat'), - >>> key_2=tb.SetActionV1(data=tb.OutputData(path='result'), payload='dog'), - >>> key_3=tb.SetActionV1(data=tb.OutputData(path='result'), payload='other'), + >>> key_1=tb.SetActionV1(tb.OutputData('result'), 'cat'), + >>> key_2=tb.SetActionV1(tb.OutputData('result'), 'dog'), + >>> key_3=tb.SetActionV1(tb.OutputData('result'), 'other'), >>> ) ... """ @@ -47,7 +46,6 @@ class HotkeysPluginV1(BasePluginV1): def __init__( self, *, - version: Optional[str] = '1.0.0', key_a: Optional[Any] = None, key_b: Optional[Any] = None, key_c: Optional[Any] = None, @@ -85,7 +83,8 @@ class HotkeysPluginV1(BasePluginV1): key_8: Optional[Any] = None, key_9: Optional[Any] = None, key_up: Optional[Any] = None, - key_down: Optional[Any] = None + key_down: Optional[Any] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class HotkeysPluginV1. """ @@ -164,11 +163,11 @@ class TriggerPluginV1(BasePluginV1): def __init__( self, *, - version: Optional[str] = '1.0.0', action: Optional[BaseComponent] = None, condition: Optional[BaseComponent] = None, fire_immediately: Optional[Union[BaseComponent, bool]] = None, - on_change_of: Optional[BaseComponent] = None + on_change_of: Optional[BaseComponent] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class TriggerPluginV1. """ @@ -193,7 +192,7 @@ class TolokaPluginV1(BasePluginV1): How to set the task width on the task page. >>> task_width_plugin = tb.plugins.TolokaPluginV1( - >>> kind='scroll', + >>> 'scroll', >>> task_width=400, >>> ) ... @@ -216,8 +215,8 @@ class TolokaPluginV1(BasePluginV1): def __init__( self, - *, kind: Optional[Kind] = None, + *, task_width: Optional[float] = None ) -> None: """Method generated by attrs for class TolokaPluginV1.TolokaPluginLayout. @@ -231,11 +230,11 @@ class TolokaPluginV1(BasePluginV1): @overload def __init__( self, - *, - version: Optional[str] = '1.0.0', kind: Optional[TolokaPluginLayout.Kind] = None, + *, task_width: Optional[float] = None, - notifications: Optional[Union[BaseComponent, List[BaseComponent]]] = None + notifications: Optional[Union[BaseComponent, List[BaseComponent]]] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class TolokaPluginV1. """ @@ -244,10 +243,10 @@ class TolokaPluginV1(BasePluginV1): @overload def __init__( self, - *, - version: Optional[str] = '1.0.0', layout: Optional[Union[BaseComponent, TolokaPluginLayout]] = ..., - notifications: Optional[Union[BaseComponent, List[BaseComponent]]] = None + *, + notifications: Optional[Union[BaseComponent, List[BaseComponent]]] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class TolokaPluginV1. """ diff --git a/src/client/project/template_builder/view.py b/src/client/project/template_builder/view.py index 1aa5c41e..b82206cb 100644 --- a/src/client/project/template_builder/view.py +++ b/src/client/project/template_builder/view.py @@ -22,17 +22,38 @@ from ...primitives.base import attribute -from .base import BaseTemplate, BaseComponent, ListDirection, ListSize, ComponentType, VersionedBaseComponent, base_component_or - - -class BaseViewV1(VersionedBaseComponent): +from .base import ( + BaseTemplate, + BaseComponent, + ListDirection, + ListSize, + ComponentType, + VersionedBaseComponentMetaclass, + base_component_or +) + + +class BaseViewV1Metaclass(VersionedBaseComponentMetaclass): + def __new__(mcs, name, bases, namespace, **kwargs): + + if 'hint' not in namespace: + namespace['hint'] = attribute(kw_only=True) + namespace.setdefault('__annotations__', {})['hint'] = base_component_or(Any) + if 'label' not in namespace: + namespace['label'] = attribute(kw_only=True) + namespace.setdefault('__annotations__', {})['label'] = base_component_or(Any) + if 'validation' not in namespace: + namespace['validation'] = attribute(kw_only=True) + namespace.setdefault('__annotations__', {})['validation'] = BaseComponent + return super().__new__(mcs, name, bases, namespace, **kwargs) + + +class BaseViewV1(BaseComponent, metaclass=VersionedBaseComponentMetaclass): """Elements displayed in the interface, such as text, list, audio player, or image. """ - hint: base_component_or(Any) - label: base_component_or(Any) - validation: BaseComponent + pass class ActionButtonViewV1(BaseViewV1, spec_value=ComponentType.VIEW_ACTION_BUTTON): @@ -40,8 +61,8 @@ class ActionButtonViewV1(BaseViewV1, spec_value=ComponentType.VIEW_ACTION_BUTTON When clicking the button, an action specified in the action property is called. Attributes: - label: Button text. action: Action called when clicking the button. + label: Button text. hint: Hint text. validation: Validation based on condition. """ @@ -54,8 +75,8 @@ class AlertViewV1(BaseViewV1, spec_value=ComponentType.VIEW_ALERT): You can use both plain text and other visual components inside it. Attributes: - label: Label above the component. content: Content of the block with important information. + label: Label above the component. hint: Hint text. theme: Determines the block color. validation: Validation based on condition. @@ -78,7 +99,7 @@ class Theme(Enum): WARNING = 'warning' content: BaseComponent - theme: base_component_or(Theme) + theme: base_component_or(Theme) = attribute(kw_only=True) class AudioViewV1(BaseViewV1, spec_value=ComponentType.VIEW_AUDIO): @@ -86,15 +107,15 @@ class AudioViewV1(BaseViewV1, spec_value=ComponentType.VIEW_AUDIO): Format support depends on the user's browser, OS, and device. We recommend using MP3. Attributes: + url: Audio link. label: Label above the component. hint: Hint text. loop: Automatically replay audio. - url: Audio link. validation: Validation based on condition. """ url: base_component_or(Any) - loop: base_component_or(bool) + loop: base_component_or(bool) = attribute(kw_only=True) class CollapseViewV1(BaseViewV1, spec_value=ComponentType.VIEW_COLLAPSE): @@ -114,8 +135,9 @@ class CollapseViewV1(BaseViewV1, spec_value=ComponentType.VIEW_COLLAPSE): validation: Validation based on condition. """ + label: base_component_or(Any) content: BaseComponent - default_opened: base_component_or(bool) = attribute(origin='defaultOpened') + default_opened: base_component_or(bool) = attribute(origin='defaultOpened', kw_only=True) class DeviceFrameViewV1(BaseViewV1, spec_value=ComponentType.VIEW_DEVICE_FRAME): @@ -123,8 +145,8 @@ class DeviceFrameViewV1(BaseViewV1, spec_value=ComponentType.VIEW_DEVICE_FRAME): You can place other components inside the frame. Attributes: - label: Label above the component. content: Content inside the frame. + label: Label above the component. full_height: If true, the element takes up all the vertical free space. The element is set to a minimum height of 400 pixels. hint: Hint text. @@ -136,10 +158,10 @@ class DeviceFrameViewV1(BaseViewV1, spec_value=ComponentType.VIEW_DEVICE_FRAME): """ content: BaseComponent - full_height: base_component_or(bool) = attribute(origin='fullHeight') - max_width: base_component_or(float) = attribute(origin='maxWidth') - min_width: base_component_or(float) = attribute(origin='minWidth') - ratio: base_component_or(List[base_component_or(float)], 'ListBaseComponentOrFloat') + full_height: base_component_or(bool) = attribute(origin='fullHeight', kw_only=True) + max_width: base_component_or(float) = attribute(origin='maxWidth', kw_only=True) + min_width: base_component_or(float) = attribute(origin='minWidth', kw_only=True) + ratio: base_component_or(List[base_component_or(float)], 'ListBaseComponentOrFloat') = attribute(kw_only=True) class DividerViewV1(BaseViewV1, spec_value=ComponentType.VIEW_DIVIDER): @@ -159,8 +181,8 @@ class GroupViewV1(BaseViewV1, spec_value=ComponentType.VIEW_GROUP): """Groups components visually into framed blocks. Attributes: - label: Group heading. content: Content of a group block. + label: Group heading. hint: Explanation of the group heading. To insert a new line, use . validation: Validation based on condition. @@ -173,6 +195,7 @@ class IframeViewV1(BaseViewV1, spec_value=ComponentType.VIEW_IFRAME): """Displays the web page at the URL in an iframe window. Attributes: + url: URL of the web page. label: Label above the component. full_height: If true, the element takes up all the vertical free space. The element is set to a minimum height of 400 pixels. @@ -185,16 +208,17 @@ class IframeViewV1(BaseViewV1, spec_value=ComponentType.VIEW_IFRAME): """ url: base_component_or(str) - full_height: base_component_or(bool) = attribute(origin='fullHeight') - max_width: base_component_or(float) = attribute(origin='maxWidth') - min_width: base_component_or(float) = attribute(origin='minWidth') - ratio: base_component_or(List[base_component_or(float)], 'ListBaseComponentOrFloat') + full_height: base_component_or(bool) = attribute(origin='fullHeight', kw_only=True) + max_width: base_component_or(float) = attribute(origin='maxWidth', kw_only=True) + min_width: base_component_or(float) = attribute(origin='minWidth', kw_only=True) + ratio: base_component_or(List[base_component_or(float)], 'ListBaseComponentOrFloat') = attribute(kw_only=True) class ImageViewV1(BaseViewV1, spec_value=ComponentType.VIEW_IMAGE): """Displays an image. Attributes: + url: Image link. label: Label above the component. full_height: If true, the element takes up all the vertical free space. The element is set to a minimum height of 400 pixels. @@ -213,20 +237,19 @@ class ImageViewV1(BaseViewV1, spec_value=ComponentType.VIEW_IMAGE): If false, the image fits in the parent element and, when clicked, opens in its original size in the module window. Images in SVG format with no size specified always fit in their parent elements. - url: Image link. validation: Validation based on condition. """ url: base_component_or(Any) - full_height: base_component_or(bool) = attribute(origin='fullHeight') - max_width: base_component_or(float) = attribute(origin='maxWidth') - min_width: base_component_or(float) = attribute(origin='minWidth') - no_border: base_component_or(bool) = attribute(origin='noBorder') - no_lazy_load: base_component_or(bool) = attribute(origin='noLazyLoad') - popup: base_component_or(bool) - ratio: base_component_or(List[base_component_or(float)], 'ListBaseComponentOrFloat') - rotatable: base_component_or(bool) - scrollable: base_component_or(bool) + full_height: base_component_or(bool) = attribute(origin='fullHeight', kw_only=True) + max_width: base_component_or(float) = attribute(origin='maxWidth', kw_only=True) + min_width: base_component_or(float) = attribute(origin='minWidth', kw_only=True) + no_border: base_component_or(bool) = attribute(origin='noBorder', kw_only=True) + no_lazy_load: base_component_or(bool) = attribute(origin='noLazyLoad', kw_only=True) + popup: base_component_or(bool) = attribute(kw_only=True) + ratio: base_component_or(List[base_component_or(float)], 'ListBaseComponentOrFloat') = attribute(kw_only=True) + rotatable: base_component_or(bool) = attribute(kw_only=True) + scrollable: base_component_or(bool) = attribute(kw_only=True) class LabeledListViewV1(BaseViewV1, spec_value=ComponentType.VIEW_LABELED_LIST): @@ -234,9 +257,9 @@ class LabeledListViewV1(BaseViewV1, spec_value=ComponentType.VIEW_LABELED_LIST): If you don't need labels, use view.list. Attributes: + items: List items. label: Label above the component. hint: Hint text. - items: List items. min_width: The minimum width of list content. If the component width is less than the specified value, it switches to compact mode. validation: Validation based on condition. @@ -246,21 +269,21 @@ class Item(BaseTemplate): """Item. Attributes: + content: List item content. + label: A label displayed next to a list item. center_label: If true, a label is center-aligned relative to the content of a list item (content). Use it if the list consists of large items, such as images or multi-line text. By default, false (the label is aligned to the top of the content block). - content: List item content. hint: A pop-up hint displayed next to a label. - label: A label displayed next to a list item. """ content: BaseComponent label: base_component_or(Any) - center_label: base_component_or(bool) = attribute(origin='centerLabel') - hint: base_component_or(Any) + center_label: base_component_or(bool) = attribute(origin='centerLabel', kw_only=True) + hint: base_component_or(Any) = attribute(kw_only=True) items: base_component_or(List[base_component_or(Item)], 'ListBaseComponentOrItem') - min_width: base_component_or(float) = attribute(origin='minWidth') + min_width: base_component_or(float) = attribute(origin='minWidth', kw_only=True) class LinkViewV1(BaseViewV1, spec_value=ComponentType.VIEW_LINK): @@ -274,15 +297,15 @@ class LinkViewV1(BaseViewV1, spec_value=ComponentType.VIEW_LINK): To insert a link with a search query, use helper.search-query. Attributes: + url: Link URL. label: Label above the component. content: Link text displayed to the user. hint: Hint text. - url: Link URL. validation: Validation based on condition. """ url: base_component_or(Any) - content: base_component_or(Any) + content: base_component_or(Any) = attribute(kw_only=True) class LinkGroupViewV1(BaseViewV1, spec_value=ComponentType.VIEW_LINK_GROUP): @@ -292,23 +315,23 @@ class LinkGroupViewV1(BaseViewV1, spec_value=ComponentType.VIEW_LINK_GROUP): This only groups links, unlike GroupViewV1. Attributes: + links: Array of links that make up a group. label: Label above the component. hint: Hint text. - links: Array of links that make up a group. validation: Validation based on condition. Example: How to add several links. >>> links = tb.view.LinkGroupViewV1( - >>> links=[ + >>> [ >>> tb.view.LinkGroupViewV1.Link( - >>> url='https://any.com/useful/url/1', - >>> content='Example1', + >>> 'https://any.com/useful/url/1', + >>> 'Example1', >>> ), >>> tb.view.LinkGroupViewV1.Link( - >>> url='https://any.com/useful/url/2', - >>> content='Example2', + >>> 'https://any.com/useful/url/2', + >>> 'Example2', >>> ), >>> ] >>> ) @@ -319,14 +342,14 @@ class Link(BaseTemplate): """Link parameters Attributes: + url: Link address content: Link text that's displayed to the user. Unviewed links are blue and underlined, and clicked links are purple. theme: Defines the appearance of the link. If you specify "theme": "primary", it's a button, otherwise it's a text link. - url: Link address """ - content: base_component_or(str) - theme: base_component_or(str) url: base_component_or(str) + content: base_component_or(str) + theme: base_component_or(str) = attribute(kw_only=True) links: base_component_or(List[base_component_or(Link)], 'ListBaseComponentOrLink') @@ -335,18 +358,18 @@ class ListViewV1(BaseViewV1, spec_value=ComponentType.VIEW_LIST): """Block for displaying data in a list. Attributes: + items: Array of list items. label: Label above the component. direction: Determines the direction of the list. hint: Hint text. - items: Array of list items. size: Specifies the size of the margins between elements. Acceptable values in ascending order: s, m (default value). validation: Validation based on condition. """ items: base_component_or(List[BaseComponent], 'ListBaseComponent') - direction: base_component_or(ListDirection) - size: base_component_or(ListSize) + direction: base_component_or(ListDirection) = attribute(kw_only=True) + size: base_component_or(ListSize) = attribute(kw_only=True) class MarkdownViewV1(BaseViewV1, spec_value=ComponentType.VIEW_MARKDOWN): @@ -362,15 +385,15 @@ class MarkdownViewV1(BaseViewV1, spec_value=ComponentType.VIEW_MARKDOWN): rel="noopener noreferrer" Attributes: - label: Label above the component. content: Text in Markdown. + label: Label above the component. hint: Hint text. validation: Validation based on condition. Example: How to add a title and description on the task interface. - >>> header = tb.view.MarkdownViewV1(content='# Some Header:\n---\nSome detailed description') + >>> header = tb.view.MarkdownViewV1('# Some Header:\n---\nSome detailed description') ... """ @@ -382,15 +405,15 @@ class TextViewV1(BaseViewV1, spec_value=ComponentType.VIEW_TEXT): If you need formatted text, use view.markdown. Attributes: - label: Label above the component. content: The text displayed in the block. To insert a new line, use \n + label: Label above the component. hint: Hint text. validation: Validation based on condition. Example: How to show labeled field from the task inputs. - >>> text_view = tb.view.TextViewV1(label='My label:', content=tb.data.InputData(path='imput_field_name')) + >>> text_view = tb.view.TextViewV1(tb.data.InputData('input_field_name'), label='My label:') ... """ @@ -406,6 +429,7 @@ class VideoViewV1(BaseViewV1, spec_value=ComponentType.VIEW_VIDEO): The video resolution does not affect the size of the block — the video will fit into the block and will not be cropped. Attributes: + url: Link to the video file. label: Label above the component. full_height: If true, the element takes up all the vertical free space. The element is set to a minimum height of 400 pixels. @@ -414,10 +438,10 @@ class VideoViewV1(BaseViewV1, spec_value=ComponentType.VIEW_VIDEO): min_width: Minimum width of the element in pixels. Takes priority over max_width. ratio: The aspect ratio of the video block. An array of two numbers: the first sets the width of the block and the second sets the height. - url: Link to the video file. validation: Validation based on condition. """ - full_height: base_component_or(bool) = attribute(origin='fullHeight') - max_width: base_component_or(float) = attribute(origin='maxWidth') - min_width: base_component_or(float) = attribute(origin='minWidth') + url: base_component_or(Any) + full_height: base_component_or(bool) = attribute(origin='fullHeight', kw_only=True) + max_width: base_component_or(float) = attribute(origin='maxWidth', kw_only=True) + min_width: base_component_or(float) = attribute(origin='minWidth', kw_only=True) diff --git a/src/client/project/template_builder/view.pyi b/src/client/project/template_builder/view.pyi index e5ecc099..4ffb0c9a 100644 --- a/src/client/project/template_builder/view.pyi +++ b/src/client/project/template_builder/view.pyi @@ -3,8 +3,7 @@ from toloka.client.project.template_builder.base import ( BaseComponent, BaseTemplate, ListDirection, - ListSize, - VersionedBaseComponent + ListSize ) from typing import ( Any, @@ -14,27 +13,17 @@ from typing import ( Union ) -class BaseViewV1(VersionedBaseComponent): +class BaseViewV1(BaseComponent): """Elements displayed in the interface, such as text, list, audio player, or image. """ - def __init__( - self, - *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None - ) -> None: + def __init__(self, *, version: Optional[str] = '1.0.0') -> None: """Method generated by attrs for class BaseViewV1. """ ... _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] class ActionButtonViewV1(BaseViewV1): @@ -42,20 +31,17 @@ class ActionButtonViewV1(BaseViewV1): When clicking the button, an action specified in the action property is called. Attributes: - label: Button text. action: Action called when clicking the button. + label: Button text. hint: Hint text. validation: Validation based on condition. """ def __init__( self, + action: Optional[BaseComponent] = None, *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, - action: Optional[BaseComponent] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class ActionButtonViewV1. """ @@ -63,9 +49,6 @@ class ActionButtonViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] action: Optional[BaseComponent] @@ -74,8 +57,8 @@ class AlertViewV1(BaseViewV1): You can use both plain text and other visual components inside it. Attributes: - label: Label above the component. content: Content of the block with important information. + label: Label above the component. hint: Hint text. theme: Determines the block color. validation: Validation based on condition. @@ -98,13 +81,10 @@ class AlertViewV1(BaseViewV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, content: Optional[BaseComponent] = None, - theme: Optional[Union[BaseComponent, Theme]] = None + *, + theme: Optional[Union[BaseComponent, Theme]] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class AlertViewV1. """ @@ -112,9 +92,6 @@ class AlertViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] content: Optional[BaseComponent] theme: Optional[Union[BaseComponent, Theme]] @@ -124,22 +101,19 @@ class AudioViewV1(BaseViewV1): Format support depends on the user's browser, OS, and device. We recommend using MP3. Attributes: + url: Audio link. label: Label above the component. hint: Hint text. loop: Automatically replay audio. - url: Audio link. validation: Validation based on condition. """ def __init__( self, - *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, url: Optional[Any] = None, - loop: Optional[Union[BaseComponent, bool]] = None + *, + loop: Optional[Union[BaseComponent, bool]] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class AudioViewV1. """ @@ -147,9 +121,6 @@ class AudioViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] url: Optional[Any] loop: Optional[Union[BaseComponent, bool]] @@ -173,13 +144,11 @@ class CollapseViewV1(BaseViewV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, content: Optional[BaseComponent] = None, - default_opened: Optional[Union[BaseComponent, bool]] = None + *, + default_opened: Optional[Union[BaseComponent, bool]] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class CollapseViewV1. """ @@ -187,9 +156,7 @@ class CollapseViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] label: Optional[Any] - validation: Optional[BaseComponent] content: Optional[BaseComponent] default_opened: Optional[Union[BaseComponent, bool]] @@ -199,8 +166,8 @@ class DeviceFrameViewV1(BaseViewV1): You can place other components inside the frame. Attributes: - label: Label above the component. content: Content inside the frame. + label: Label above the component. full_height: If true, the element takes up all the vertical free space. The element is set to a minimum height of 400 pixels. hint: Hint text. @@ -213,16 +180,13 @@ class DeviceFrameViewV1(BaseViewV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, content: Optional[BaseComponent] = None, + *, full_height: Optional[Union[BaseComponent, bool]] = None, max_width: Optional[Union[BaseComponent, float]] = None, min_width: Optional[Union[BaseComponent, float]] = None, - ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None + ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class DeviceFrameViewV1. """ @@ -230,9 +194,6 @@ class DeviceFrameViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] content: Optional[BaseComponent] full_height: Optional[Union[BaseComponent, bool]] max_width: Optional[Union[BaseComponent, float]] @@ -250,31 +211,21 @@ class DividerViewV1(BaseViewV1): validation: Validation based on condition. """ - def __init__( - self, - *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None - ) -> None: + def __init__(self, *, version: Optional[str] = '1.0.0') -> None: """Method generated by attrs for class DividerViewV1. """ ... _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] class GroupViewV1(BaseViewV1): """Groups components visually into framed blocks. Attributes: - label: Group heading. content: Content of a group block. + label: Group heading. hint: Explanation of the group heading. To insert a new line, use . validation: Validation based on condition. @@ -282,12 +233,9 @@ class GroupViewV1(BaseViewV1): def __init__( self, + content: Optional[BaseComponent] = None, *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, - content: Optional[BaseComponent] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class GroupViewV1. """ @@ -295,9 +243,6 @@ class GroupViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] content: Optional[BaseComponent] @@ -305,6 +250,7 @@ class IframeViewV1(BaseViewV1): """Displays the web page at the URL in an iframe window. Attributes: + url: URL of the web page. label: Label above the component. full_height: If true, the element takes up all the vertical free space. The element is set to a minimum height of 400 pixels. @@ -318,16 +264,13 @@ class IframeViewV1(BaseViewV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, url: Optional[Union[BaseComponent, str]] = None, + *, full_height: Optional[Union[BaseComponent, bool]] = None, max_width: Optional[Union[BaseComponent, float]] = None, min_width: Optional[Union[BaseComponent, float]] = None, - ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None + ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class IframeViewV1. """ @@ -335,9 +278,6 @@ class IframeViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] url: Optional[Union[BaseComponent, str]] full_height: Optional[Union[BaseComponent, bool]] max_width: Optional[Union[BaseComponent, float]] @@ -349,6 +289,7 @@ class ImageViewV1(BaseViewV1): """Displays an image. Attributes: + url: Image link. label: Label above the component. full_height: If true, the element takes up all the vertical free space. The element is set to a minimum height of 400 pixels. @@ -367,18 +308,13 @@ class ImageViewV1(BaseViewV1): If false, the image fits in the parent element and, when clicked, opens in its original size in the module window. Images in SVG format with no size specified always fit in their parent elements. - url: Image link. validation: Validation based on condition. """ def __init__( self, - *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, url: Optional[Any] = None, + *, full_height: Optional[Union[BaseComponent, bool]] = None, max_width: Optional[Union[BaseComponent, float]] = None, min_width: Optional[Union[BaseComponent, float]] = None, @@ -387,7 +323,8 @@ class ImageViewV1(BaseViewV1): popup: Optional[Union[BaseComponent, bool]] = None, ratio: Optional[Union[BaseComponent, List[Union[BaseComponent, float]]]] = None, rotatable: Optional[Union[BaseComponent, bool]] = None, - scrollable: Optional[Union[BaseComponent, bool]] = None + scrollable: Optional[Union[BaseComponent, bool]] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class ImageViewV1. """ @@ -395,9 +332,6 @@ class ImageViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] url: Optional[Any] full_height: Optional[Union[BaseComponent, bool]] max_width: Optional[Union[BaseComponent, float]] @@ -415,9 +349,9 @@ class LabeledListViewV1(BaseViewV1): If you don't need labels, use view.list. Attributes: + items: List items. label: Label above the component. hint: Hint text. - items: List items. min_width: The minimum width of list content. If the component width is less than the specified value, it switches to compact mode. validation: Validation based on condition. @@ -427,19 +361,19 @@ class LabeledListViewV1(BaseViewV1): """Item. Attributes: + content: List item content. + label: A label displayed next to a list item. center_label: If true, a label is center-aligned relative to the content of a list item (content). Use it if the list consists of large items, such as images or multi-line text. By default, false (the label is aligned to the top of the content block). - content: List item content. hint: A pop-up hint displayed next to a label. - label: A label displayed next to a list item. """ def __init__( self, - *, content: Optional[BaseComponent] = None, label: Optional[Any] = None, + *, center_label: Optional[Union[BaseComponent, bool]] = None, hint: Optional[Any] = None ) -> None: @@ -455,13 +389,10 @@ class LabeledListViewV1(BaseViewV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, items: Optional[Union[BaseComponent, List[Union[BaseComponent, Item]]]] = None, - min_width: Optional[Union[BaseComponent, float]] = None + *, + min_width: Optional[Union[BaseComponent, float]] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class LabeledListViewV1. """ @@ -469,9 +400,6 @@ class LabeledListViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] items: Optional[Union[BaseComponent, List[Union[BaseComponent, Item]]]] min_width: Optional[Union[BaseComponent, float]] @@ -487,22 +415,19 @@ class LinkViewV1(BaseViewV1): To insert a link with a search query, use helper.search-query. Attributes: + url: Link URL. label: Label above the component. content: Link text displayed to the user. hint: Hint text. - url: Link URL. validation: Validation based on condition. """ def __init__( self, - *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, url: Optional[Any] = None, - content: Optional[Any] = None + *, + content: Optional[Any] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class LinkViewV1. """ @@ -510,9 +435,6 @@ class LinkViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] url: Optional[Any] content: Optional[Any] @@ -524,23 +446,23 @@ class LinkGroupViewV1(BaseViewV1): This only groups links, unlike GroupViewV1. Attributes: + links: Array of links that make up a group. label: Label above the component. hint: Hint text. - links: Array of links that make up a group. validation: Validation based on condition. Example: How to add several links. >>> links = tb.view.LinkGroupViewV1( - >>> links=[ + >>> [ >>> tb.view.LinkGroupViewV1.Link( - >>> url='https://any.com/useful/url/1', - >>> content='Example1', + >>> 'https://any.com/useful/url/1', + >>> 'Example1', >>> ), >>> tb.view.LinkGroupViewV1.Link( - >>> url='https://any.com/useful/url/2', - >>> content='Example2', + >>> 'https://any.com/useful/url/2', + >>> 'Example2', >>> ), >>> ] >>> ) @@ -551,35 +473,32 @@ class LinkGroupViewV1(BaseViewV1): """Link parameters Attributes: + url: Link address content: Link text that's displayed to the user. Unviewed links are blue and underlined, and clicked links are purple. theme: Defines the appearance of the link. If you specify "theme": "primary", it's a button, otherwise it's a text link. - url: Link address """ def __init__( self, - *, + url: Optional[Union[BaseComponent, str]] = None, content: Optional[Union[BaseComponent, str]] = None, - theme: Optional[Union[BaseComponent, str]] = None, - url: Optional[Union[BaseComponent, str]] = None + *, + theme: Optional[Union[BaseComponent, str]] = None ) -> None: """Method generated by attrs for class LinkGroupViewV1.Link. """ ... _unexpected: Optional[Dict[str, Any]] + url: Optional[Union[BaseComponent, str]] content: Optional[Union[BaseComponent, str]] theme: Optional[Union[BaseComponent, str]] - url: Optional[Union[BaseComponent, str]] def __init__( self, + links: Optional[Union[BaseComponent, List[Union[BaseComponent, Link]]]] = None, *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, - links: Optional[Union[BaseComponent, List[Union[BaseComponent, Link]]]] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class LinkGroupViewV1. """ @@ -587,9 +506,6 @@ class LinkGroupViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] links: Optional[Union[BaseComponent, List[Union[BaseComponent, Link]]]] @@ -597,10 +513,10 @@ class ListViewV1(BaseViewV1): """Block for displaying data in a list. Attributes: + items: Array of list items. label: Label above the component. direction: Determines the direction of the list. hint: Hint text. - items: Array of list items. size: Specifies the size of the margins between elements. Acceptable values in ascending order: s, m (default value). validation: Validation based on condition. @@ -608,14 +524,11 @@ class ListViewV1(BaseViewV1): def __init__( self, - *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, items: Optional[Union[BaseComponent, List[BaseComponent]]] = None, + *, direction: Optional[Union[BaseComponent, ListDirection]] = None, - size: Optional[Union[BaseComponent, ListSize]] = None + size: Optional[Union[BaseComponent, ListSize]] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class ListViewV1. """ @@ -623,9 +536,6 @@ class ListViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] items: Optional[Union[BaseComponent, List[BaseComponent]]] direction: Optional[Union[BaseComponent, ListDirection]] size: Optional[Union[BaseComponent, ListSize]] @@ -644,15 +554,15 @@ class MarkdownViewV1(BaseViewV1): rel="noopener noreferrer" Attributes: - label: Label above the component. content: Text in Markdown. + label: Label above the component. hint: Hint text. validation: Validation based on condition. Example: How to add a title and description on the task interface. - >>> header = tb.view.MarkdownViewV1(content='# Some Header: + >>> header = tb.view.MarkdownViewV1('# Some Header: --- Some detailed description') ... @@ -660,12 +570,9 @@ class MarkdownViewV1(BaseViewV1): def __init__( self, + content: Optional[Any] = None, *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, - content: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class MarkdownViewV1. """ @@ -673,9 +580,6 @@ class MarkdownViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] content: Optional[Any] @@ -684,27 +588,24 @@ class TextViewV1(BaseViewV1): If you need formatted text, use view.markdown. Attributes: - label: Label above the component. content: The text displayed in the block. To insert a new line, use + label: Label above the component. hint: Hint text. validation: Validation based on condition. Example: How to show labeled field from the task inputs. - >>> text_view = tb.view.TextViewV1(label='My label:', content=tb.data.InputData(path='imput_field_name')) + >>> text_view = tb.view.TextViewV1(tb.data.InputData('input_field_name'), label='My label:') ... """ def __init__( self, + content: Optional[Any] = None, *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, - content: Optional[Any] = None + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class TextViewV1. """ @@ -712,9 +613,6 @@ class TextViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] content: Optional[Any] @@ -727,6 +625,7 @@ class VideoViewV1(BaseViewV1): The video resolution does not affect the size of the block — the video will fit into the block and will not be cropped. Attributes: + url: Link to the video file. label: Label above the component. full_height: If true, the element takes up all the vertical free space. The element is set to a minimum height of 400 pixels. @@ -735,20 +634,17 @@ class VideoViewV1(BaseViewV1): min_width: Minimum width of the element in pixels. Takes priority over max_width. ratio: The aspect ratio of the video block. An array of two numbers: the first sets the width of the block and the second sets the height. - url: Link to the video file. validation: Validation based on condition. """ def __init__( self, + url: Optional[Any] = None, *, - version: Optional[str] = '1.0.0', - hint: Optional[Any] = None, - label: Optional[Any] = None, - validation: Optional[BaseComponent] = None, full_height: Optional[Union[BaseComponent, bool]] = None, max_width: Optional[Union[BaseComponent, float]] = None, - min_width: Optional[Union[BaseComponent, float]] = None + min_width: Optional[Union[BaseComponent, float]] = None, + version: Optional[str] = '1.0.0' ) -> None: """Method generated by attrs for class VideoViewV1. """ @@ -756,9 +652,7 @@ class VideoViewV1(BaseViewV1): _unexpected: Optional[Dict[str, Any]] version: Optional[str] - hint: Optional[Any] - label: Optional[Any] - validation: Optional[BaseComponent] + url: Optional[Any] full_height: Optional[Union[BaseComponent, bool]] max_width: Optional[Union[BaseComponent, float]] min_width: Optional[Union[BaseComponent, float]] diff --git a/tests/template_builder/test_template_builder.py b/tests/template_builder/test_template_builder.py index ad8e8718..097436fb 100644 --- a/tests/template_builder/test_template_builder.py +++ b/tests/template_builder/test_template_builder.py @@ -140,89 +140,89 @@ def view_spec_map(): def test_result(view_spec_map): expected_result = TemplateBuilder( view=SideBySideLayoutV1( - version='1.0.0', - controls=ListViewV1( - version='1.0.0', - items=[ + ListViewV1( + [ RadioGroupFieldV1( - version='1.0.0', - data=RefComponent( - ref='vars.0' + RefComponent( + 'vars.0' ), - label='Какое фото вам больше нравится?', - options=[ + [ GroupFieldOption( - label='A', - value='a' + 'a', + 'A', ), GroupFieldOption( - label='B', - value='b', + 'b', + 'B', hint=TextareaFieldV1( data=InputData( - path='text' + 'text' ), version='1.0.0' ) ), GroupFieldOption( - label='Картинки не загрузились', - value='failure' + 'failure', + 'Картинки не загрузились', ) ], + label='Какое фото вам больше нравится?', + version='1.0.0' ), TextareaFieldV1( - version='1.0.0', - data=OutputData( - path='why' + OutputData( + 'why' ), + version='1.0.0', label=InputData( - path='text' + 'text' ), validation=RequiredConditionV1( version='1.0.0' ) ) - ] + ], + version='1.0.0', ), - items=[ + [ ImageViewV1( - version='1.2.3', - url=InputData( - path='image_a', + InputData( + 'image_a', ), + version='1.2.3', full_height=True ), ImageViewV1( - version='1.2.3', - url=InputData( - path='image_b' + InputData( + 'image_b' ), + version='1.2.3', full_height=True ) - ] + ], + version='1.0.0' ), plugins=[ HotkeysPluginV1( version='1.0.0', key_0=SetActionV1( version='1.0.0', - data=RefComponent(ref='vars.0'), + data=RefComponent('vars.0'), payload='failure' ), key_1=SetActionV1( version='1.0.0', - data=RefComponent(ref='vars.0'), + data=RefComponent('vars.0'), payload='a' ), key_2=SetActionV1( version='1.0.0', - data=RefComponent(ref='vars.0'), + data=RefComponent('vars.0'), payload='b' ) ) ], - vars={'0': OutputData(path='result')} + vars={'0': OutputData('result')} ) result = ViewSpec.structure(view_spec_map) @@ -231,13 +231,13 @@ def test_result(view_spec_map): def test_ref(view_spec_map): result = ViewSpec.structure(view_spec_map) - assert result.config.plugins[0].key_0.data == RefComponent(ref='vars.0') + assert result.config.plugins[0].key_0.data == RefComponent('vars.0') def test_union_with_base_component_parsing(view_spec_map): result = ViewSpec.structure(view_spec_map) - assert result.config.vars['0'] == OutputData(path='result') - assert result.config.view.controls.items[1].label == InputData(path='text') + assert result.config.vars['0'] == OutputData('result') + assert result.config.view.controls.items[1].label == InputData('text') def test_versions(view_spec_map): @@ -267,39 +267,39 @@ def test_get_input_and_output(): version='1.0.0', items=[ RadioGroupFieldV1( - version='1.0.0', - data=RefComponent( - ref='vars.0' + RefComponent( + 'vars.0' ), + version='1.0.0', label='Какое фото вам больше нравится?', options=[ GroupFieldOption( - label='A', - value='a' + 'a', + 'A', ), GroupFieldOption( - label='B', - value='b', + 'b', + 'B', hint=TextareaFieldV1( - data=InputData( - path='text' + InputData( + 'text' ), version='1.0.0' ) ), GroupFieldOption( - label='Картинки не загрузились', - value='failure' + 'failure', + 'Картинки не загрузились' ) ], ), TextareaFieldV1( - version='1.0.0', - data=OutputData( - path='why' + OutputData( + 'why' ), + version='1.0.0', label=InputData( - path='text' + 'text' ), validation=RequiredConditionV1( version='1.0.0' @@ -309,17 +309,13 @@ def test_get_input_and_output(): ), items=[ ImageViewV1( + InputData('image_a'), version='1.2.3', - url=InputData( - path='image_a', - ), full_height=True ), ImageViewV1( + InputData('image_b'), version='1.2.3', - url=InputData( - path='image_b' - ), full_height=True ) ] @@ -328,23 +324,23 @@ def test_get_input_and_output(): HotkeysPluginV1( version='1.0.0', key_0=SetActionV1( - version='1.0.0', - data=RefComponent(ref='vars.0'), - payload='failure' + RefComponent('vars.0'), + 'failure', + version='1.0.0' ), key_1=SetActionV1( - version='1.0.0', - data=RefComponent(ref='vars.0'), - payload='a' + RefComponent('vars.0'), + 'a', + version='1.0.0' ), key_2=SetActionV1( - version='1.0.0', - data=RefComponent(ref='vars.0'), - payload='b' + RefComponent('vars.0'), + 'b', + version='1.0.0' ) ) ], - vars={'0': OutputData(path='result')} + vars={'0': OutputData('result')} ) expected_input = { From 4e6f78b9a9ca3540d68d31010df0b4a6a39e47d3 Mon Sep 17 00:00:00 2001 From: Evgeny Tulin Date: Wed, 14 Jul 2021 14:33:57 +0300 Subject: [PATCH 4/8] readonly parameters in expands ![review](https://codereview.in.yandex-team.ru/badges/review-complete-green.svg) [![vlad--mois](https://codereview.in.yandex-team.ru/badges/vlad--mois-ok-green.svg)](https://staff.yandex-team.ru/vlad-mois) ref:504c48be8dbcfd0f063dbda9baca5210dd8a1a91 --- src/client/__init__.py | 1 + src/client/pool/__init__.py | 16 +++--- src/client/primitives/base.py | 14 +++++- src/client/project/__init__.py | 6 +-- src/client/skill.py | 6 +-- src/client/task.py | 10 ++-- src/client/task_suite.py | 8 +-- src/client/training.py | 14 +++--- src/client/user_bonus.py | 4 +- src/client/user_restriction.py | 6 +-- src/client/util/_codegen.py | 78 +++++++++++++++++++++--------- src/client/webhook_subscription.py | 6 +-- tests/pool/test_pool.py | 40 +++++++++++++++ tests/test_skill.py | 14 ++++++ tests/test_task.py | 6 +-- tests/test_user_bonus.py | 10 +++- 16 files changed, 172 insertions(+), 67 deletions(-) diff --git a/src/client/__init__.py b/src/client/__init__.py index f3a77a5a..7a1a2583 100644 --- a/src/client/__init__.py +++ b/src/client/__init__.py @@ -2384,6 +2384,7 @@ def get_operation_log(self, operation_id: str) -> List[OperationLogItem]: # User bonus + @expand('parameters') def create_user_bonus(self, user_bonus: UserBonus, parameters: Optional[UserBonusCreateRequestParameters] = None) -> UserBonus: """Issues payments directly to the performer diff --git a/src/client/pool/__init__.py b/src/client/pool/__init__.py index 978575b7..ea79f9a3 100644 --- a/src/client/pool/__init__.py +++ b/src/client/pool/__init__.py @@ -25,7 +25,7 @@ from .._converter import unstructure from ..filter import FilterCondition, FilterOr, FilterAnd from ..owner import Owner -from ..primitives.base import BaseTolokaObject +from ..primitives.base import attribute, BaseTolokaObject from ..quality_control import QualityControl from ..util._codegen import codegen_attr_attributes_setters, create_setter, expand @@ -219,13 +219,13 @@ class Type(Enum): owner: Owner # Readonly - id: str - status: Status - last_close_reason: CloseReason - created: datetime.datetime - last_started: datetime.datetime - last_stopped: datetime.datetime - type: Type + id: str = attribute(readonly=True) + status: Status = attribute(readonly=True) + last_close_reason: CloseReason = attribute(readonly=True) + created: datetime.datetime = attribute(readonly=True) + last_started: datetime.datetime = attribute(readonly=True) + last_stopped: datetime.datetime = attribute(readonly=True) + type: Type = attribute(readonly=True) def unstructure(self) -> Optional[dict]: self_unstructured_dict = super().unstructure() diff --git a/src/client/primitives/base.py b/src/client/primitives/base.py index d98ab637..183165f7 100644 --- a/src/client/primitives/base.py +++ b/src/client/primitives/base.py @@ -15,6 +15,7 @@ REQUIRED_KEY = 'toloka_field_required' ORIGIN_KEY = 'toloka_field_origin' +READONLY_KEY = 'toloka_field_readonly' E = TypeVar('E', bound=Enum) @@ -43,12 +44,23 @@ def __getitem__(self, value: E): return self.registered_classes[value] -def attribute(*args, required=False, origin=None, **kwargs): +def attribute(*args, required=False, origin=None, readonly=False, **kwargs): + """Proxy for attr.attrib(...). Adds several keywords. + + Args: + *args: All positional arguments from attr.attrib + required: If True makes attribute not Optional. All other attributes are optional by default. Defaults to False. + origin: Sets field name in dict for attribute, when structuring/unstructuring from dict. Defaults to None. + readonly: Affects only when the class 'expanding' as a parameter in some function. If True, drops this attribute from expanded parameters. Defaults to None. + **kwargs: All keyword arguments from attr.attrib + """ metadata = {} if required: metadata[REQUIRED_KEY] = True if origin: metadata[ORIGIN_KEY] = origin + if readonly: + metadata[READONLY_KEY] = True return attr.attrib(*args, metadata=metadata, **kwargs) diff --git a/src/client/project/__init__.py b/src/client/project/__init__.py index 580dc30a..a775d059 100644 --- a/src/client/project/__init__.py +++ b/src/client/project/__init__.py @@ -158,10 +158,10 @@ class AssignmentsIssuingViewConfig(BaseTolokaObject): quality_control: QualityControl # metadata: Dict[str, List[str]] ??? - status: ProjectStatus - created: datetime.datetime + status: ProjectStatus = attribute(readonly=True) + created: datetime.datetime = attribute(readonly=True) - id: str + id: str = attribute(readonly=True) public_instructions: str # public private_comment: str diff --git a/src/client/skill.py b/src/client/skill.py index 643bb1cb..dd77a36c 100644 --- a/src/client/skill.py +++ b/src/client/skill.py @@ -2,7 +2,7 @@ import datetime from typing import Dict -from .primitives.base import BaseTolokaObject +from .primitives.base import attribute, BaseTolokaObject LangIso639 = str @@ -65,5 +65,5 @@ class Skill(BaseTolokaObject): public_requester_description: Dict[LangIso639, str] # Readonly - id: str - created: datetime.datetime + id: str = attribute(readonly=True) + created: datetime.datetime = attribute(readonly=True) diff --git a/src/client/task.py b/src/client/task.py index dfa8ce4c..7588467c 100644 --- a/src/client/task.py +++ b/src/client/task.py @@ -57,8 +57,8 @@ class KnownSolution(BaseTolokaObject): message_on_unknown_solution: str # Readonly - id: str - origin_task_id: str + id: str = attribute(readonly=True) + origin_task_id: str = attribute(readonly=True) class Task(InfiniteOverlapParametersMixin, BaseTask): @@ -96,14 +96,14 @@ class BaselineSolution(BaseTolokaObject): pool_id: str - remaining_overlap: int + remaining_overlap: int = attribute(readonly=True) reserved_for: List[str] unavailable_for: List[str] traits_all_of: List[str] traits_any_of: List[str] traits_none_of_any: List[str] - origin_task_id: str - created: datetime.datetime + origin_task_id: str = attribute(readonly=True) + created: datetime.datetime = attribute(readonly=True) baseline_solutions: List[BaselineSolution] diff --git a/src/client/task_suite.py b/src/client/task_suite.py index 2da4e24b..05a3f6f4 100644 --- a/src/client/task_suite.py +++ b/src/client/task_suite.py @@ -64,10 +64,10 @@ class TaskSuite(InfiniteOverlapParametersMixin, BaseTolokaObject): latitude: float # Readonly - id: str - remaining_overlap: int - automerged: bool - created: datetime.datetime + id: str = attribute(readonly=True) + remaining_overlap: int = attribute(readonly=True) + automerged: bool = attribute(readonly=True) + created: datetime.datetime = attribute(readonly=True) @expand('base_task') def add_base_task(self, base_task: BaseTask) -> 'TaskSuite': diff --git a/src/client/training.py b/src/client/training.py index 413c44b1..4cc08516 100644 --- a/src/client/training.py +++ b/src/client/training.py @@ -4,7 +4,7 @@ from typing import Dict, List from .owner import Owner -from .primitives.base import BaseTolokaObject +from .primitives.base import attribute, BaseTolokaObject from .util._codegen import codegen_attr_attributes_setters @@ -98,12 +98,12 @@ class Status(Enum): owner: Owner # Readonly - id: str - status: Status - last_close_reason: CloseReason - created: datetime.datetime - last_started: datetime.datetime - last_stopped: datetime.datetime + id: str = attribute(readonly=True) + status: Status = attribute(readonly=True) + last_close_reason: CloseReason = attribute(readonly=True) + created: datetime.datetime = attribute(readonly=True) + last_started: datetime.datetime = attribute(readonly=True) + last_stopped: datetime.datetime = attribute(readonly=True) def is_open(self) -> bool: return self.status == Training.Status.OPEN diff --git a/src/client/user_bonus.py b/src/client/user_bonus.py index 673aec0e..2479d9c3 100644 --- a/src/client/user_bonus.py +++ b/src/client/user_bonus.py @@ -73,8 +73,8 @@ class UserBonus(BaseTolokaObject): assignment_id: str # Readonly - id: str - created: datetime.datetime + id: str = attribute(readonly=True) + created: datetime.datetime = attribute(readonly=True) class UserBonusCreateRequestParameters(Parameters): diff --git a/src/client/user_restriction.py b/src/client/user_restriction.py index 85f09e8a..9db64a98 100644 --- a/src/client/user_restriction.py +++ b/src/client/user_restriction.py @@ -9,7 +9,7 @@ import datetime from enum import unique, Enum -from .primitives.base import BaseTolokaObject +from .primitives.base import attribute, BaseTolokaObject @unique @@ -76,8 +76,8 @@ class Scope(Enum): will_expire: datetime.datetime # Readonly - id: str - created: datetime.datetime + id: str = attribute(readonly=True) + created: datetime.datetime = attribute(readonly=True) class AllProjectsUserRestriction(UserRestriction, spec_value=UserRestriction.ALL_PROJECTS): diff --git a/src/client/util/_codegen.py b/src/client/util/_codegen.py index 7548880f..d02573fb 100644 --- a/src/client/util/_codegen.py +++ b/src/client/util/_codegen.py @@ -2,17 +2,17 @@ import functools import linecache import uuid -from inspect import signature, Signature, Parameter +from inspect import signature, Signature, Parameter, BoundArguments from textwrap import dedent, indent -from typing import Callable, Dict, List, Optional, Type +from typing import Any, Callable, Dict, List, Optional, Tuple, Type import attr -from ..primitives.base import BaseTolokaObject, BaseTolokaObjectMetaclass +from ..primitives.base import BaseTolokaObject, BaseTolokaObjectMetaclass, READONLY_KEY from ..util._typing import is_optional_of -def _get_signature(func: Callable): +def _get_signature(func: Callable) -> Signature: """ Correctly processes a signature for a callable. Correctly processes classes @@ -64,15 +64,12 @@ def _get_annotations_from_signature(sig: Signature) -> dict: return annotations -def _check_arguments_compatibility(sig: Signature, args: List, kwargs: Dict): - """Checks if arguments are suitable for provided signature""" - +def _try_bind_arguments(sig: Signature, args: List, kwargs: Dict) -> Tuple[Optional[BoundArguments], Optional[TypeError]]: + """Checks if arguments are suitable for provided signature. Return bindings and exception.""" try: - sig.bind(*args, **kwargs) - except TypeError: - return False - - return True + return sig.bind(*args, **kwargs), None + except TypeError as err: + return None, err def _get_signature_invocation_string(sig: Signature) -> str: @@ -155,20 +152,27 @@ def codegen_attr_attributes_setters(cls): def expand_func_by_argument(func: Callable, arg_name: str, arg_type: Optional[Type] = None) -> Callable: - func_sig = _get_signature(func) - func_params = list(func_sig.parameters.values()) + func_sig: Signature = _get_signature(func) + func_params: List[Parameter] = list(func_sig.parameters.values()) - arg_param = func_sig.parameters[arg_name] + arg_param: Parameter = func_sig.parameters[arg_name] arg_index = next(i for (i, p) in enumerate(func_params) if p is arg_param) if arg_type is None: arg_type = is_optional_of(arg_param.annotation) or arg_param.annotation - arg_type_sig = _get_signature(arg_type) + arg_type_sig: Signature = _get_signature(arg_type) # TODO: add tests if arg_param.kind == Parameter.KEYWORD_ONLY: arg_type_sig = _make_keyword_only_signature(arg_type_sig) - new_params = list(func_params) + if attr.has(arg_type): + additional_params: dict[str, Parameter] = dict(arg_type_sig.parameters) + for field in attr.fields(arg_type): + if field.metadata.get(READONLY_KEY, False): + additional_params.pop(field.name) + arg_type_sig = arg_type_sig.replace(parameters=list(additional_params.values())) + + new_params: List[Parameter] = list(func_params) new_params[arg_index:arg_index + 1] = arg_type_sig.parameters.values() expanded_func = _compile_function( @@ -184,18 +188,44 @@ def expand_func_by_argument(func: Callable, arg_name: str, arg_type: Optional[Ty return expanded_func -def expand(arg_name, arg_type=None): +def _check_arg_type_compatibility(func_sig: Signature, arg_name: str, arg_type: Optional[Type], bound: BoundArguments) -> Tuple[bool, Optional[str]]: + arg_param: Parameter = func_sig.parameters[arg_name] + if arg_type is None: + arg_type = is_optional_of(arg_param.annotation) or arg_param.annotation + bound.apply_defaults() + arg_candidate: Any = bound.arguments[arg_name] # incoming argument + if isinstance(arg_candidate, arg_type): + return True, None + return False, f'Argument "{arg_candidate}" has type "{type(arg_candidate)}" that is not a subclass of "{arg_type}"' + + +def expand(arg_name: str, arg_type: Optional[Type] = None, check_type: bool = True) -> Callable: + """Allows you to call function also via passing values for creating "arg_name", not only via passing an instance of "arg_name" + Args: + arg_name: Parameter that will be expanded. + arg_type: Specify the type of this parameter. Defaults to None and calc it themselves. + check_type: If True, check that one argument has a compatible type for none expanded version. If not, calls an expanded version. Defaults to True. + """ def wrapper(func): - func_sig = _get_signature(func) - expanded_func = expand_func_by_argument(func, arg_name, arg_type) + func_sig: Signature = _get_signature(func) + expanded_func: Callable = expand_func_by_argument(func, arg_name, arg_type) + expanded_func_sig: Signature = _get_signature(expanded_func) @functools.wraps(func) def wrapped(*args, **kwargs): - - if _check_arguments_compatibility(func_sig, args, kwargs): - return func(*args, **kwargs) - + bound, func_problem = _try_bind_arguments(func_sig, args, kwargs) + if bound is not None: + if check_type and arg_name not in kwargs: + fit, func_problem = _check_arg_type_compatibility(func_sig, arg_name, arg_type, bound) + if fit: + return func(*args, **kwargs) + else: + return func(*args, **kwargs) + + bound, expand_func_problem = _try_bind_arguments(expanded_func_sig, args, kwargs) + if bound is None: + raise TypeError(f'Arguments does not fit standart or expanded version.\nStandart version on problem: {func_problem}\nExpand version on problem: {expand_func_problem}') return expanded_func(*args, **kwargs) wrapped._func = func diff --git a/src/client/webhook_subscription.py b/src/client/webhook_subscription.py index 2b31a886..b656eaff 100644 --- a/src/client/webhook_subscription.py +++ b/src/client/webhook_subscription.py @@ -4,7 +4,7 @@ from datetime import datetime from enum import Enum, unique -from .primitives.base import BaseTolokaObject +from .primitives.base import attribute, BaseTolokaObject class WebhookSubscription(BaseTolokaObject): @@ -48,5 +48,5 @@ class EventType(Enum): secret_key: str # Readonly - id: str - created: datetime + id: str = attribute(readonly=True) + created: datetime = attribute(readonly=True) diff --git a/tests/pool/test_pool.py b/tests/pool/test_pool.py index 2590609e..3727af0c 100644 --- a/tests/pool/test_pool.py +++ b/tests/pool/test_pool.py @@ -78,6 +78,23 @@ def get_pools(request, context): assert expected_pools == client.unstructure(list(result)) +def test_get_pools_one_params(requests_mock, toloka_client, toloka_url, pool_map_with_readonly): + pools = [dict(pool_map_with_readonly, id=str(i)) for i in range(10)] + pools.sort(key=itemgetter('id')) + expected_pools = [pool for pool in pools] + + def get_pools(request, context): + params = parse_qs(urlparse(request.url).query) + assert {'status': ['OPEN'], 'sort': ['id']} == params + return {'items': [pool for pool in pools], 'has_more': False} + + requests_mock.get(f'{toloka_url}/pools', json=get_pools) + + # Expanded positional syntax + result = toloka_client.get_pools('OPEN') + assert expected_pools == client.unstructure(list(result)) + + def test_get_pool(requests_mock, toloka_client, toloka_url, pool_map_with_readonly): requests_mock.get(f'{toloka_url}/pools/21', json=pool_map_with_readonly) assert pool_map_with_readonly == client.unstructure(toloka_client.get_pool('21')) @@ -281,6 +298,10 @@ def pools(request, context): result = toloka_client.patch_pool('21', priority=42) assert raw_result == client.unstructure(result) + # Expanded positional syntax + result = toloka_client.patch_pool('21', 42) + assert raw_result == client.unstructure(result) + @pytest.fixture def open_pool_operation_map(): @@ -516,3 +537,22 @@ def test_clone_pool(requests_mock, toloka_client, toloka_url, 'A new pool with ID "22" has been cloned. Link to open in web interface: https://sandbox.toloka.yandex.com/requester/project/10/pool/22' )] assert cloned_pool_map == client.unstructure(result) + + +@pytest.fixture +def simple_project_with_mixer_config(): + return { + 'project_id': '12345', + 'defaults': {'default_overlap_for_new_task_suites': 1}, + 'quality_control': {'configs': []}, + 'mixer_config': {'real_tasks_count': 1, 'golden_tasks_count': 0, 'training_tasks_count': 0}, + } + + +def test_mixer_config_expand(simple_project_with_mixer_config): + pool = client.Pool(project_id='12345') + pool.set_mixer_config(real_tasks_count=1) + assert client.unstructure(pool) == simple_project_with_mixer_config + + with pytest.raises(TypeError): + pool.set_mixer_config(1) diff --git a/tests/test_skill.py b/tests/test_skill.py index b2f4dc4e..a5d09d22 100644 --- a/tests/test_skill.py +++ b/tests/test_skill.py @@ -127,6 +127,20 @@ def create_skill(request, context): assert skill_sample == client.unstructure(result) +def test_create_skill_readonly_fields(skill_sample, toloka_client): + with pytest.raises(TypeError): + toloka_client.create_skill( + id='21', + name='Skill name', + private_comment='Private comment', + hidden=False, + public_requester_description={ + 'EN': 'Skill description', + 'RU': 'Описание навыка', + }, + ) + + def test_update_skill(skill_sample, skill_header, requests_mock, toloka_client, toloka_url): def update_skill(request, context): assert request.json() == skill_header diff --git a/tests/test_task.py b/tests/test_task.py index a17c19a8..4e333cd3 100644 --- a/tests/test_task.py +++ b/tests/test_task.py @@ -460,7 +460,7 @@ def tasks(request, context): requests_mock.patch(f'{toloka_url}/tasks/task-1', json=tasks) # Request object syntax - request = client.unstructure(raw_request) + request = client.structure(raw_request, client.task.TaskPatch) result = toloka_client.patch_task('task-1', request) assert raw_result == client.unstructure(result) @@ -513,7 +513,7 @@ def tasks(request, context): requests_mock.patch(f'{toloka_url}/tasks/task-1/set-overlap-or-min', json=tasks) # Request object syntax - request = client.unstructure(raw_request) + request = client.structure(raw_request, client.task.TaskPatch) result = toloka_client.patch_task_overlap_or_min('task-1', request) assert raw_result == client.unstructure(result) @@ -533,7 +533,7 @@ def tasks(request, context): requests_mock.patch(f'{toloka_url}/tasks/task-1/set-overlap-or-min', json=tasks) # Request object syntax - request = client.unstructure(raw_request) + request = client.structure(raw_request, client.task.TaskPatch) result = toloka_client.patch_task_overlap_or_min('task-1', request) assert raw_result == client.unstructure(result) diff --git a/tests/test_user_bonus.py b/tests/test_user_bonus.py index 96c4c33e..1eb2e2f6 100644 --- a/tests/test_user_bonus.py +++ b/tests/test_user_bonus.py @@ -57,13 +57,21 @@ def user_bonus_map_without_message_with_readonly(user_bonus_map_without_message) def test_create_user_bonus(requests_mock, toloka_client, toloka_url, user_bonus_map, user_bonus_map_with_readonly): def user_bonuses(request, context): + assert {'skip_invalid_items': ['true']} == parse_qs(urlparse(request.url).query) assert user_bonus_map == request.json() return simplejson.dumps(user_bonus_map_with_readonly) requests_mock.post(f'{toloka_url}/user-bonuses', text=user_bonuses, status_code=201) user_bonus = client.structure(user_bonus_map, client.user_bonus.UserBonus) assert user_bonus.amount == Decimal('1.50') - result = toloka_client.create_user_bonus(user_bonus) + result = toloka_client.create_user_bonus( + user_bonus, + client.user_bonus.UserBonusCreateRequestParameters(skip_invalid_items=True), + ) + assert user_bonus_map_with_readonly == client.unstructure(result) + + # Expanded syntax + result = toloka_client.create_user_bonus(user_bonus, skip_invalid_items=True) assert user_bonus_map_with_readonly == client.unstructure(result) From f3d45effb814495e8fef9d4ae1a764dc15c65660 Mon Sep 17 00:00:00 2001 From: alexdrydew Date: Wed, 14 Jul 2021 17:43:04 +0300 Subject: [PATCH 5/8] PR from branch users/alexdrydew/add_init_signature toloka-kit md update doc type support for expanded init args **** ![review](https://codereview.in.yandex-team.ru/badges/review-complete-green.svg) [![vlad--mois](https://codereview.in.yandex-team.ru/badges/vlad--mois-...-yellow.svg)](https://staff.yandex-team.ru/vlad-mois) [![sinosov](https://codereview.in.yandex-team.ru/badges/sinosov-ok-green.svg)](https://staff.yandex-team.ru/sinosov) ref:1944bea71ea56dec0e905fdf900416617032cc79 --- src/client/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/__init__.py b/src/client/__init__.py index 7a1a2583..27d83485 100644 --- a/src/client/__init__.py +++ b/src/client/__init__.py @@ -2622,8 +2622,8 @@ def get_user_restrictions(self, request: search_requests.UserRestrictionSearchRe UserRestriction: The next object corresponding to the request parameters. Example: - >>> results_list = [restriction for restriction in toloka_client.get_user_restrictions(scope='ALL_PROJECTS')] - ... + >>> results_list = [restriction for restriction in toloka_client.get_user_restrictions(scope='ALL_PROJECTS')] + ... """ return self._find_all(self.find_user_restrictions, request) From 02ef78f98eed1a637bf4a00381d470c3343d7d31 Mon Sep 17 00:00:00 2001 From: Stepan Nosov Date: Thu, 15 Jul 2021 16:52:55 +0300 Subject: [PATCH 6/8] hotfixes ![review](https://codereview.in.yandex-team.ru/badges/review-complete-green.svg) [![losev](https://codereview.in.yandex-team.ru/badges/losev-...-yellow.svg)](https://staff.yandex-team.ru/losev) [![tulinev](https://codereview.in.yandex-team.ru/badges/tulinev-ok-green.svg)](https://staff.yandex-team.ru/tulinev) ref:e2a9e2b7e1989327ee44400075cd8bdd4f7305cf --- src/client/__init__.pyi | 1050 +++++++++++++++++++++++++--- src/client/batch_create_results.py | 3 +- src/client/collectors.pyi | 128 ++-- src/client/conditions.py | 3 + src/client/conditions.pyi | 2 + src/client/primitives/base.pyi | 13 +- src/client/search_requests.py | 6 +- src/client/search_requests.pyi | 3 + src/client/task_suite.pyi | 4 +- 9 files changed, 1049 insertions(+), 163 deletions(-) diff --git a/src/client/__init__.pyi b/src/client/__init__.pyi index 56988022..8105faad 100644 --- a/src/client/__init__.pyi +++ b/src/client/__init__.pyi @@ -224,13 +224,13 @@ class TolokaClient: * DAY - Retry daily quotas. We strongly not recommended retrying these quotas. Example: - How to create TolokaClient and make you first request to Toloka. + How to create TolokaClient instance and make your first request to Toloka. - >>> import toloka.client as toloka - >>> token = input("Enter your token:") - >>> toloka_client = toloka.TolokaClient(token, 'PRODUCTION') - >>> print(toloka_client.get_requester()) + >>> your_oauth_token = input('Enter your token:') + >>> toloka_client = toloka.TolokaClient(your_oauth_token, 'PRODUCTION') # Or switch to 'SANDBOX' environment ... + + **Note**: `toloka_client` instance will be used to pass all API calls later on. """ class Environment(Enum): @@ -269,7 +269,8 @@ class TolokaClient: Example: How to accept one assignment. - >>> toloka_client.accept_assignment(assignment_id, "Well done!") + >>> toloka_client.accept_assignment(assignment_id, 'Well done!') + ... """ ... @@ -286,6 +287,10 @@ class TolokaClient: Returns: MessageThread: Full object by ID with updated folders. + + Example: + >>> toloka_client.add_message_thread_to_folders(message_thread_id='1', folders=['IMPORTANT']) + ... """ ... @@ -303,7 +308,7 @@ class TolokaClient: Responses to all completed tasks will be aggregated. The method only starts the aggregation and returns the operation for further tracking. - Note: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation + **Note**: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation methods and can perform on your computers: https://github.com/Toloka/crowd-kit Args: @@ -334,7 +339,7 @@ class TolokaClient: Responses to all completed tasks will be aggregated. The method only starts the aggregation and returns the operation for further tracking. - Note: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation + **Note**: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation methods and can perform on your computers: https://github.com/Toloka/crowd-kit Args: @@ -430,6 +435,11 @@ class TolokaClient: Returns: Pool: Object with updated status. + + Example: + >>> closed_pool = next(toloka_client.get_pools(status='CLOSED')) + >>> toloka_client.archive_pool(pool_id=closed_pool.id) + ... """ ... @@ -444,6 +454,12 @@ class TolokaClient: Returns: PoolArchiveOperation: An operation upon completion of which you can get the pool with updated status. + + Example: + >>> closed_pool = next(toloka_client.get_pools(status='CLOSED')) + >>> archive_op = toloka_client.archive_pool_async(pool_id=closed_pool.id) + >>> toloka_client.wait_operation(archive_op) + ... """ ... @@ -458,6 +474,10 @@ class TolokaClient: Returns: Project: Object with updated status. + + Example: + >>> toloka_client.archive_project(project_id='1') + ... """ ... @@ -472,6 +492,11 @@ class TolokaClient: Returns: ProjectArchiveOperation: An operation upon completion of which you can get the project with updated status. + + Example: + >>> archive_op = toloka_client.archive_project_async(project_id='1') + >>> toloka_client.wait_operation(archive_op) + ... """ ... @@ -486,6 +511,11 @@ class TolokaClient: Returns: Training: Object with updated status. + + Example: + >>> closed_training = next(toloka_client.get_trainings(status='CLOSED')) + >>> toloka_client.archive_training(training_id=closed_training.id) + ... """ ... @@ -500,6 +530,12 @@ class TolokaClient: Returns: TrainingArchiveOperation: An operation upon completion of which you can get the training with updated status. + + Example: + >>> closed_training = next(toloka_client.find_trainings(status='CLOSED')) + >>> archive_op = toloka_client.archive_training_async(training_id=closed_training.id) + >>> toloka_client.wait_operation(archive_op) + ... """ ... @@ -514,6 +550,10 @@ class TolokaClient: Returns: Pool: New pool. + + Example: + >>> toloka_client.clone_pool(pool_id='1') + ... """ ... @@ -528,6 +568,11 @@ class TolokaClient: Returns: PoolCloneOperation: An operation upon completion of which you can get the new pool. + + Example: + >>> new_pool = toloka_client.clone_pool_async(pool_id='1') + >>> toloka_client.wait_operation(new_pool) + ... """ ... @@ -575,6 +620,10 @@ class TolokaClient: Returns: Training: New training. + + Example: + >>> toloka_client.clone_training(training_id='1') + ... """ ... @@ -589,6 +638,11 @@ class TolokaClient: Returns: TrainingCloneOperation: An operation upon completion of which you can get the new training. + + Example: + >>> clone_training = toloka_client.clone_training_async(training_id='1') + >>> toloka_client.wait_operation(clone_training) + ... """ ... @@ -602,6 +656,11 @@ class TolokaClient: Returns: Pool: Pool object with new status. + + Example: + >>> open_pool = next(toloka_client.get_pools(status='OPEN')) + >>> toloka_client.close_pool(pool_id=open_pool.id) + ... """ ... @@ -615,12 +674,33 @@ class TolokaClient: Returns: PoolCloseOperation: An operation upon completion of which you can get the pool with updated status. + + Example: + >>> open_pool = next(toloka_client.get_pools(status='OPEN')) + >>> close_op = toloka_client.close_pool_async(pool_id=open_pool.id) + >>> toloka_client.wait_operation(close_op) + ... """ ... - def close_pool_for_update(self, pool_id: str) -> Pool: ... + def close_pool_for_update(self, pool_id: str) -> Pool: + """Closes pool for update + + Example: + >>> toloka_client.close_pool_for_update(pool_id='1') + ... + """ + ... - def close_pool_for_update_async(self, pool_id: str) -> PoolCloseOperation: ... + def close_pool_for_update_async(self, pool_id: str) -> PoolCloseOperation: + """Closes pool for update, asynchronous version + + Example: + >>> close_op = toloka_client.close_pool_for_update_async(pool_id='1') + >>> toloka_client.wait_operation(close_op) + ... + """ + ... def close_training(self, training_id: str) -> Training: """Stops distributing tasks from the training @@ -630,6 +710,11 @@ class TolokaClient: Returns: Training: Training object with new status. + + Example: + >>> open_training = next(toloka_client.get_trainings(status='OPEN')) + >>> toloka_client.close_training(training_id=open_training.id) + ... """ ... @@ -641,6 +726,12 @@ class TolokaClient: Returns: TrainingCloseOperation: An operation upon completion of which you can get the training with updated status. + + Example: + >>> open_training = next(toloka_client.get_trainings(status='OPEN')) + >>> close_training = toloka_client.close_training_async(training_id=open_training.id) + >>> toloka_client.wait_operation(close_training) + ... """ ... @@ -664,6 +755,18 @@ class TolokaClient: Returns: MessageThread: New created thread. + + Example: + If you want to thank Toloka performers who have tried to complete your tasks, send them a nice message. + + >>> message_text = 'Amazing job! We've just trained our first model with the data YOU prepared for us. Thank you!' + >>> toloka_client.compose_message_thread( + >>> recipients_select_type='ALL', + >>> topic={'EN':'Thank you, performer!'}, + >>> text={'EN': message_text}, + >>> answerable=False + >>> ) + ... """ ... @@ -678,6 +781,18 @@ class TolokaClient: Returns: MessageThread: New created thread. + + Example: + If you want to thank Toloka performers who have tried to complete your tasks, send them a nice message. + + >>> message_text = 'Amazing job! We've just trained our first model with the data YOU prepared for us. Thank you!' + >>> toloka_client.compose_message_thread( + >>> recipients_select_type='ALL', + >>> topic={'EN':'Thank you, performer!'}, + >>> text={'EN': message_text}, + >>> answerable=False + >>> ) + ... """ ... @@ -695,7 +810,6 @@ class TolokaClient: Example: How to create a new pool in a project. - >>> toloka_client = toloka.TolokaClient(your_token, 'PRODUCTION') >>> new_pool = toloka.pool.Pool( >>> project_id=existing_project_id, >>> private_name='Pool 1', @@ -753,9 +867,7 @@ class TolokaClient: skill_ttl_hours: Optional[int] = None, training: Optional[bool] = None, public_name: Optional[Dict[str, str]] = None, - public_requester_description: Optional[Dict[str, str]] = None, - id: Optional[str] = None, - created: Optional[datetime] = None + public_requester_description: Optional[Dict[str, str]] = None ) -> Skill: """Creates a new Skill @@ -768,13 +880,13 @@ class TolokaClient: Skill: Created skill. With read-only fields. Example: - How to create new skill. + How to create a new skill. >>> new_skill = toloka_client.create_skill( >>> name='Area selection of road signs', >>> public_requester_description={ >>> 'EN': 'Performer is annotating road signs', - >>> 'RU': 'Как исполнитель размечает дорожные знаки', + >>> 'FR': 'L'exécuteur marque les signaux routier', >>> }, >>> ) >>> print(new_skill.id) @@ -795,13 +907,13 @@ class TolokaClient: Skill: Created skill. With read-only fields. Example: - How to create new skill. + How to create a new skill. >>> new_skill = toloka_client.create_skill( >>> name='Area selection of road signs', >>> public_requester_description={ >>> 'EN': 'Performer is annotating road signs', - >>> 'RU': 'Как исполнитель размечает дорожные знаки', + >>> 'FR': 'L'exécuteur marque les signaux routier', >>> }, >>> ) >>> print(new_skill.id) @@ -829,6 +941,13 @@ class TolokaClient: Returns: Task: Created task. + + Example: + >>> task = toloka.task.Task( + >>> input_values={'image': 'https://tlk.s3.yandex.net/dataset/cats_vs_dogs/dogs/048e5760fc5a46faa434922b2447a527.jpg'}, + >>> pool_id='1') + >>> toloka_client.create_task(task=task, allow_defaults=True) + ... """ ... @@ -850,6 +969,13 @@ class TolokaClient: Returns: Task: Created task. + + Example: + >>> task = toloka.task.Task( + >>> input_values={'image': 'https://tlk.s3.yandex.net/dataset/cats_vs_dogs/dogs/048e5760fc5a46faa434922b2447a527.jpg'}, + >>> pool_id='1') + >>> toloka_client.create_task(task=task, allow_defaults=True) + ... """ ... @@ -878,6 +1004,14 @@ class TolokaClient: Returns: TaskSuite: Created task suite. + + Example: + >>> new_task_suite = toloka.task_suite.TaskSuite( + >>> pool_id='1', + >>> tasks=[toloka.task.Task(input_values={'label': 'Cats vs Dogs'})], + >>> overlap=2) + >>> toloka_client.create_task_suite(new_task_suite) + ... """ ... @@ -901,6 +1035,14 @@ class TolokaClient: Returns: TaskSuite: Created task suite. + + Example: + >>> new_task_suite = toloka.task_suite.TaskSuite( + >>> pool_id='1', + >>> tasks=[toloka.task.Task(input_values={'label': 'Cats vs Dogs'})], + >>> overlap=2) + >>> toloka_client.create_task_suite(new_task_suite) + ... """ ... @@ -932,12 +1074,28 @@ class TolokaClient: operations is used. Returns: - TaskSuiteBatchCreateResult: Result of task suites creating. Contains created task suites in "items" and + TaskSuiteBatchCreateResult: Result of task suites creating. Contains created task suites in `items` and problems in "validation_errors". Raises: ValidationApiError: If no tasks were created, or skip_invalid_items==False and there is a problem when checking any task. + + Example: + >>> task_suites = [ + >>> toloka.task_suite.TaskSuite( + >>> pool_id=pool.id, + >>> overlap=1, + >>> tasks=[ + >>> toloka.task.Task(input_values={ + >>> 'input1': some_input_value, + >>> 'input2': some_input_value + >>> }) + >>> ] + >>> ) + >>> ] + >>> task_suites = toloka_client.create_task_suites(task_suites) + ... """ ... @@ -964,12 +1122,28 @@ class TolokaClient: operations is used. Returns: - TaskSuiteBatchCreateResult: Result of task suites creating. Contains created task suites in "items" and + TaskSuiteBatchCreateResult: Result of task suites creating. Contains created task suites in `items` and problems in "validation_errors". Raises: ValidationApiError: If no tasks were created, or skip_invalid_items==False and there is a problem when checking any task. + + Example: + >>> task_suites = [ + >>> toloka.task_suite.TaskSuite( + >>> pool_id=pool.id, + >>> overlap=1, + >>> tasks=[ + >>> toloka.task.Task(input_values={ + >>> 'input1': some_input_value, + >>> 'input2': some_input_value + >>> }) + >>> ] + >>> ) + >>> ] + >>> task_suites = toloka_client.create_task_suites(task_suites) + ... """ ... @@ -995,6 +1169,23 @@ class TolokaClient: Returns: TaskSuiteCreateBatchOperation: An operation upon completion of which you can get the created teask suites. + + Example: + >>> task_suites = [ + >>> toloka.task_suite.TaskSuite( + >>> pool_id=pool.id, + >>> overlap=1, + >>> tasks=[ + >>> toloka.task.Task(input_values={ + >>> 'input1': some_input_value, + >>> 'input2': some_input_value + >>> }) + >>> ] + >>> ) + >>> ] + >>> task_suites_op = toloka_client.create_task_suites_async(task_suites) + >>> toloka_client.wait_operation(task_suites_op) + ... """ ... @@ -1015,6 +1206,23 @@ class TolokaClient: Returns: TaskSuiteCreateBatchOperation: An operation upon completion of which you can get the created teask suites. + + Example: + >>> task_suites = [ + >>> toloka.task_suite.TaskSuite( + >>> pool_id=pool.id, + >>> overlap=1, + >>> tasks=[ + >>> toloka.task.Task(input_values={ + >>> 'input1': some_input_value, + >>> 'input2': some_input_value + >>> }) + >>> ] + >>> ) + >>> ] + >>> task_suites_op = toloka_client.create_task_suites_async(task_suites) + >>> toloka_client.wait_operation(task_suites_op) + ... """ ... @@ -1043,7 +1251,7 @@ class TolokaClient: operations is used. Returns: - batch_create_results.TaskBatchCreateResult: Result of tasks creating. Contains created tasks in "items" and + batch_create_results.TaskBatchCreateResult: Result of tasks creating. Contains created tasks in `items` and problems in "validation_errors". Raises: @@ -1051,7 +1259,7 @@ class TolokaClient: checking any task. Example: - How to create regular tasks from csv. + How to create regular tasks from tsv. >>> dataset = pandas.read_csv('dataset.tsv', sep=' ') >>> tasks = [ @@ -1100,7 +1308,7 @@ class TolokaClient: operations is used. Returns: - batch_create_results.TaskBatchCreateResult: Result of tasks creating. Contains created tasks in "items" and + batch_create_results.TaskBatchCreateResult: Result of tasks creating. Contains created tasks in `items` and problems in "validation_errors". Raises: @@ -1108,7 +1316,7 @@ class TolokaClient: checking any task. Example: - How to create regular tasks from csv. + How to create regular tasks from tsv. >>> dataset = pandas.read_csv('dataset.tsv', sep=' ') >>> tasks = [ @@ -1159,6 +1367,19 @@ class TolokaClient: Returns: TasksCreateOperation: An operation upon completion of which you can get the created tasks. + + Example: + >>> training_tasks = [ + >>> toloka.task.Task( + >>> input_values={'image': 'link1'}, + >>> pool_id='1'), + >>> toloka.task.Task( + >>> input_values={'image': 'link2'}, + >>> pool_id='1') + >>> ] + >>> tasks_op = toloka_client.create_tasks_async(training_tasks) + >>> toloka_client.wait_operation(tasks_op) + ... """ ... @@ -1179,6 +1400,19 @@ class TolokaClient: Returns: TasksCreateOperation: An operation upon completion of which you can get the created tasks. + + Example: + >>> training_tasks = [ + >>> toloka.task.Task( + >>> input_values={'image': 'link1'}, + >>> pool_id='1'), + >>> toloka.task.Task( + >>> input_values={'image': 'link2'}, + >>> pool_id='1') + >>> ] + >>> tasks_op = toloka_client.create_tasks_async(training_tasks) + >>> toloka_client.wait_operation(tasks_op) + ... """ ... @@ -1213,6 +1447,43 @@ class TolokaClient: """ ... + @overload + def create_user_bonus( + self, + user_bonus: UserBonus, + *, + operation_id: Optional[str] = None, + skip_invalid_items: Optional[bool] = None + ) -> UserBonus: + """Issues payments directly to the performer + + You can send a maximum of 10,000 requests of this kind per day. + + Args: + user_bonus: To whom, how much to pay and for what. + parameters: Parameters for UserBonus creation controlling. + + Returns: + UserBonus: Created bonus. + + Example: + Create bonus for specific assignment. + + >>> import decimal + >>> new_bonus = toloka_client.create_user_bonus( + >>> UserBonus( + >>> user_id='1', + >>> amount=decimal.Decimal('0.50'), + >>> public_title='Perfect job!', + >>> public_message='You are the best performer!', + >>> assignment_id='012345' + >>> ) + >>> ) + ... + """ + ... + + @overload def create_user_bonus( self, user_bonus: UserBonus, @@ -1230,14 +1501,15 @@ class TolokaClient: UserBonus: Created bonus. Example: - How to create bonus with message for specific assignment. + Create bonus for specific assignment. + >>> import decimal >>> new_bonus = toloka_client.create_user_bonus( >>> UserBonus( >>> user_id='1', - >>> amount='0.50', + >>> amount=decimal.Decimal('0.50'), >>> public_title='Perfect job!', - >>> public_message='You are the best performer EVER!' + >>> public_message='You are the best performer!', >>> assignment_id='012345' >>> ) >>> ) @@ -1263,8 +1535,27 @@ class TolokaClient: parameters: Parameters for UserBonus creation controlling. Returns: - UserBonusBatchCreateResult: Result of user bonuses creating. Contains created user bonuses in "items" and + UserBonusBatchCreateResult: Result of user bonuses creating. Contains created user bonuses in `items` and problems in "validation_errors". + + Example: + >>> import decimal + >>> new_bonuses=[ + >>> UserBonus( + >>> user_id='1', + >>> amount=decimal.Decimal('0.50'), + >>> public_title='Perfect job!', + >>> public_message='You are the best performer!', + >>> assignment_id='1'), + >>> UserBonus( + >>> user_id='2', + >>> amount=decimal.Decimal('1.0'), + >>> public_title='Excellent work!', + >>> public_message='You completed all the tasks!', + >>> assignment_id='2') + >>> ] + >>> toloka_client.create_user_bonuses(new_bonuses) + ... """ ... @@ -1284,8 +1575,27 @@ class TolokaClient: parameters: Parameters for UserBonus creation controlling. Returns: - UserBonusBatchCreateResult: Result of user bonuses creating. Contains created user bonuses in "items" and + UserBonusBatchCreateResult: Result of user bonuses creating. Contains created user bonuses in `items` and problems in "validation_errors". + + Example: + >>> import decimal + >>> new_bonuses=[ + >>> UserBonus( + >>> user_id='1', + >>> amount=decimal.Decimal('0.50'), + >>> public_title='Perfect job!', + >>> public_message='You are the best performer!', + >>> assignment_id='1'), + >>> UserBonus( + >>> user_id='2', + >>> amount=decimal.Decimal('1.0'), + >>> public_title='Excellent work!', + >>> public_message='You completed all the tasks!', + >>> assignment_id='2') + >>> ] + >>> toloka_client.create_user_bonuses(new_bonuses) + ... """ ... @@ -1307,6 +1617,26 @@ class TolokaClient: Returns: UserBonusCreateBatchOperation: An operation upon completion of which the bonuses can be considered created. + + Example: + >>> import decimal + >>> new_bonuses=[ + >>> UserBonus( + >>> user_id='1', + >>> amount=decimal.Decimal('0.50'), + >>> public_title='Perfect job!', + >>> public_message='You are the best performer!', + >>> assignment_id='1'), + >>> UserBonus( + >>> user_id='2', + >>> amount=decimal.Decimal('1.0'), + >>> public_title='Excellent work!', + >>> public_message='You completed all the tasks!', + >>> assignment_id='2') + >>> ] + >>> create_bonuses = toloka_client.create_user_bonuses_async(new_bonuses) + >>> toloka_client.wait_operation(create_bonuses) + ... """ ... @@ -1326,6 +1656,26 @@ class TolokaClient: Returns: UserBonusCreateBatchOperation: An operation upon completion of which the bonuses can be considered created. + + Example: + >>> import decimal + >>> new_bonuses=[ + >>> UserBonus( + >>> user_id='1', + >>> amount=decimal.Decimal('0.50'), + >>> public_title='Perfect job!', + >>> public_message='You are the best performer!', + >>> assignment_id='1'), + >>> UserBonus( + >>> user_id='2', + >>> amount=decimal.Decimal('1.0'), + >>> public_title='Excellent work!', + >>> public_message='You completed all the tasks!', + >>> assignment_id='2') + >>> ] + >>> create_bonuses = toloka_client.create_user_bonuses_async(new_bonuses) + >>> toloka_client.wait_operation(create_bonuses) + ... """ ... @@ -1334,6 +1684,10 @@ class TolokaClient: Args: user_restriction_id: Restriction that should be removed. + + Example: + >>> toloka_client.delete_user_restriction(user_restriction_id='1') + ... """ ... @@ -1344,6 +1698,10 @@ class TolokaClient: Args: user_skill_id: ID of the fact that the performer has a skill to delete. + + Example: + >>> toloka_client.delete_user_skill(user_skill_id='1') + ... """ ... @@ -1367,10 +1725,10 @@ class TolokaClient: out: File object where to put downloaded file. Example: - How to download attachment. + How to download an attachment. >>> with open('my_new_file.txt', 'wb') as out_f: - >>> toloka_client.download_attachment('attachment-id', out_f) + >>> toloka_client.download_attachment(attachment_id='1', out=out_f) ... """ ... @@ -1389,7 +1747,7 @@ class TolokaClient: """Gets aggregated responses after the AggregatedSolutionOperation completes. It is better to use the "get_aggregated_solutions" method, that allows to iterate through all results. - Note: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation + **Note**: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation methods and can perform on your computers: https://github.com/Toloka/crowd-kit Args: @@ -1400,7 +1758,7 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - search_results.AggregatedSolutionSearchResult: The first "limit" solutions in "items". And a mark that there is more. + search_results.AggregatedSolutionSearchResult: The first `limit` solutions in `items`. And a mark that there is more. Example: How to get all aggregated solutions from pool. @@ -1431,7 +1789,7 @@ class TolokaClient: """Gets aggregated responses after the AggregatedSolutionOperation completes. It is better to use the "get_aggregated_solutions" method, that allows to iterate through all results. - Note: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation + **Note**: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation methods and can perform on your computers: https://github.com/Toloka/crowd-kit Args: @@ -1442,7 +1800,7 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - search_results.AggregatedSolutionSearchResult: The first "limit" solutions in "items". And a mark that there is more. + search_results.AggregatedSolutionSearchResult: The first `limit` solutions in `items`. And a mark that there is more. Example: How to get all aggregated solutions from pool. @@ -1499,7 +1857,15 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - search_results.AssignmentSearchResult: The first "limit" assignments in "items". And a mark that there is more. + search_results.AssignmentSearchResult: The first `limit` assignments in `items`. And a mark that there is more. + + Example: + Search for `SKIPPED` or `EXPIRED` assignments in the specified pool. + + >>> toloka_client.find_assignments(pool_id='1', status = ['SKIPPED', 'EXPIRED']) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1524,7 +1890,15 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - search_results.AssignmentSearchResult: The first "limit" assignments in "items". And a mark that there is more. + search_results.AssignmentSearchResult: The first `limit` assignments in `items`. And a mark that there is more. + + Example: + Search for `SKIPPED` or `EXPIRED` assignments in the specified pool. + + >>> toloka_client.find_assignments(pool_id='1', status = ['SKIPPED', 'EXPIRED']) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1563,7 +1937,15 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - search_results.AttachmentSearchResult: The first "limit" assignments in "items". And a mark that there is more. + search_results.AttachmentSearchResult: The first `limit` assignments in `items`. And a mark that there is more. + + Example: + Let's find attachments in the pool and sort them by id and date of creation. + + >>> toloka_client.find_attachments(pool_id='1', sort=['-created', '-id'], limit=10) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1588,7 +1970,15 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - search_results.AttachmentSearchResult: The first "limit" assignments in "items". And a mark that there is more. + search_results.AttachmentSearchResult: The first `limit` assignments in `items`. And a mark that there is more. + + Example: + Let's find attachments in the pool and sort them by id and date of creation. + + >>> toloka_client.find_attachments(pool_id='1', sort=['-created', '-id'], limit=10) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1622,8 +2012,14 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - search_results.MessageThreadSearchResult: The first "limit" message threads in "items". + search_results.MessageThreadSearchResult: The first `limit` message threads in `items`. And a mark that there is more. + + Example: + Find all message threads in the Inbox folder. + + >>> toloka_client.find_message_threads(folder='INBOX') + ... """ ... @@ -1648,8 +2044,14 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - search_results.MessageThreadSearchResult: The first "limit" message threads in "items". + search_results.MessageThreadSearchResult: The first `limit` message threads in `items`. And a mark that there is more. + + Example: + Find all message threads in the Inbox folder. + + >>> toloka_client.find_message_threads(folder='INBOX') + ... """ ... @@ -1687,8 +2089,26 @@ class TolokaClient: Defaults to None, in which case it returns first 20 results. Returns: - search_results.PoolSearchResult: The first "limit" pools in "items". + search_results.PoolSearchResult: The first `limit` pools in `items`. And a mark that there is more. + + Examples: + Find all pools in all projects. + + >>> toloka_client.find_pools() + ... + + Find all open pools in all projects. + + >>> toloka_client.find_pools(status='OPEN') + ... + + Find open pools in a specific project. + + >>> toloka_client.find_pools(status='OPEN', project_id='1') + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1713,8 +2133,26 @@ class TolokaClient: Defaults to None, in which case it returns first 20 results. Returns: - search_results.PoolSearchResult: The first "limit" pools in "items". + search_results.PoolSearchResult: The first `limit` pools in `items`. And a mark that there is more. + + Examples: + Find all pools in all projects. + + >>> toloka_client.find_pools() + ... + + Find all open pools in all projects. + + >>> toloka_client.find_pools(status='OPEN') + ... + + Find open pools in a specific project. + + >>> toloka_client.find_pools(status='OPEN', project_id='1') + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1747,8 +2185,16 @@ class TolokaClient: Defaults to None, in which case it returns first 20 results. Returns: - search_results.ProjectSearchResult: The first "limit" projects in "items". + search_results.ProjectSearchResult: The first `limit` projects in `items`. And a mark that there is more. + + Example: + Find projects that were created before a specific date. + + >>> toloka_client.find_projects(created_lt='2021-06-01T00:00:00') + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1773,8 +2219,16 @@ class TolokaClient: Defaults to None, in which case it returns first 20 results. Returns: - search_results.ProjectSearchResult: The first "limit" projects in "items". + search_results.ProjectSearchResult: The first `limit` projects in `items`. And a mark that there is more. + + Example: + Find projects that were created before a specific date. + + >>> toloka_client.find_projects(created_lt='2021-06-01T00:00:00') + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1806,8 +2260,16 @@ class TolokaClient: limit: Limit on the number of results returned. Returns: - SkillSearchResult: The first "limit" skills in "items". + SkillSearchResult: The first `limit` skills in `items`. And a mark that there is more. + + Example: + Find ten most recently created skills. + + >>> toloka_client.find_skills(sort=['-created', '-id'], limit=10) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1831,8 +2293,16 @@ class TolokaClient: limit: Limit on the number of results returned. Returns: - SkillSearchResult: The first "limit" skills in "items". + SkillSearchResult: The first `limit` skills in `items`. And a mark that there is more. + + Example: + Find ten most recently created skills. + + >>> toloka_client.find_skills(sort=['-created', '-id'], limit=10) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1871,7 +2341,15 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - TaskSuiteSearchResult: The first "limit" task suites in "items". And a mark that there is more. + TaskSuiteSearchResult: The first `limit` task suites in `items`. And a mark that there is more. + + Example: + Find three most recently created task suites in a specified pool. + + >>> toloka_client.find_task_suites(pool_id='1', sort=['-created', '-id'], limit=3) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1896,7 +2374,15 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - TaskSuiteSearchResult: The first "limit" task suites in "items". And a mark that there is more. + TaskSuiteSearchResult: The first `limit` task suites in `items`. And a mark that there is more. + + Example: + Find three most recently created task suites in a specified pool. + + >>> toloka_client.find_task_suites(pool_id='1', sort=['-created', '-id'], limit=3) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1934,7 +2420,15 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - TaskSearchResult: The first "limit" tasks in "items". And a mark that there is more. + TaskSearchResult: The first `limit` tasks in `items`. And a mark that there is more. + + Example: + Find three most recently created tasks in a specified pool. + + >>> toloka_client.find_tasks(pool_id='1', sort=['-created', '-id'], limit=3) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1959,7 +2453,15 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - TaskSearchResult: The first "limit" tasks in "items". And a mark that there is more. + TaskSearchResult: The first `limit` tasks in `items`. And a mark that there is more. + + Example: + Find three most recently created tasks in a specified pool. + + >>> toloka_client.find_tasks(pool_id='1', sort=['-created', '-id'], limit=3) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -1996,8 +2498,26 @@ class TolokaClient: limit: Limit on the number of results returned. Returns: - search_results.PoolSearchResult: The first "limit" trainings in "items". + search_results.TrainingSearchResult: The first `limit` trainings in `items`. And a mark that there is more. + + Examples: + Find all trainings in all projects. + + >>> toloka_client.find_trainings() + ... + + Find all open trainings in all projects. + + >>> toloka_client.find_trainings(status='OPEN') + ... + + Find all open trainings in a specific project. + + >>> toloka_client.find_trainings(status='OPEN', project_id='1') + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -2021,8 +2541,26 @@ class TolokaClient: limit: Limit on the number of results returned. Returns: - search_results.PoolSearchResult: The first "limit" trainings in "items". + search_results.TrainingSearchResult: The first `limit` trainings in `items`. And a mark that there is more. + + Examples: + Find all trainings in all projects. + + >>> toloka_client.find_trainings() + ... + + Find all open trainings in all projects. + + >>> toloka_client.find_trainings(status='OPEN') + ... + + Find all open trainings in a specific project. + + >>> toloka_client.find_trainings(status='OPEN', project_id='1') + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -2030,6 +2568,7 @@ class TolokaClient: def find_user_bonuses( self, user_id: Optional[str] = None, + assignment_id: Optional[str] = None, private_comment: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, @@ -2055,8 +2594,14 @@ class TolokaClient: limit: Limit on the number of results returned. Returns: - UserBonusSearchResult: The first "limit" user bonuses in "items". + UserBonusSearchResult: The first `limit` user bonuses in `items`. And a mark that there is more. + + Example: + >>> toloka_client.find_user_bonuses(user_id='1', sort=['-created', '-id'], limit=3) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -2080,8 +2625,14 @@ class TolokaClient: limit: Limit on the number of results returned. Returns: - UserBonusSearchResult: The first "limit" user bonuses in "items". + UserBonusSearchResult: The first `limit` user bonuses in `items`. And a mark that there is more. + + Example: + >>> toloka_client.find_user_bonuses(user_id='1', sort=['-created', '-id'], limit=3) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -2116,8 +2667,14 @@ class TolokaClient: limit: Limit on the number of results returned. Returns: - UserRestrictionSearchResult: The first "limit" user restrictions in "items". + UserRestrictionSearchResult: The first `limit` user restrictions in `items`. And a mark that there is more. + + Example: + >>> toloka_client.find_user_restrictions(sort=['-created', '-id'], limit=10) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -2141,8 +2698,14 @@ class TolokaClient: limit: Limit on the number of results returned. Returns: - UserRestrictionSearchResult: The first "limit" user restrictions in "items". + UserRestrictionSearchResult: The first `limit` user restrictions in `items`. And a mark that there is more. + + Example: + >>> toloka_client.find_user_restrictions(sort=['-created', '-id'], limit=10) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -2181,8 +2744,14 @@ class TolokaClient: limit: Limit on the number of results returned. Returns: - UserSkillSearchResult: The first "limit" user skills in "items". + UserSkillSearchResult: The first `limit` user skills in `items`. And a mark that there is more. + + Example: + >>> toloka_client.find_user_skills(limit=10) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -2207,8 +2776,14 @@ class TolokaClient: limit: Limit on the number of results returned. Returns: - UserSkillSearchResult: The first "limit" user skills in "items". + UserSkillSearchResult: The first `limit` user skills in `items`. And a mark that there is more. + + Example: + >>> toloka_client.find_user_skills(limit=10) + ... + + If method finds more objects than custom or system `limit` allows to operate, it will also show an indicator `has_more=True`. """ ... @@ -2242,7 +2817,7 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - WebhookSubscriptionSearchResult: The first "limit" webhook-subscriptions in "items". + WebhookSubscriptionSearchResult: The first `limit` webhook-subscriptions in `items`. And a mark that there is more. """ ... @@ -2268,7 +2843,7 @@ class TolokaClient: Defaults to None, in which case it returns first 50 results. Returns: - WebhookSubscriptionSearchResult: The first "limit" webhook-subscriptions in "items". + WebhookSubscriptionSearchResult: The first `limit` webhook-subscriptions in `items`. And a mark that there is more. """ ... @@ -2284,7 +2859,7 @@ class TolokaClient: ) -> Generator[AggregatedSolution, None, None]: """Finds all aggregated responses after the AggregatedSolutionOperation completes - Note: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation + **Note**: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation methods and can perform on your computers: https://github.com/Toloka/crowd-kit Args: @@ -2299,7 +2874,6 @@ class TolokaClient: >>> # run toloka_client.aggregate_solutions_by_pool and wait operation for closing. >>> aggregation_results = list(toloka_client.get_aggregated_solutions(aggregation_operation.id)) - >>> print(len(aggregation_results)) ... """ ... @@ -2312,7 +2886,7 @@ class TolokaClient: ) -> Generator[AggregatedSolution, None, None]: """Finds all aggregated responses after the AggregatedSolutionOperation completes - Note: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation + **Note**: In all aggregation purposes we are strongly recommending using our crowd-kit library, that have more aggregation methods and can perform on your computers: https://github.com/Toloka/crowd-kit Args: @@ -2327,7 +2901,6 @@ class TolokaClient: >>> # run toloka_client.aggregate_solutions_by_pool and wait operation for closing. >>> aggregation_results = list(toloka_client.get_aggregated_solutions(aggregation_operation.id)) - >>> print(len(aggregation_results)) ... """ ... @@ -2365,6 +2938,10 @@ class TolokaClient: Returns: Assignment: The solution read as a result. + + Example: + >>> toloka_client.get_assignment(assignment_id='1') + ... """ ... @@ -2401,10 +2978,11 @@ class TolokaClient: Assignment: The next object corresponding to the request parameters. Example: - How to process all accepted assignmens. + Let’s make a list of `assignment_id` of all `SUBMITTED` assignments in the specified pool. - >>> for assignment in toloka_client.get_assignments(pool_id=some_pool_id, status=['ACCEPTED', 'SUBMITTED']): - >>> # somehow process "assignment" + >>> from toloka.client import Assignment + >>> assignments = toloka_client.get_assignments(pool_id='1', status=Assignment.SUBMITTED) + >>> result_list = [assignment.id for assignment in assignments] ... """ ... @@ -2423,10 +3001,11 @@ class TolokaClient: Assignment: The next object corresponding to the request parameters. Example: - How to process all accepted assignmens. + Let’s make a list of `assignment_id` of all `SUBMITTED` assignments in the specified pool. - >>> for assignment in toloka_client.get_assignments(pool_id=some_pool_id, status=['ACCEPTED', 'SUBMITTED']): - >>> # somehow process "assignment" + >>> from toloka.client import Assignment + >>> assignments = toloka_client.get_assignments(pool_id='1', status=Assignment.SUBMITTED) + >>> result_list = [assignment.id for assignment in assignments] ... """ ... @@ -2459,6 +3038,18 @@ class TolokaClient: * "HINT" - Hints for completing tasks. Filled in for training tasks. * "ACCEPT" - Fields describing the deferred acceptance of tasks. * "ASSIGNMENT" - fields describing additional information about the Assignment. + + Example: + Get all assignments from the specified pool by `pool_id` to [pandas.DataFrame](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html). + And apply the native pandas `rename` method to change columns' names. + + >>> answers_df = toloka_client.get_assignments_df(pool_id='1') + >>> answers_df = answers_df.rename(columns={ + >>> 'INPUT:image': 'task', + >>> 'OUTPUT:result': 'label', + >>> 'ASSIGNMENT:worker_id': 'performer' + >>> }) + ... """ ... @@ -2485,6 +3076,18 @@ class TolokaClient: * "HINT" - Hints for completing tasks. Filled in for training tasks. * "ACCEPT" - Fields describing the deferred acceptance of tasks. * "ASSIGNMENT" - fields describing additional information about the Assignment. + + Example: + Get all assignments from the specified pool by `pool_id` to [pandas.DataFrame](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html). + And apply the native pandas `rename` method to change columns' names. + + >>> answers_df = toloka_client.get_assignments_df(pool_id='1') + >>> answers_df = answers_df.rename(columns={ + >>> 'INPUT:image': 'task', + >>> 'OUTPUT:result': 'label', + >>> 'ASSIGNMENT:worker_id': 'performer' + >>> }) + ... """ ... @@ -2498,6 +3101,12 @@ class TolokaClient: Returns: Attachment: The attachment metadata read as a result. + + Example: + Specify an `attachment_id` to get the information about any attachment object. + + >>> toloka_client.get_attachment(attachment_id='1') + ... """ ... @@ -2530,6 +3139,12 @@ class TolokaClient: Yields: Attachment: The next object corresponding to the request parameters. + + Example: + Make a list of all received attachments in the specified pool. + + >>> results_list = [attachment for attachment in toloka_client.get_attachments(pool_id='1')] + ... """ ... @@ -2545,6 +3160,12 @@ class TolokaClient: Yields: Attachment: The next object corresponding to the request parameters. + + Example: + Make a list of all received attachments in the specified pool. + + >>> results_list = [attachment for attachment in toloka_client.get_attachments(pool_id='1')] + ... """ ... @@ -2613,6 +3234,10 @@ class TolokaClient: Returns: Operation: The operation. + + Example: + >>> op = toloka_client.get_operation(operation_id='1') + ... """ ... @@ -2628,6 +3253,10 @@ class TolokaClient: Returns: List[OperationLogItem]: Logs for the operation. + + Example: + >>> op = toloka_client.get_operation_log(operation_id='1') + ... """ ... @@ -2639,6 +3268,10 @@ class TolokaClient: Returns: Pool: The pool. + + Example: + >>> toloka_client.get_pool(pool_id='1') + ... """ ... @@ -2674,12 +3307,12 @@ class TolokaClient: Example: How to get all open pools from project. - >>> open_pools = toloka_client.get_pools(project_id=my_project_id, status='OPEN') + >>> open_pools = toloka_client.get_pools(project_id='1', status='OPEN') ... How to get all pools from project. - >>> all_pools = toloka_client.get_pools(project_id=my_project_id) + >>> all_pools = toloka_client.get_pools(project_id='1') ... """ ... @@ -2700,12 +3333,12 @@ class TolokaClient: Example: How to get all open pools from project. - >>> open_pools = toloka_client.get_pools(project_id=my_project_id, status='OPEN') + >>> open_pools = toloka_client.get_pools(project_id='1', status='OPEN') ... How to get all pools from project. - >>> all_pools = toloka_client.get_pools(project_id=my_project_id) + >>> all_pools = toloka_client.get_pools(project_id='1') ... """ ... @@ -2718,6 +3351,10 @@ class TolokaClient: Returns: Project: The project. + + Example: + >>> toloka_client.get_project(project_id='1') + ... """ ... @@ -2746,12 +3383,12 @@ class TolokaClient: Project: The next object corresponding to the request parameters. Example: - How to get all active projects. + Get all active projects. - >>> active_projects = toloka_client.get_projects(status='ACTIVE'): + >>> active_projects = toloka_client.get_projects(status='ACTIVE') ... - How to get all your projects. + Get all your projects. >>> my_projects = toloka_client.get_projects() ... @@ -2772,12 +3409,12 @@ class TolokaClient: Project: The next object corresponding to the request parameters. Example: - How to get all active projects. + Get all active projects. - >>> active_projects = toloka_client.get_projects(status='ACTIVE'): + >>> active_projects = toloka_client.get_projects(status='ACTIVE') ... - How to get all your projects. + Get all your projects. >>> my_projects = toloka_client.get_projects() ... @@ -2789,6 +3426,21 @@ class TolokaClient: Returns: Requester: Object that contains all information about customer. + + Examples: + Make sure that you've entered a valid OAuth token. + + >>> toloka_client.get_requester() + ... + + You can also estimate approximate pipeline costs and check if there is enough money on your account. + + >>> requester = toloka_client.get_requester() + >>> if requester.balance >= approx_pipeline_price: + >>> print('You have enough money on your account!') + >>> else: + >>> print('You haven't got enough money on your account!') + ... """ ... @@ -2800,6 +3452,10 @@ class TolokaClient: Returns: Skill: The skill. + + Example: + >>> toloka_client.get_skill(skill_id='1') + ... """ ... @@ -2872,6 +3528,10 @@ class TolokaClient: Returns: Task: The task. + + Example: + >>> toloka_client.get_task(task_id='1') + ... """ ... @@ -2883,6 +3543,10 @@ class TolokaClient: Returns: TaskSuite: The task suite. + + Example: + >>> toloka_client.get_task_suite(task_suite_id='1') + ... """ ... @@ -2915,6 +3579,12 @@ class TolokaClient: Yields: TaskSuite: The next object corresponding to the request parameters. + + Example: + Get task suites from a specific pool. + + >>> results_list = [task_suite for task_suite in toloka_client.get_task_suites(pool_id='1')] + ... """ ... @@ -2930,6 +3600,12 @@ class TolokaClient: Yields: TaskSuite: The next object corresponding to the request parameters. + + Example: + Get task suites from a specific pool. + + >>> results_list = [task_suite for task_suite in toloka_client.get_task_suites(pool_id='1')] + ... """ ... @@ -2961,6 +3637,12 @@ class TolokaClient: Yields: Task: The next object corresponding to the request parameters. + + Example: + Get tasks from a specific pool. + + >>> results_list = [task for task in toloka_client.get_tasks(pool_id='1')] + ... """ ... @@ -2976,6 +3658,12 @@ class TolokaClient: Yields: Task: The next object corresponding to the request parameters. + + Example: + Get tasks from a specific pool. + + >>> results_list = [task for task in toloka_client.get_tasks(pool_id='1')] + ... """ ... @@ -2987,6 +3675,10 @@ class TolokaClient: Returns: Training: The training. + + Example: + >>> toloka_client.get_training(training_id='1') + ... """ ... @@ -3056,6 +3748,10 @@ class TolokaClient: Returns: UserBonus: The user bonus. + + Example: + >>> toloka_client.get_user_bonus(user_bonus_id='1') + ... """ ... @@ -3063,6 +3759,7 @@ class TolokaClient: def get_user_bonuses( self, user_id: Optional[str] = None, + assignment_id: Optional[str] = None, private_comment: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, @@ -3083,6 +3780,10 @@ class TolokaClient: Yields: UserBonus: The next object corresponding to the request parameters. + + Example: + >>> bonuses = [bonus for bonus in toloka_client.get_user_bonuses(created_lt='2021-06-01T00:00:00')] + ... """ ... @@ -3098,6 +3799,10 @@ class TolokaClient: Yields: UserBonus: The next object corresponding to the request parameters. + + Example: + >>> bonuses = [bonus for bonus in toloka_client.get_user_bonuses(created_lt='2021-06-01T00:00:00')] + ... """ ... @@ -3109,6 +3814,10 @@ class TolokaClient: Returns: UserRestriction: The user restriction. + + Example: + >>> toloka_client.get_user_restriction(user_restriction_id='1') + ... """ ... @@ -3138,6 +3847,10 @@ class TolokaClient: Yields: UserRestriction: The next object corresponding to the request parameters. + + Example: + >>> results_list = [restriction for restriction in toloka_client.get_user_restrictions(scope='ALL_PROJECTS')] + ... """ ... @@ -3153,6 +3866,10 @@ class TolokaClient: Yields: UserRestriction: The next object corresponding to the request parameters. + + Example: + >>> results_list = [restriction for restriction in toloka_client.get_user_restrictions(scope='ALL_PROJECTS')] + ... """ ... @@ -3166,6 +3883,10 @@ class TolokaClient: Returns: UserSkill: The skill value. + + Example: + >>> toloka_client.get_user_skill(user_skill_id='1') + ... """ ... @@ -3199,6 +3920,10 @@ class TolokaClient: Yields: UserSkill: The next object corresponding to the request parameters. + + Example: + >>> results_list = [skill for skill in toloka_client.get_user_skills()] + ... """ ... @@ -3215,6 +3940,10 @@ class TolokaClient: Yields: UserSkill: The next object corresponding to the request parameters. + + Example: + >>> results_list = [skill for skill in toloka_client.get_user_skills()] + ... """ ... @@ -3281,6 +4010,12 @@ class TolokaClient: Returns: Pool: Pool object with new status. + + Example: + Open the pool for performers. + + >>> toloka_client.open_pool(pool_id='1') + ... """ ... @@ -3294,6 +4029,13 @@ class TolokaClient: Returns: PoolOpenOperation: An operation upon completion of which you can get the pool with new status. + + Example: + Open the pool for performers. + + >>> open_pool = toloka_client.open_pool(pool_id='1') + >>> toloka_client.wait_operation(open_pool) + ... """ ... @@ -3305,6 +4047,12 @@ class TolokaClient: Returns: Training: Training object with new status. + + Example: + Open the training for performers. + + >>> toloka_client.open_training(training_id='1') + ... """ ... @@ -3316,6 +4064,13 @@ class TolokaClient: Returns: TrainingOpenOperation: An operation upon completion of which you can get the training with new status. + + Example: + Open the training for performers. + + >>> open_training = toloka_client.open_training_async(training_id='1') + >>> toloka_client.wait_operation(open_training) + ... """ ... @@ -3337,6 +4092,10 @@ class TolokaClient: Returns: Assignment: Object with new status. + + Example: + >>> toloka_client.patch_assignment(assignment_id='1', public_comment='Some issues present, but work is acceptable', status='ACCEPTED') + ... """ ... @@ -3356,6 +4115,10 @@ class TolokaClient: Returns: Assignment: Object with new status. + + Example: + >>> toloka_client.patch_assignment(assignment_id='1', public_comment='Some issues present, but work is acceptable', status='ACCEPTED') + ... """ ... @@ -3375,11 +4138,9 @@ class TolokaClient: Pool: Object with updated priority. Example: - How to set highest priority to some pool. + Set the highest priority to a specified pool. - >>> toloka_client = toloka.TolokaClient(your_token, 'PRODUCTION') - >>> patched_pool = toloka_client.patch_pool(existing_pool_id, 100) - >>> print(patched_pool.priority) + >>> toloka_client.patch_pool(pool_id='1', priority=100) ... """ ... @@ -3400,11 +4161,9 @@ class TolokaClient: Pool: Object with updated priority. Example: - How to set highest priority to some pool. + Set the highest priority to a specified pool. - >>> toloka_client = toloka.TolokaClient(your_token, 'PRODUCTION') - >>> patched_pool = toloka_client.patch_pool(existing_pool_id, 100) - >>> print(patched_pool.priority) + >>> toloka_client.patch_pool(pool_id='1', priority=100) ... """ ... @@ -3462,6 +4221,14 @@ class TolokaClient: Returns: Task: Task with updated fields. + + Example: + Set an infinite overlap for a specific task in training. + + >>> toloka_client.patch_task_overlap_or_min(task_id='1', infinite_overlap=True) + ... + + **Note**: you can't set infinite overlap in a regular pool. """ ... @@ -3479,6 +4246,14 @@ class TolokaClient: Returns: Task: Task with updated fields. + + Example: + Set an infinite overlap for a specific task in training. + + >>> toloka_client.patch_task_overlap_or_min(task_id='1', infinite_overlap=True) + ... + + **Note**: you can't set infinite overlap in a regular pool. """ ... @@ -3500,6 +4275,12 @@ class TolokaClient: Returns: TaskSuite: Task suite with updated fields. + + Example: + Change the task suite's priority. + + >>> toloka_client.patch_task_suite(task_suite_id='1', issuing_order_override=100) + ... """ ... @@ -3517,6 +4298,12 @@ class TolokaClient: Returns: TaskSuite: Task suite with updated fields. + + Example: + Change the task suite's priority. + + >>> toloka_client.patch_task_suite(task_suite_id='1', issuing_order_override=100) + ... """ ... @@ -3535,6 +4322,10 @@ class TolokaClient: Returns: TaskSuite: Task suite with updated fields. + + Example: + >>> toloka_client.patch_task_suite_overlap_or_min(task_suite_id='1', overlap=100) + ... """ ... @@ -3552,6 +4343,10 @@ class TolokaClient: Returns: TaskSuite: Task suite with updated fields. + + Example: + >>> toloka_client.patch_task_suite_overlap_or_min(task_suite_id='1', overlap=100) + ... """ ... @@ -3572,9 +4367,10 @@ class TolokaClient: Assignment: Object with new status. Example: - How to reject one assignment. + Reject an assignment that was completed too fast. - >>> toloka_client.reject_assignment(assignment_id, "Bad work.") + >>> toloka_client.reject_assignment(assignment_id='1', 'Assignment was completed too fast.') + ... """ ... @@ -3591,6 +4387,10 @@ class TolokaClient: Returns: MessageThread: Full object by ID with updated folders. + + Example: + >>> toloka_client.remove_message_thread_from_folders(message_thread_id='1', folders=['IMPORTANT']) + ... """ ... @@ -3607,6 +4407,13 @@ class TolokaClient: Returns: MessageThread: New created message. + + Example: + >>> message_threads = toloka_client.get_message_threads(folder='UNREAD') + >>> message_reply = {'EN': 'Thank you for your message! I will get back to you soon.'} + >>> for thread in message_threads: + >>> toloka_client.reply_message_thread(message_thread_id=thread.id, reply=toloka.message_thread.MessageThreadReply(text=message_reply)) + ... """ ... @@ -3618,6 +4425,18 @@ class TolokaClient: Returns: UserRestriction: Created restriction object. + + Example: + If performer often makes mistakes, we will restrict access to all our projects. + + >>> new_restriction = toloka_client.set_user_restriction( + >>> toloka.user_restriction.ProjectUserRestriction( + >>> user_id='1', + >>> private_comment='Performer often makes mistakes', + >>> project_id='5' + >>> ) + >>> ) + ... """ ... @@ -3636,6 +4455,11 @@ class TolokaClient: Returns: UserSkill: Сreated fact of skill installation. + + Example: + >>> from decimal import * + >>> toloka_client.set_user_skill(skill_id='1', user_id='1', value=Decimal(100)) + ... """ ... @@ -3648,6 +4472,11 @@ class TolokaClient: Returns: UserSkill: Сreated fact of skill installation. + + Example: + >>> from decimal import * + >>> toloka_client.set_user_skill(skill_id='1', user_id='1', value=Decimal(100)) + ... """ ... @@ -3664,6 +4493,10 @@ class TolokaClient: Returns: Pool: Pool object with all fields. + + Example: + >>> updated_pool = toloka_client.update_pool(pool_id=old_pool_id, pool=new_pool_object) + ... """ ... @@ -3680,6 +4513,10 @@ class TolokaClient: Returns: Project: Project object with all fields. + + Example: + >>> updated_project = toloka_client.update_project(project_id=old_project.id, project=new_project_object) + ... """ ... @@ -3696,6 +4533,10 @@ class TolokaClient: Returns: Skill: Modified skill object with all fields. + + Example: + >>> toloka_client.create_skill(skill_id=old_skill_id, skill=new_skill_object) + ... """ ... @@ -3712,6 +4553,12 @@ class TolokaClient: Returns: Training: Training object with all fields. + + Example: + If you want to update any configurations of the existing training. + + >>> updated_training = toloka_client.update_training(training_id=old_training_id, training=new_training_object) + ... """ ... @@ -3723,7 +4570,7 @@ class TolokaClient: Returns: batch_create_results.WebhookSubscriptionBatchCreateResult: Result of subscriptions creation. - Contains created subscriptions in "items" and problems in "validation_errors". + Contains created subscriptions in `items` and problems in "validation_errors". Raises: ValidationApiError: If no subscriptions were created. @@ -3744,7 +4591,7 @@ class TolokaClient: >>> } >>> ]) >>> print(len(created_result.items)) - 2 + ... """ ... @@ -3764,5 +4611,22 @@ class TolokaClient: Returns: Operation: Completed operation. + + Example: + Waiting for the pool to close can be running in the background. + + >>> pool = toloka_client.get_pool(pool_id) + >>> while not pool.is_closed(): + >>> op = toloka_client.get_analytics([toloka.analytics_request.CompletionPercentagePoolAnalytics(subject_id=pool.id)]) + >>> op = toloka_client.wait_operation(op) + >>> percentage = op.details['value'][0]['result']['value'] + >>> print( + >>> f' {datetime.datetime.now().strftime("%H:%M:%S")} ' + >>> f'Pool {pool.id} - {percentage}%' + >>> ) + >>> time.sleep(60 * minutes_to_wait) + >>> pool = toloka_client.get_pool(pool.id) + >>> print('Pool was closed.') + ... """ ... diff --git a/src/client/batch_create_results.py b/src/client/batch_create_results.py index bfd005e8..7669dafd 100644 --- a/src/client/batch_create_results.py +++ b/src/client/batch_create_results.py @@ -2,7 +2,8 @@ 'FieldValidationError', 'TaskBatchCreateResult', 'TaskSuiteBatchCreateResult', - 'UserBonusBatchCreateResult' + 'UserBonusBatchCreateResult', + 'WebhookSubscriptionBatchCreateResult' ] from typing import Any, Dict, List, Optional, Type diff --git a/src/client/collectors.pyi b/src/client/collectors.pyi index c34fdee8..da4833b9 100644 --- a/src/client/collectors.pyi +++ b/src/client/collectors.pyi @@ -67,16 +67,16 @@ class AcceptanceRate(CollectorConfig): - Block access for performers who give incorrect responses. Used with conditions: - * TotalAssignmentsCount - How many assignments from this performer were checked. - * AcceptedAssignmentsRate - Percentage of how many assignments were accepted from this performer out of all checked assignment. - * RejectedAssignmentsRate - Percentage of how many assignments were rejected from this performer out of all checked assignment. + * TotalAssignmentsCount - How many assignments from this performer were checked. + * AcceptedAssignmentsRate - Percentage of how many assignments were accepted from this performer out of all checked assignment. + * RejectedAssignmentsRate - Percentage of how many assignments were rejected from this performer out of all checked assignment. Used with actions: - * RestrictionV2 - Block access to projects or pools. - * ApproveAllAssignments - Approve all replies from the performer. - * RejectAllAssignments - Reject all replies from the performer. - * SetSkill - Set perfmer skill value. - * SetSkillFromOutputField - Set performer skill value from source. + * RestrictionV2 - Block access to projects or pools. + * ApproveAllAssignments - Approve all replies from the performer. + * RejectAllAssignments - Reject all replies from the performer. + * SetSkill - Set perfmer skill value. + * SetSkillFromOutputField - Set performer skill value from source. Example: How to ban a performer in this project if he makes mistakes. @@ -129,13 +129,13 @@ class AnswerCount(CollectorConfig): - Mark performers completing a task so that you can filter them later in the checking project. Used with conditions: - * AssignmentsAcceptedCount - How many assignment was accepted from performer + * AssignmentsAcceptedCount - How many assignment was accepted from performer Used with actions: - * RestrictionV2 - Block access to projects or pools. - * ApproveAllAssignments - Approve all replies from the performer. - * RejectAllAssignments - Reject all replies from the performer. - * SetSkill - Set perfmer skill value. + * RestrictionV2 - Block access to projects or pools. + * ApproveAllAssignments - Approve all replies from the performer. + * RejectAllAssignments - Reject all replies from the performer. + * SetSkill - Set perfmer skill value. Example: How to mark performers completing a task so that you can filter them later in the checking project. @@ -183,13 +183,13 @@ class AssignmentsAssessment(CollectorConfig): accepted assignments only. Used with conditions: - * PendingAssignmentsCount - Number of Assignments pending checking. - * AcceptedAssignmentsCount - How many times this assignment was accepted. - * RejectedAssignmentsCount - How many times this assignment was rejected. - * AssessmentEvent - Assessment of the assignment changes its status to the specified one. + * PendingAssignmentsCount - Number of Assignments pending checking. + * AcceptedAssignmentsCount - How many times this assignment was accepted. + * RejectedAssignmentsCount - How many times this assignment was rejected. + * AssessmentEvent - Assessment of the assignment changes its status to the specified one. Used with actions: - * ChangeOverlap - Increase the overlap of the set of tasks. + * ChangeOverlap - Increase the overlap of the set of tasks. Example: How to resend rejected assignments for re-completion to other performers. @@ -233,14 +233,14 @@ class AssignmentSubmitTime(CollectorConfig): - Provide protection from robots. Used with conditions: - * TotalSubmittedCount - The number of assignments a specific performer completed. - * FastSubmittedCount - The number of assignments a specific performer completed too fast. + * TotalSubmittedCount - The number of assignments a specific performer completed. + * FastSubmittedCount - The number of assignments a specific performer completed too fast. Used with actions: - * RestrictionV2 - Block access to projects or pools. - * ApproveAllAssignments - Approve all replies from the performer. - * RejectAllAssignments - Reject all replies from the performer. - * SetSkill - Set perfmer skill value. + * RestrictionV2 - Block access to projects or pools. + * ApproveAllAssignments - Approve all replies from the performer. + * RejectAllAssignments - Reject all replies from the performer. + * SetSkill - Set perfmer skill value. Attributes: parameters.fast_submit_threshold_seconds: The task suite completion time (in seconds). @@ -306,16 +306,16 @@ class Captcha(CollectorConfig): """Captchas provide a high level of protection from robots Used with conditions: - * StoredResultsCount - How many times the performer entered captcha. - * SuccessRate - Percentage of correct answers of the performer to the captcha. - * FailRate - Percentage of wrong answers of the performer to the captcha. + * StoredResultsCount - How many times the performer entered captcha. + * SuccessRate - Percentage of correct answers of the performer to the captcha. + * FailRate - Percentage of wrong answers of the performer to the captcha. Used with actions: - * RestrictionV2 - Block access to projects or pools. - * ApproveAllAssignments - Approve all replies from the performer. - * RejectAllAssignments - Reject all replies from the performer. - * SetSkill - Set perfmer skill value. - * SetSkillFromOutputField - Set performer skill value from source. + * RestrictionV2 - Block access to projects or pools. + * ApproveAllAssignments - Approve all replies from the performer. + * RejectAllAssignments - Reject all replies from the performer. + * SetSkill - Set perfmer skill value. + * SetSkillFromOutputField - Set performer skill value from source. Attributes: parameters.history_size: The number of times the performer was shown a captcha recently. @@ -390,19 +390,19 @@ class GoldenSet(CollectorConfig): "Choose the page design option that you like best". Used with conditions: - * TotalAnswersCount - The number of completed control and training tasks. - * CorrectAnswersRate - The percentage of correct responses in training and control tasks. - * IncorrectAnswersRate - The percentage of incorrect responses in training and control tasks. - * GoldenSetAnswersCount - The number of completed control tasks - * GoldenSetCorrectAnswersRate - The percentage of correct responses in control tasks. - * GoldenSetIncorrectAnswersRate - The percentage of incorrect responses in control tasks. + * TotalAnswersCount - The number of completed control and training tasks. + * CorrectAnswersRate - The percentage of correct responses in training and control tasks. + * IncorrectAnswersRate - The percentage of incorrect responses in training and control tasks. + * GoldenSetAnswersCount - The number of completed control tasks + * GoldenSetCorrectAnswersRate - The percentage of correct responses in control tasks. + * GoldenSetIncorrectAnswersRate - The percentage of incorrect responses in control tasks. Used with actions: - * RestrictionV2 - Block access to projects or pools. - * ApproveAllAssignments - Approve all replies from the performer. - * RejectAllAssignments - Reject all replies from the performer. - * SetSkill - Set perfmer skill value. - * SetSkillFromOutputField - Set performer skill value from source. + * RestrictionV2 - Block access to projects or pools. + * ApproveAllAssignments - Approve all replies from the performer. + * RejectAllAssignments - Reject all replies from the performer. + * SetSkill - Set perfmer skill value. + * SetSkillFromOutputField - Set performer skill value from source. Attributes: parameters.history_size: The number of the performer's last responses to control tasks. @@ -462,13 +462,13 @@ class Income(CollectorConfig): - Get responses from as many performers as possible. Used with conditions: - * IncomeSumForLast24Hours - The performer earnings for completed tasks in the pool over the last 24 hours. + * IncomeSumForLast24Hours - The performer earnings for completed tasks in the pool over the last 24 hours. Used with actions: - * RestrictionV2 - Block access to projects or pools. - * ApproveAllAssignments - Approve all replies from the performer. - * RejectAllAssignments - Reject all replies from the performer. - * SetSkill - Set perfmer skill value. + * RestrictionV2 - Block access to projects or pools. + * ApproveAllAssignments - Approve all replies from the performer. + * RejectAllAssignments - Reject all replies from the performer. + * SetSkill - Set perfmer skill value. Example: How to ban a performer in this project if he made enough answers. @@ -516,16 +516,16 @@ class MajorityVote(CollectorConfig): Depending on the percentage of correct responses, you can either increase the user's skill value, or ban the user from tasks. Used with conditions: - * TotalAnswersCount - The number of completed tasks by the performer. - * CorrectAnswersRate - The percentage of correct responses. - * IncorrectAnswersRate - The percentage of incorrect responses. + * TotalAnswersCount - The number of completed tasks by the performer. + * CorrectAnswersRate - The percentage of correct responses. + * IncorrectAnswersRate - The percentage of incorrect responses. Used with actions: - * RestrictionV2 - Block access to projects or pools. - * ApproveAllAssignments - Approve all replies from the performer. - * RejectAllAssignments - Reject all replies from the performer. - * SetSkill - Set perfmer skill value. - * SetSkillFromOutputField - Set performer skill value from source. + * RestrictionV2 - Block access to projects or pools. + * ApproveAllAssignments - Approve all replies from the performer. + * RejectAllAssignments - Reject all replies from the performer. + * SetSkill - Set perfmer skill value. + * SetSkillFromOutputField - Set performer skill value from source. Attributes: parameters.answer_threshold: The number of users considered the majority (for example, 3 out of 5). @@ -597,13 +597,13 @@ class SkippedInRowAssignments(CollectorConfig): You can block access to a pool or project if a user skips multiple task suites in a row. Used with conditions: - * SkippedInRowCount - How many tasks in a row the performer skipped. + * SkippedInRowCount - How many tasks in a row the performer skipped. Used with actions: - * RestrictionV2 - Block access to projects or pools. - * ApproveAllAssignments - Approve all replies from the performer. - * RejectAllAssignments - Reject all replies from the performer. - * SetSkill - Set perfmer skill value. + * RestrictionV2 - Block access to projects or pools. + * ApproveAllAssignments - Approve all replies from the performer. + * RejectAllAssignments - Reject all replies from the performer. + * SetSkill - Set perfmer skill value. Example: How to ban a performer in this project if he skipped tasks. @@ -674,11 +674,11 @@ class UsersAssessment(CollectorConfig): This rule will help you do this automatically. Used with conditions: - * PoolAccessRevokedReason - Reason for loss of access of the performer to the current pool. - * SkillId - The performer no longer meets the specific skill filter. + * PoolAccessRevokedReason - Reason for loss of access of the performer to the current pool. + * SkillId - The performer no longer meets the specific skill filter. Used with actions: - * ChangeOverlap - Increase the overlap of the set of tasks. + * ChangeOverlap - Increase the overlap of the set of tasks. Example: How to resend rejected assignments for re-completion to other performers. diff --git a/src/client/conditions.py b/src/client/conditions.py index c88dae25..6bef1743 100644 --- a/src/client/conditions.py +++ b/src/client/conditions.py @@ -105,6 +105,7 @@ class AssessmentEvent(IdentityRuleCondition, spec_value=RuleConditionKey.ASSESSM Attributes: value: Possible values: * conditions.AssessmentEvent.ACCEPT + * conditions.AssessmentEvent.ACCEPT_AFTER_REJECT * conditions.AssessmentEvent.REJECT Example: @@ -122,9 +123,11 @@ class AssessmentEvent(IdentityRuleCondition, spec_value=RuleConditionKey.ASSESSM @unique class Type(Enum): ACCEPT = 'ACCEPT' + ACCEPT_AFTER_REJECT = 'ACCEPT_AFTER_REJECT' REJECT = 'REJECT' ACCEPT = Type.ACCEPT + ACCEPT_AFTER_REJECT = Type.ACCEPT_AFTER_REJECT REJECT = Type.REJECT value: Type diff --git a/src/client/conditions.pyi b/src/client/conditions.pyi index 070e58da..28c149d5 100644 --- a/src/client/conditions.pyi +++ b/src/client/conditions.pyi @@ -140,6 +140,7 @@ class AssessmentEvent(IdentityRuleCondition): Attributes: value: Possible values: * conditions.AssessmentEvent.ACCEPT + * conditions.AssessmentEvent.ACCEPT_AFTER_REJECT * conditions.AssessmentEvent.REJECT Example: @@ -159,6 +160,7 @@ class AssessmentEvent(IdentityRuleCondition): """ ACCEPT = 'ACCEPT' + ACCEPT_AFTER_REJECT = 'ACCEPT_AFTER_REJECT' REJECT = 'REJECT' def __init__( diff --git a/src/client/primitives/base.pyi b/src/client/primitives/base.pyi index 2d86c715..c1ffe028 100644 --- a/src/client/primitives/base.pyi +++ b/src/client/primitives/base.pyi @@ -30,8 +30,19 @@ def attribute( *args, required=False, origin=None, + readonly=False, **kwargs -): ... +): + """Proxy for attr.attrib(...). Adds several keywords. + + Args: + *args: All positional arguments from attr.attrib + required: If True makes attribute not Optional. All other attributes are optional by default. Defaults to False. + origin: Sets field name in dict for attribute, when structuring/unstructuring from dict. Defaults to None. + readonly: Affects only when the class 'expanding' as a parameter in some function. If True, drops this attribute from expanded parameters. Defaults to None. + **kwargs: All keyword arguments from attr.attrib + """ + ... class BaseTolokaObjectMetaclass(type): diff --git a/src/client/search_requests.py b/src/client/search_requests.py index ced2506b..f7bf2cdd 100644 --- a/src/client/search_requests.py +++ b/src/client/search_requests.py @@ -31,7 +31,9 @@ 'UserBonusSearchRequest', 'UserBonusSortItems', 'MessageThreadSearchRequest', - 'MessageThreadSortItems' + 'MessageThreadSortItems', + 'WebhookSubscriptionSearchRequest', + 'WebhookSubscriptionSortItems' ] import datetime from enum import Enum, unique, auto @@ -762,6 +764,7 @@ class UserBonusSearchRequest(BaseSearchRequest): Attributes: user_id: Performer ID. + assignment_id: ID of the performer's response to the task. private_comment: Comments for the requester. id_lt: Bonuses with an ID less than the specified value. id_lte: Bonuses with an ID less than or equal to the specified value. @@ -778,6 +781,7 @@ class CompareFields: created: datetime.datetime user_id: str + assignment_id: str private_comment: str diff --git a/src/client/search_requests.pyi b/src/client/search_requests.pyi index 01af389b..12aafe5e 100644 --- a/src/client/search_requests.pyi +++ b/src/client/search_requests.pyi @@ -1298,6 +1298,7 @@ class UserBonusSearchRequest(BaseSearchRequest): Attributes: user_id: Performer ID. + assignment_id: ID of the performer's response to the task. private_comment: Comments for the requester. id_lt: Bonuses with an ID less than the specified value. id_lte: Bonuses with an ID less than or equal to the specified value. @@ -1316,6 +1317,7 @@ class UserBonusSearchRequest(BaseSearchRequest): def __init__( self, user_id: Optional[str] = None, + assignment_id: Optional[str] = None, private_comment: Optional[str] = None, id_lt: Optional[str] = None, id_lte: Optional[str] = None, @@ -1332,6 +1334,7 @@ class UserBonusSearchRequest(BaseSearchRequest): _unexpected: Optional[Dict[str, Any]] user_id: Optional[str] + assignment_id: Optional[str] private_comment: Optional[str] id_lt: Optional[str] id_lte: Optional[str] diff --git a/src/client/task_suite.pyi b/src/client/task_suite.pyi index 5e0d7111..f2d56b50 100644 --- a/src/client/task_suite.pyi +++ b/src/client/task_suite.pyi @@ -74,9 +74,7 @@ class TaskSuite(InfiniteOverlapParametersMixin, BaseTolokaObject): *, input_values: Optional[Dict[str, Any]] = None, known_solutions: Optional[List[BaseTask.KnownSolution]] = None, - message_on_unknown_solution: Optional[str] = None, - id: Optional[str] = None, - origin_task_id: Optional[str] = None + message_on_unknown_solution: Optional[str] = None ) -> 'TaskSuite': ... @overload From 96760e9daf236d28f659a33e987a3f0be30093c9 Mon Sep 17 00:00:00 2001 From: alexdrydew Date: Thu, 15 Jul 2021 17:54:53 +0300 Subject: [PATCH 7/8] PR from branch users/alexdrydew/add_kw_only_to_doc updated md added function signatures to doc **** ![review](https://codereview.in.yandex-team.ru/badges/review-complete-green.svg) [![losev](https://codereview.in.yandex-team.ru/badges/losev-...-yellow.svg)](https://staff.yandex-team.ru/losev) [![sinosov](https://codereview.in.yandex-team.ru/badges/sinosov-ok-green.svg)](https://staff.yandex-team.ru/sinosov) ref:1b6b2854b04ff69ca3dc56f719a3a4b0e228f60c --- src/client/actions.py | 2 +- src/client/primitives/base.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/actions.py b/src/client/actions.py index 5556c1d7..4b5f6d67 100644 --- a/src/client/actions.py +++ b/src/client/actions.py @@ -157,7 +157,7 @@ class Parameters(RuleAction.Parameters): class SetSkill(RuleAction, spec_value=RuleType.SET_SKILL): - """Set perfmer skill value + """Set performer skill value Attributes: parameters.skill_id: ID of the skill to update. diff --git a/src/client/primitives/base.py b/src/client/primitives/base.py index 183165f7..61d042eb 100644 --- a/src/client/primitives/base.py +++ b/src/client/primitives/base.py @@ -44,7 +44,7 @@ def __getitem__(self, value: E): return self.registered_classes[value] -def attribute(*args, required=False, origin=None, readonly=False, **kwargs): +def attribute(*args, required: bool = False, origin: Optional[str] = None, readonly: bool = False, **kwargs): """Proxy for attr.attrib(...). Adds several keywords. Args: From e3c3e32d96b2563b714c0175847e60ac89fe7467 Mon Sep 17 00:00:00 2001 From: Stepan Nosov Date: Thu, 15 Jul 2021 19:44:08 +0300 Subject: [PATCH 8/8] 0.1.10 release ![review](https://codereview.in.yandex-team.ru/badges/review-complete-green.svg) [![vlad--mois](https://codereview.in.yandex-team.ru/badges/vlad--mois-...-yellow.svg)](https://staff.yandex-team.ru/vlad-mois) [![losev](https://codereview.in.yandex-team.ru/badges/losev-ok-green.svg)](https://staff.yandex-team.ru/losev) ref:978bce068664e5e2616cb9bf482554edd1727256 --- CHANGELOG.md | 9 +++++++++ src/client/__version__.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00f713be..97e5188c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +0.1.10 +------------------- + +* `TemplateBuilder` components now support positional arguments +* Added `readonly` flag to attributes +* Added `ACCEPT_AFTER_REJECT` value to ` AssessmentEvent.Type` +* Added `assignment_id` attribute to `UserBonusSearchRequest` +* Improved stub files formatting + 0.1.9 ------------------- * Improved support by static analyzers diff --git a/src/client/__version__.py b/src/client/__version__.py index 290b4935..c98bedcd 100644 --- a/src/client/__version__.py +++ b/src/client/__version__.py @@ -1,3 +1,3 @@ __title__ = 'toloka-kit' -__version__ = '0.1.9' +__version__ = '0.1.10' __license__ = 'Apache 2.0'