Skip to content

Commit

Permalink
docs: fix docstring
Browse files Browse the repository at this point in the history
Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>
  • Loading branch information
JoanFM committed Oct 4, 2023
1 parent 0ae67a1 commit a6df665
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions jina/serve/runtimes/worker/batch_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,14 @@ def _get_docs_groups_completed_request_indexes(non_assigned_docs,
This method groups all the `non_assigned_docs` into groups of docs according to the `req_idx` they belong to.
They are only distributed when we are sure that the request is full.
The method returns the a list of document groups and a list of request Idx to which each of these groups belong
The method returns the ac
:param non_assigned_docs: The documents that have already been processed but have not been assigned to a request result
:param non_assigned_docs_reqs_idx: The request IDX that are not yet completed (not all of its docs have been processed)
:param sum_from_previous_mini_batch_in_first_req_idx: The number of docs from previous iteration that belong to the first non_assigned_req_idx. This is useful
to make sure we know when a request is completed.
:return: list of document groups and a list of request Idx to which each of these groups belong
"""
distributed_requests = []
completed_req_idx = []
Expand All @@ -149,10 +156,11 @@ def _get_docs_groups_completed_request_indexes(non_assigned_docs,
completed_req_idx.append(req_idx)
request_bucket = non_assigned_docs[num_distributed_docs: num_distributed_docs + num_docs_in_req_idx]
distributed_requests.append(request_bucket)

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

View check run for this annotation

Codecov / codecov/patch

jina/serve/runtimes/worker/batch_queue.py#L156-L158

Added lines #L156 - L158 were not covered by tests

return distributed_requests, completed_req_idx

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L160 was not covered by tests

async def _assign_results(non_assigned_to_response_docs,
non_assigned_to_response_request_idxs,
async def _assign_results(non_assigned_docs,

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L162 was not covered by tests
non_assigned_docs_reqs_idx,
sum_from_previous_mini_batch_in_first_req_idx):
"""
This method aims to assign to the corresponding request objects the resulting documents from the mini batches.
Expand All @@ -161,10 +169,17 @@ async def _assign_results(non_assigned_to_response_docs,
It also communicates to the corresponding queue that the request is full so that it can be returned
It returns the amount of assigned documents so that some documents can come back in the next iteration
:param non_assigned_docs: The documents that have already been processed but have not been assigned to a request result
:param non_assigned_docs_reqs_idx: The request IDX that are not yet completed (not all of its docs have been processed)
:param sum_from_previous_mini_batch_in_first_req_idx: The number of docs from previous iteration that belong to the first non_assigned_req_idx. This is useful
to make sure we know when a request is completed.
:return: amount of assigned documents so that some documents can come back in the next iteration
"""
docs_grouped, completed_req_idxs = _get_docs_groups_completed_request_indexes(non_assigned_to_response_docs,
non_assigned_to_response_request_idxs,
sum_from_previous_mini_batch_in_first_req_idx)
docs_grouped, completed_req_idxs = _get_docs_groups_completed_request_indexes(non_assigned_docs,

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L180 was not covered by tests
non_assigned_docs_reqs_idx,
sum_from_previous_mini_batch_in_first_req_idx)
num_assigned_docs = sum(len(group) for group in docs_grouped)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L183 was not covered by tests

for docs_group, request_idx in zip(docs_grouped, completed_req_idxs):
Expand Down

0 comments on commit a6df665

Please sign in to comment.