Skip to content

Commit 4168c01

Browse files
committed
feat: add back progress bar
1 parent 21b157e commit 4168c01

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

parea/experiment/experiment.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,20 @@ def limit_concurrency_sync(sample):
146146
tasks = [asyncio.ensure_future(loop.run_in_executor(executor, partial(limit_concurrency_sync, sample))) for
147147
sample in data]
148148

149-
done, pending = await asyncio.wait(tasks, return_when=asyncio.FIRST_EXCEPTION)
150149
status = ExperimentStatus.COMPLETED
151-
for task in done:
150+
with tqdm(total=len(tasks), desc="Running samples", unit="sample") as pbar:
152151
try:
153-
await task
154-
except Exception as e:
155-
print(f"Experiment stopped due to an error: {str(e)}")
156-
for _p in pending:
157-
_p.cancel()
158-
status = ExperimentStatus.FAILED
152+
for coro in asyncio.as_completed(tasks):
153+
try:
154+
await coro
155+
pbar.update(1)
156+
except Exception as e:
157+
print(f"\nExperiment stopped due to an error: {str(e)}\n")
158+
status = ExperimentStatus.FAILED
159+
for task in tasks:
160+
task.cancel()
161+
except asyncio.CancelledError:
162+
pass
159163

160164
await asyncio.sleep(0.2)
161165
total_evals = len(thread_ids_running_evals.get())

0 commit comments

Comments
 (0)