From 0e3ee6c975b857afb6042b14b00489a039abc7ec Mon Sep 17 00:00:00 2001 From: Logan Markewich Date: Wed, 17 Apr 2024 10:39:42 -0600 Subject: [PATCH] Fix show progress being out of order --- llama-index-core/llama_index/core/async_utils.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/llama-index-core/llama_index/core/async_utils.py b/llama-index-core/llama_index/core/async_utils.py index 8713ea940d566..fdb5ec77eb98b 100644 --- a/llama-index-core/llama_index/core/async_utils.py +++ b/llama-index-core/llama_index/core/async_utils.py @@ -1,7 +1,6 @@ """Async utils.""" import asyncio -import tqdm from itertools import zip_longest from typing import Any, Coroutine, Iterable, List, Optional, TypeVar @@ -119,11 +118,9 @@ async def worker(job: Coroutine) -> Any: pool_jobs = [worker(job) for job in jobs] if show_progress: - results = [] - for result in tqdm.tqdm( - asyncio.as_completed(pool_jobs), total=len(pool_jobs), desc=desc - ): - results.append(await result) + from tqdm.asyncio import tqdm_asyncio + + results = await tqdm_asyncio.gather(*pool_jobs, desc=desc) else: results = await asyncio.gather(*pool_jobs)