Skip to content

Commit 79fd687

Browse files
committed
Resolve #4
1 parent b8104bc commit 79fd687

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

joblib_progress/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,17 @@ def joblib_progress(description: Optional[str] = None, total: Optional[int] = No
3333
)
3434
task_id = progress.add_task(f"[cyan]{description}", total=total)
3535

36-
class BatchCompletionCallback(joblib.parallel.BatchCompletionCallBack):
37-
def __call__(self, *args, **kwargs):
38-
progress.update(task_id, advance=self.batch_size, refresh=True)
39-
return super().__call__(*args, **kwargs)
36+
print_progress = joblib.parallel.Parallel.print_progress
4037

41-
old_callback = joblib.parallel.BatchCompletionCallBack
38+
def update_progress(self: joblib.parallel.Parallel):
39+
progress.update(task_id, completed=self.n_completed_tasks, refresh=True)
40+
return print_progress(self)
4241

4342
try:
44-
joblib.parallel.BatchCompletionCallBack = BatchCompletionCallback
43+
joblib.parallel.Parallel.print_progress = update_progress
4544
progress.start()
4645

4746
yield progress
4847
finally:
4948
progress.stop()
50-
joblib.parallel.BatchCompletionCallBack = old_callback
49+
joblib.parallel.Parallel.print_progress = print_progress

0 commit comments

Comments
 (0)