Skip to content

Commit 71c1f3b

Browse files
Add real-time progress bar with throughput display for parallel execution
1 parent 534de8c commit 71c1f3b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

engine/base_client/search.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,20 @@ def worker_function(chunk, result_queue):
140140
# Start measuring time for the critical work
141141
start = time.perf_counter()
142142

143+
# Create a progress bar for the total number of queries
144+
total_queries = len(used_queries)
145+
pbar = tqdm.tqdm(total=total_queries, desc="Processing queries", unit="queries")
146+
143147
# Collect results from all worker processes
144148
results = []
145149
for _ in processes:
146-
results.extend(result_queue.get())
150+
chunk_results = result_queue.get()
151+
results.extend(chunk_results)
152+
# Update the progress bar with the number of processed queries in this chunk
153+
pbar.update(len(chunk_results))
154+
155+
# Close the progress bar
156+
pbar.close()
147157

148158
# Wait for all worker processes to finish
149159
for process in processes:
@@ -192,6 +202,7 @@ def chunked_iterable(iterable, size):
192202

193203
def process_chunk(chunk, search_one):
194204
"""Process a chunk of queries using the search_one function."""
205+
# No progress bar in worker processes to avoid cluttering the output
195206
return [search_one(query) for query in chunk]
196207

197208

0 commit comments

Comments
 (0)