Progress Bar doesn't reach 100% in Jupyter
Closed this issue · 2 comments
Hey,
thanks for creating such a nice, elegant and simple package. I was playing with it today, using the demo code from the README mostly because I wanted to see what happens when you don't specify a total
to the context manager.
When I run the demo code in a single Jupyter(Lab) notebook cell the process completes but the progress never shows 100%, it stops at 9/10
. However, when I run the same demo code from a python script file (python test.py
) the code executes exactly like the demo, and shows 10/10
as expected. Any thoughts on what is happening in the notebook setting and how to fix?
For what it's work I am using:
jupyterlab 3.6.5
rich 13.6.0
joblib 1.3.2
I believe I fixed it, based on the rich progress documentation, (https://rich.readthedocs.io/en/stable/progress.html#),
Progress works with Jupyter notebooks, with the caveat that auto-refresh is disabled. You will need to explicitly call refresh() or set refresh=True when calling update(). Or use the track() function which does a refresh automatically on each loop.
the progress.update( ... )
could use refresh=True
, making the change:
...
class BatchCompletionCallback(joblib.parallel.BatchCompletionCallBack):
def __call__(self, *args, **kwargs):
progress.update(task_id, advance=self.batch_size, refresh=True)
return super().__call__(*args, **kwargs)
...
This change works in my basic testing using the demo-code in notebooks as well as shell scripts. I'll submit a PR in a moment with the change.
Resolved in version 1.0.4