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 show progress being out of order #12897

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 3 additions & 6 deletions llama-index-core/llama_index/core/async_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Async utils."""

import asyncio
import tqdm
from itertools import zip_longest
from typing import Any, Coroutine, Iterable, List, Optional, TypeVar

Expand Down Expand Up @@ -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)

Expand Down