Skip to content

Commit

Permalink
Merge pull request #12 from Toloka/autosync
Browse files Browse the repository at this point in the history
toloka-kit-0.1.5
  • Loading branch information
Losik authored Mar 22, 2021
2 parents b5c6459 + 0112b9d commit 0068a63
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.1.5
-------------------
Fixing issues with `create_tasks` and `create_task_suites`

0.1.4
-------------------
* Implemented a `clone_project` method
Expand Down
6 changes: 4 additions & 2 deletions src/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ def _synch_via_asynch(self, objects, parameters, url, result_type, operation_typ
# Emulates synchronous operation, through asynchronous calls and reading operation logs.
client_uuid_to_index = {}
for i, obj in enumerate(objects):
obj.__client_uuid = uuid.uuid4().hex
client_uuid_to_index[obj.__client_uuid] = str(i)
obj._unexpected['__client_uuid'] = uuid.uuid4().hex
client_uuid_to_index[obj._unexpected['__client_uuid']] = str(i)

response = self._request('post', url, json=unstructure(objects), params=unstructure(parameters))
insert_operation = structure(response, operation_type)
Expand All @@ -146,6 +146,8 @@ def _synch_via_asynch(self, objects, parameters, url, result_type, operation_typ
validation_errors = {}

for log_item in self.get_operation_log(insert_operation.id):
if log_item.type not in ['TASK_CREATE', 'TASK_VALIDATE', 'TASK_SUITE_VALIDATE', 'TASK_SUITE_CREATE']:
continue
index = client_uuid_to_index[log_item.input['__client_uuid']]
if log_item.success:
numerated_ids = pools.setdefault(log_item.input['pool_id'], {})
Expand Down
2 changes: 1 addition & 1 deletion src/client/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__title__ = 'toloka-kit'
__version__ = '0.1.4'
__version__ = '0.1.5'
__license__ = 'Apache 2.0'
3 changes: 2 additions & 1 deletion tests/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ def check_tasks(request, context):
} == parse_qs(urlparse(request.url).query)
imcoming_tasks = []
for t in request.json():
t.pop('__client_uuid', '')
assert '__client_uuid' in t
t.pop('__client_uuid')
imcoming_tasks.append(t)
assert tasks_map == imcoming_tasks
return operation_running_map
Expand Down
3 changes: 2 additions & 1 deletion tests/test_task_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ def check_task_suites(request, context):
} == parse_qs(urlparse(request.url).query)
imcoming_task_suites = []
for t in request.json():
t.pop('__client_uuid', '')
assert '__client_uuid' in t
t.pop('__client_uuid')
imcoming_task_suites.append(t)
assert task_suites_map == imcoming_task_suites
return operation_running_map
Expand Down

0 comments on commit 0068a63

Please sign in to comment.