Progress bars in IPython Notebooks

Pushed a few changes that I’ll send on Pypi later today for v0.1.4. It replaces IS_NOTEBOOK by your test and adds a function force_console_behavior that can force the behavior of console (as the name indicates) for users of Spider or qtconsole (I’ll fix this problem later if necessary). Usage:

from fast_progress import force_console_behavior
master_bar, progress_bar = force_console_behavior()

Also @radek wanted an option to have no bar at all and only the epochs stats printed, this behavior can now be obtained with

from fast_progress import force_console_behavior
import fast_progress
fast_progress.fast_progress.NO_BAR = True
master_bar, progress_bar = force_console_behavior()
2 Likes

Great. Can you check the output for spyder console for shell = get_ipython().__class__.__name__. That should be different from the normal ipython and python outputs and another if else statement should do the job. Though its not the most elegant solution.

Nope, this one gives the same as in a notebook. I have seen solutions for Spyder and QtConsole, it’s jsut going to take a bit of time and we have other priorities right now :wink:

1 Like

Important note: we have removed the package fast_progress and replaced it with fastprogress because conda didn’t like the _.
Don’t forget to update your code accordingly!

Sure. Thanks for the heads up. Might want to change them on the readme files as well :slight_smile:

1 Like

Good point, thanks for telling me!

fastprogress link in readme file of fastai should redirect to fast_progress repository, or may be you would want to change the name of the repo

I ran this with fastai_pytorch and fastprogress 0.1.5 and works great :slight_smile: Thx again Sylvain

Fastprogress is not working for me in Jupyter Lab but works in Jupyter notebooks with the new release.

There is an additional step to have it properly working in jupyter lab: you must have the jupyter widgets extension properly installed, which I think is done with:

jupyter labextension install @jupyter-widgets/jupyterlab-manager

Let me know if it solves your issue.

5 Likes

Hi @sgugger can you clarify how I can use the force_console_behavior to change the default display of progress bars with the fastai library. Once I have the master_bar and progress_bar how do I tell fastai to use them?

Once you have done that, every time you call fit or a function that uses progress bars, you’ll see the text rendering of a console.
Then you can use progress_bar on anything you want to track the progress of (see the fastprogress repo for more examples).

Apologies if I am misunderstanding your suggestion but I think I have tried that.

For the record, I am using the emacs ipython notebook, which makes fastprogress think I am in a jupyter notebook.

I can verify that it works when it it is in scope

But based on the fastai source code, I don’t currently see a way to override the progress_bar objects that are imported from core.py

Arf, that’s because fastai uses its own copy of progress_bar/master_bar. You should add:

fastai.basic_train.master_bar, fastai.basic_train.progress_bar = master_bar, progress_bar

after your force_console_behavior().
This is a bit hacky for now, but ultimately, I hope to have fastprogress recognize emacs or spyder from jupyter notebook.

2 Likes

Thanks so much! I am totally fine with the hack for now. It is really great to have the freedom to switch to console mode. I will definitely be using fastprogress in other projects now! Let me know if you ever need a test subject for future emacs ipython notebook functionality.

1 Like

I have the latest version of FastAI Dev (pulled around 10 mins ago) and as per @sgugger instructions I have the appropriate jupyter lab extension:

jupyter labextension install @jupyter-widgets/jupyterlab-manager

However, despite this, I am not getting a progress bar during training:

learn.lr_find()
VBox(children=(HBox(children=(IntProgress(value=0, max=1), HTML(value='0.00% [0/1 00:00<00:00]'))), HTML(value…

I’m running this in JupyterLab. Please note that this used to work earlier.

I have no idea why it stopped working, but it’s probably ipywidget’s fault somehow. Note that you can force the console behavior to see something.

I deleted the environment and started afresh. Restarted and cleared out all the variables in the notebook. Its working now. Weird!

1 Like

Hi Everyone,

any hints how to eliminate the progress bar - or at least the deletion of a Notebook’s cell for following calls?

learn.lr_find()
learn.fit_one_cycle()

Thanks,
Andras

This helped to get the Widgets (Like file upload) working for Jupyter lab. Thanks.