Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Using status overwrites all previous output when in Jupyter notebook #2112

Open
ggydush-fn opened this issue Mar 25, 2022 · 5 comments

Comments

@ggydush-fn
Copy link

ggydush-fn commented Mar 25, 2022

Describe the bug

When in a Jupyter notebook, using status overwrites all previous output.

import time

from rich.console import Console

print("Previous output")
console = Console()

with console.status('This overwrites previous output'):
    time.sleep(2)

Platform

Click to expand

What platform (Win/Linux/Mac) are you running on? What terminal software are you using?

I may ask you to copy and paste the output of the following commands. It may save some time if you do it now.

If you're using Rich in a terminal:

╭────────────────────── <class 'rich.console.Console'> ──────────────────────╮
│ A high level console interface.                                            │
│                                                                            │
│ ╭────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=93 ColorSystem.TRUECOLOR>                               │ │
│ ╰────────────────────────────────────────────────────────────────────────╯ │
│                                                                            │
│     color_system = 'truecolor'                                             │
│         encoding = 'utf-8'                                                 │
│             file = <ipykernel.iostream.OutStream object at 0x7f9c0ea1eb20> │
│           height = 100                                                     │
│    is_alt_screen = False                                                   │
│ is_dumb_terminal = False                                                   │
│   is_interactive = False                                                   │
│       is_jupyter = True                                                    │
│      is_terminal = False                                                   │
│   legacy_windows = False                                                   │
│         no_color = False                                                   │
│          options = ConsoleOptions(                                         │
│                        size=ConsoleDimensions(width=93, height=100),       │
│                        legacy_windows=False,                               │
│                        min_width=1,                                        │
│                        max_width=93,                                       │
│                        is_terminal=False,                                  │
│                        encoding='utf-8',                                   │
│                        max_height=100,                                     │
│                        justify=None,                                       │
│                        overflow=None,                                      │
│                        no_wrap=False,                                      │
│                        highlight=None,                                     │
│                        markup=None,                                        │
│                        height=None                                         │
│                    )                                                       │
│            quiet = False                                                   │
│           record = False                                                   │
│         safe_box = True                                                    │
│             size = ConsoleDimensions(width=93, height=100)                 │
│        soft_wrap = False                                                   │
│           stderr = False                                                   │
│            style = None                                                    │
│         tab_size = 8                                                       │
│            width = 93                                                      │
╰────────────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available.                           │
│                                                       │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│                                                       │
│ truecolor = False                                     │
│        vt = False                                     │
╰───────────────────────────────────────────────────────╯
╭────── Environment Variables ───────╮
│ {                                  │
│     'TERM': 'xterm-color',         │
│     'COLORTERM': None,             │
│     'CLICOLOR': '1',               │
│     'NO_COLOR': None,              │
│     'TERM_PROGRAM': None,          │
│     'COLUMNS': None,               │
│     'LINES': None,                 │
│     'JPY_PARENT_PID': '53',        │
│     'VSCODE_VERBOSE_LOGGING': None │
│ }                                  │
╰────────────────────────────────────╯
platform="Linux"
@USLTD
Copy link
Contributor

USLTD commented Mar 25, 2022

Please post output of

from rich.diagnose import report
report()

@ggydush-fn
Copy link
Author

@UltraStudioLTD Updated the Platform section!

@willmcgugan
Copy link
Collaborator

@ggydush-fn Can you try in Jupyter lab. There are API differences in Jupyter Lab and Jupyter Notebook, which unfortunately there is not much we can do about.

@ggydush-fn
Copy link
Author

@willmcgugan Thanks for getting back and you were right on target there! Bummer about the API differences and not having much control over it, but appreciate you taking a look!

Just in case anyone gets here down the road:

I tried this on JupyterHub and it looked like the following (previous text is overwritten):

jupyterhub.mov

Whereas on JupyterLab in a fresh environment (and in Vscode's notebooks), the previous text was kept:

jupyterlab.mov

@Damacustas
Copy link

I also encounter this issue or at least very similar. I can replicate this with the status sample. All output from console.log (except 'task 10 complete') is removed:
image

When run in a jupyter terminal, I do get the behaviour I expect:
image

Output of rich.diagnose.report:
╭────────────────────── <class 'rich.console.Console'> ──────────────────────╮
│ A high level console interface.                                            │
│                                                                            │
│ ╭────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=115 ColorSystem.TRUECOLOR>                              │ │
│ ╰────────────────────────────────────────────────────────────────────────╯ │
│                                                                            │
│     color_system = 'truecolor'                                             │
│         encoding = 'utf-8'                                                 │
│             file = <ipykernel.iostream.OutStream object at 0x7ff6d4b86070> │
│           height = 100                                                     │
│    is_alt_screen = False                                                   │
│ is_dumb_terminal = False                                                   │
│   is_interactive = False                                                   │
│       is_jupyter = True                                                    │
│      is_terminal = False                                                   │
│   legacy_windows = False                                                   │
│         no_color = False                                                   │
│          options = ConsoleOptions(                                         │
│                        size=ConsoleDimensions(width=115, height=100),      │
│                        legacy_windows=False,                               │
│                        min_width=1,                                        │
│                        max_width=115,                                      │
│                        is_terminal=False,                                  │
│                        encoding='utf-8',                                   │
│                        max_height=100,                                     │
│                        justify=None,                                       │
│                        overflow=None,                                      │
│                        no_wrap=False,                                      │
│                        highlight=None,                                     │
│                        markup=None,                                        │
│                        height=None                                         │
│                    )                                                       │
│            quiet = False                                                   │
│           record = False                                                   │
│         safe_box = True                                                    │
│             size = ConsoleDimensions(width=115, height=100)                │
│        soft_wrap = False                                                   │
│           stderr = False                                                   │
│            style = None                                                    │
│         tab_size = 8                                                       │
│            width = 115                                                     │
╰────────────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available.                           │
│                                                       │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│                                                       │
│ truecolor = False                                     │
│        vt = False                                     │
╰───────────────────────────────────────────────────────╯
╭────── Environment Variables ───────╮
│ {                                  │
│     'TERM': 'xterm-color',         │
│     'COLORTERM': None,             │
│     'CLICOLOR': '1',               │
│     'NO_COLOR': None,              │
│     'TERM_PROGRAM': None,          │
│     'COLUMNS': None,               │
│     'LINES': None,                 │
│     'JUPYTER_COLUMNS': None,       │
│     'JUPYTER_LINES': None,         │
│     'JPY_PARENT_PID': '90838',     │
│     'VSCODE_VERBOSE_LOGGING': None │
│ }                                  │
╰────────────────────────────────────╯
platform="Linux"
I'm using jupyterlab version 3.2.4, being run from RStudio Workbench on Linux with Python 3.8.14. I have ipywidgets version 8.0.4. Rich version 12.5.1.

Different ipywidgets version

It gets more interesting when I use an ipywidgets version 7.7.2 (last version before v8.0), everything else kept equal.
Then I get this output:
image

Different environment

When running on a standalone jupyter lab instance on a different machine I even get this behaviour:
image
This is run with jupyter lab version 3.5.2, ipywidgets 7.7.2, rich 12.6.0, python 3.9.12 on Windows 10. I also tried ipywidgets 8.0.4 which gives equal behaviour.

I don't know if this is all related, but I wanted to be complete. Is there any additional information I can provide that would help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants