question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. Itย collects links to all the places you might be looking at while hunting down a tough bug.

And, if youโ€™re still stuck at the end, weโ€™re happy to hop on a call to see how we can help out.

[BUG] Live Progress Bars Double-Render in Jupyter Notebooks

See original GitHub issue

Describe the bug

Upgrading to 10.15.1 from 10.13.0 causes a double-render when using a live progress bar in a Jupyter Notebook. You can see this easily using the following example code:

from rich.progress import Progress

with Progress() as progress:
    task1 = progress.add_task("[red]Downloading...", total=2)
    while not progress.finished:
        progress.update(task1, advance=1)
        progress.refresh()

image

If it matters, we were using ipywidgets==7.6.5 for this example above. Rolling back to rich==10.13.0 fixed the issue.

You can see the section below for a description of whatโ€™s happening in the Jupyter messaging protocol, but my best guess is that the ipywidgets usage is slightly off and causing this bug.

ipywidgets specifics

Normally when you update an output widget it fires the following messages:

  1. A comm_msg that specifies that all future messages apply to a specific output model
  2. A clear_output message with wait=True
  3. A display_data message including the new content
  4. A comm_msg that specifies that future messages no longer apply to a specific output model

We were noticing that this is still the case except for the final update message, in which it does the following:

  1. A comm_msg that specifies that all future messages apply to a specific output model
  2. A clear_output message with wait=True
  3. A comm_msg that specifies that future messages no longer apply to a specific output model
  4. A display_data message including the new content

The swap of those two messages caused the double-render, because the old render is never cleared by an output to that widget model, and the display_data is tracked as a new output for the cell.

Platform

Underlying platform is linux, using the classic Jupyter interface. This also happened using Noteableโ€™s interface.

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ <class 'rich.console.Console'> โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ A high level console interface.                                              โ”‚
โ”‚                                                                              โ”‚
โ”‚ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚
โ”‚ โ”‚ <console width=80 None>                                                  โ”‚ โ”‚
โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”‚
โ”‚                                                                              โ”‚
โ”‚     color_system = None                                                      โ”‚
โ”‚         encoding = 'utf-8'                                                   โ”‚
โ”‚             file = <_io.TextIOWrapper name='<stdout>' mode='w'               โ”‚
โ”‚                    encoding='utf-8'>                                         โ”‚
โ”‚           height = 25                                                        โ”‚
โ”‚    is_alt_screen = False                                                     โ”‚
โ”‚ is_dumb_terminal = False                                                     โ”‚
โ”‚   is_interactive = False                                                     โ”‚
โ”‚       is_jupyter = False                                                     โ”‚
โ”‚      is_terminal = False                                                     โ”‚
โ”‚   legacy_windows = False                                                     โ”‚
โ”‚         no_color = False                                                     โ”‚
โ”‚          options = ConsoleOptions(                                           โ”‚
โ”‚                        size=ConsoleDimensions(width=80, height=25),          โ”‚
โ”‚                        legacy_windows=False,                                 โ”‚
โ”‚                        min_width=1,                                          โ”‚
โ”‚                        max_width=80,                                         โ”‚
โ”‚                        is_terminal=False,                                    โ”‚
โ”‚                        encoding='utf-8',                                     โ”‚
โ”‚                        max_height=25,                                        โ”‚
โ”‚                        justify=None,                                         โ”‚
โ”‚                        overflow=None,                                        โ”‚
โ”‚                        no_wrap=False,                                        โ”‚
โ”‚                        highlight=None,                                       โ”‚
โ”‚                        markup=None,                                          โ”‚
โ”‚                        height=None                                           โ”‚
โ”‚                    )                                                         โ”‚
โ”‚            quiet = False                                                     โ”‚
โ”‚           record = False                                                     โ”‚
โ”‚         safe_box = True                                                      โ”‚
โ”‚             size = ConsoleDimensions(width=80, height=25)                    โ”‚
โ”‚        soft_wrap = False                                                     โ”‚
โ”‚           stderr = False                                                     โ”‚
โ”‚            style = None                                                      โ”‚
โ”‚         tab_size = 8                                                         โ”‚
โ”‚            width = 80                                                        โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
platform="Linux"
WindowsConsoleFeatures(vt=False, truecolor=False)
rich==10.15.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
willmcgugancommented, Dec 12, 2021

Thatโ€™s in 10.16.0 now

2reactions
willmcgugancommented, Dec 11, 2021

I think I have a fix for that. Please give 10.15.3a1 a try.

There are also changes there to workaround issues with thread-safety in Jupyter. So Iโ€™d appreciate it if you could try it against any code with progress bars.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Live Progress Bars Double-Render in Jupyter Notebooks
A comm_msg that specifies that future messages no longer apply to a specific output model. We were noticing that this is still the...
Read more >
Jupyter Notebooks not displaying progress bars - Stack Overflow
I tried this with a recent version of Juypterlab. The second command takes 10 minutes to run and doesn't fix the issue. โ€“...
Read more >
Notebook API | Visual Studio Code Extension API
The Notebook API allows Visual Studio Code extensions to open files as notebooks, execute notebook code cells, and render notebook outputs in a...
Read more >
Chapter 5 Jupyter Notebook ecosystem - GitHub Pages
A handbook on teaching and learning with Jupyter notebooks. ... generate and display sliders, progress bars, text boxes, check boxes, toggle buttons, etc....
Read more >
papermill Documentation - Read the Docs
Learn more about the jupyter notebook format and metadata fields here. ... Papermill execution progress bars now render within a notebookย ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found