Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display tqdm in AWS Sagemaker's jupyterlab

Does anyone nows how can we have python tqdm progress bar working on a Sagemaker Jupyterlab Noteook ? The tqdm progress bar is never displayed, components are displayed as their code.

Example :

HBox(children=(FloatProgress(value=0.0, max=5234.0), HTML(value='')))

I'm aware of the usual fix describe here, but It does not work since trying to executing jupyter lab build will results in the issue describe here

Many thanks.

like image 910
jugo Avatar asked Mar 12 '20 15:03

jugo


People also ask

Does tqdm work in Jupyter notebook?

tqdm works on any platform (Linux, Windows, Mac, FreeBSD, NetBSD, Solaris/SunOS), in any console or in a GUI, and is also friendly with IPython/Jupyter notebooks.


1 Answers

Thanks for using Sagemaker Notebooks!

I got this working by following the instructions in your links.

Note: I had to use the Jupyter terminal instead of using a magic ! from the notebook. There was a lot of output during the installation which slowed Jupyter down too much.

So in the terminal:

jupyter labextension install @jupyter-widgets/jupyterlab-manager > /dev/null

then:

jupyter nbextension enable --py widgetsnbextension

At this point you need to reload Jupyterlab in your browser. This is because the labextension build generates a new javascript bundle that you must reload to get.

Finally in the notebook:

!pip install tqdm

and then the example worked:

import time
from tqdm import tqdm_notebook

example_iter = [1,2,3,4,5]
for rec in tqdm_notebook(example_iter):
    time.sleep(.1)

Hope this helps!

You should also try in a new notebook instance to ensure you are on the latest version of Jupyterlab.

like image 94
user3363678 Avatar answered Sep 28 '22 04:09

user3363678