Skip to content

Commit

Permalink
fix: do not assign results if Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
JoanFM committed Dec 14, 2023
1 parent 129b7b3 commit 94fff08
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions jina/serve/runtimes/worker/batch_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def batch(iterable_1, iterable_2, n=1):
non_assigned_to_response_docs: DocumentArray = DocumentArray.empty()
else:
non_assigned_to_response_docs = self._response_docarray_cls()

non_assigned_to_response_request_idxs = []
sum_from_previous_first_req_idx = 0
for docs_inner_batch, req_idxs in batch(
Expand Down Expand Up @@ -271,33 +272,25 @@ def batch(iterable_1, iterable_2, n=1):
involved_requests_min_indx : involved_requests_max_indx + 1
]:
await request_full.put(exc)
pass

# If there has been an exception, this will be docs_inner_batch
output_executor_docs = (
batch_res_docs
if batch_res_docs is not None
else docs_inner_batch
)

# We need to attribute the docs to their requests
non_assigned_to_response_docs.extend(output_executor_docs)
non_assigned_to_response_request_idxs.extend(req_idxs)
num_assigned_docs = await _assign_results(
non_assigned_to_response_docs,
non_assigned_to_response_request_idxs,
sum_from_previous_first_req_idx,
)
else:
# We need to attribute the docs to their requests
non_assigned_to_response_docs.extend(batch_res_docs)
non_assigned_to_response_request_idxs.extend(req_idxs)
num_assigned_docs = await _assign_results(

Check warning on line 279 in jina/serve/runtimes/worker/batch_queue.py

View check run for this annotation

Codecov / codecov/patch

jina/serve/runtimes/worker/batch_queue.py#L277-L279

Added lines #L277 - L279 were not covered by tests
non_assigned_to_response_docs,
non_assigned_to_response_request_idxs,
sum_from_previous_first_req_idx,
)

sum_from_previous_first_req_idx = (
len(non_assigned_to_response_docs) - num_assigned_docs
)
non_assigned_to_response_docs = non_assigned_to_response_docs[
num_assigned_docs:
]
non_assigned_to_response_request_idxs = (
non_assigned_to_response_request_idxs[num_assigned_docs:]
)
sum_from_previous_first_req_idx = (

Check warning on line 285 in jina/serve/runtimes/worker/batch_queue.py

View check run for this annotation

Codecov / codecov/patch

jina/serve/runtimes/worker/batch_queue.py#L285

Added line #L285 was not covered by tests
len(non_assigned_to_response_docs) - num_assigned_docs
)
non_assigned_to_response_docs = non_assigned_to_response_docs[

Check warning on line 288 in jina/serve/runtimes/worker/batch_queue.py

View check run for this annotation

Codecov / codecov/patch

jina/serve/runtimes/worker/batch_queue.py#L288

Added line #L288 was not covered by tests
num_assigned_docs:
]
non_assigned_to_response_request_idxs = (

Check warning on line 291 in jina/serve/runtimes/worker/batch_queue.py

View check run for this annotation

Codecov / codecov/patch

jina/serve/runtimes/worker/batch_queue.py#L291

Added line #L291 was not covered by tests
non_assigned_to_response_request_idxs[num_assigned_docs:]
)
if len(non_assigned_to_response_request_idxs) > 0:
_ = await _assign_results(
non_assigned_to_response_docs,
Expand Down

0 comments on commit 94fff08

Please sign in to comment.