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] Top line of live table duplicated in this progress bar example #1144

Closed
StoneLabs opened this issue Mar 30, 2021 · 2 comments
Closed

Comments

@StoneLabs
Copy link

StoneLabs commented Mar 30, 2021

Describe the bug
In the code example below there are 100 major tasks that each contain 10 minor tasks. I've done this using a Live of a Table with two Progress bars. The minor tasks are added once at a time. After each major task, the minor tasks are removed.

This snippet leads to some artifacts being generated above the Live which is slowly sliding down at seemingly random times.
I've added a screenshot below to illustrate.

To Reproduce
Please note: The bug occurs often but at seemingly random times. Give it a few major tasks and it should show up.

import time

from rich.live import Live
from rich.progress import Progress, BarColumn, TimeRemainingColumn, TextColumn, SpinnerColumn, TransferSpeedColumn, FileSizeColumn, TotalFileSizeColumn
from rich.table import Table

progressOverall = Progress(
    "{task.completed} of {task.total}",
    BarColumn(),
    "[progress.percentage]{task.percentage:>3.2f}%",
    TimeRemainingColumn(),
    "[progress.description]{task.description}",
)
taskOverall = progressOverall.add_task("[red]Downloading piece...", total=100)

progressFile = Progress(
    "├─",
    SpinnerColumn(),
    BarColumn(),
    "[progress.percentage]{task.percentage:>3.0f}%",
    TransferSpeedColumn(),
    TotalFileSizeColumn(),
    TimeRemainingColumn(),
    "[progress.description]{task.description}",
)

progress_table = Table(show_header=False, show_edge=False)
progress_table.add_row(progressOverall)
progress_table.add_row(progressFile)

with Live(progress_table, refresh_per_second=30, vertical_overflow="visible") as live:
    print = live.console.print

    for i in range(100):
        progressOverall.update(taskOverall, completed=i, description="Major Task # %s" % (i)) # Update major task with progress

        for minorTaskID in range(10):
            taskFile = progressFile.add_task("[red]Downloading: %d" % (minorTaskID), total=100) # Create minor task

            time.sleep(0.4)
            progressFile.update(taskFile, description="[green]Done", completed=100) # Simulate it being done after a couple of 0.4s
            time.sleep(0.4)

        # Clear the minor tasks for the next major task
        for task in progressFile.task_ids:
            progressFile.remove_task(task)

        time.sleep(0.5)

Output
Bug picture 1

Bug picture 2

Platform
Microsoft Windows 10 Pro Version 10.0.19041 Build 19041

Diagnose

PS C:\Users\Stone> python -m rich.diagnose
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=120 ColorSystem.TRUECOLOR>                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = 'truecolor'                                                   │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 45                                                            │
│    is_alt_screen = False                                                         │
│ is_dumb_terminal = False                                                         │
│   is_interactive = True                                                          │
│       is_jupyter = False                                                         │
│      is_terminal = True                                                          │
│   legacy_windows = False                                                         │
│         no_color = False                                                         │
│          options = ConsoleOptions(                                               │
│                        size=ConsoleDimensions(width=120, height=45),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=120,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=120, height=45)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 120                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯

PS C:\Users\Stone> python -m rich._windows
platform="Windows"
WindowsConsoleFeatures(vt=True, truecolor=True)

PS C:\Users\Stone> pip freeze
...
rich==10.0.0
...
@willmcgugan
Copy link
Collaborator

Please try with v10.0.1

@StoneLabs
Copy link
Author

Appears to be fixed with v10.0.1. Thank you.

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

2 participants