Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: async progress bar does not display #779

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 32 additions & 24 deletions client/clip_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,19 +284,22 @@ async def aencode(self, content, **kwargs):
)

results = DocumentArray()
async for da in self._async_client.post(
**self._get_post_payload(content, kwargs)
):
if not results:
self._pbar.start_task(self._r_task)
results.extend(da)
self._pbar.update(
self._r_task,
advance=len(da),
total_size=str(
filesize.decimal(int(os.environ.get('JINA_GRPC_RECV_BYTES', '0')))
),
)
with self._pbar:
async for da in self._async_client.post(
**self._get_post_payload(content, kwargs)
):
if not results:
self._pbar.start_task(self._r_task)
results.extend(da)
self._pbar.update(
self._r_task,
advance=len(da),
total_size=str(
filesize.decimal(
int(os.environ.get('JINA_GRPC_RECV_BYTES', '0'))
)
),
)

return self._unboxed_result(results)

Expand Down Expand Up @@ -415,16 +418,21 @@ async def arank(self, docs: Iterable['Document'], **kwargs) -> 'DocumentArray':
total=len(docs),
)
results = DocumentArray()
async for da in self._async_client.post(**self._get_rank_payload(docs, kwargs)):
if not results:
self._pbar.start_task(self._r_task)
results.extend(da)
self._pbar.update(
self._r_task,
advance=len(da),
total_size=str(
filesize.decimal(int(os.environ.get('JINA_GRPC_RECV_BYTES', '0')))
),
)
with self._pbar:
async for da in self._async_client.post(
**self._get_rank_payload(docs, kwargs)
):
if not results:
self._pbar.start_task(self._r_task)
results.extend(da)
self._pbar.update(
self._r_task,
advance=len(da),
total_size=str(
filesize.decimal(
int(os.environ.get('JINA_GRPC_RECV_BYTES', '0'))
)
),
)

return results