Rich progress bar doesn't play nicely with other prints
See original GitHub issueπ Bug
Some internal printing mechanisms donβt play nicely with RichProgressBar. This can result in the progress bar getting interleaved into the printed data.
For example, this affects the pretty table of metrics that is printed after Trainer.test
ing your model:
Testing ββββββββββββββββββββββββββββββββββββββββ 1/1 0:00:00 β’ 0:00:00 0.00it/s βββββββββββββββββββββββββββββ³ββββββββββββββββββββββββββββ
β Test metric β DataLoader 0 β
β‘ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β test_loss β -4.4067792892456055 β
βββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββ
A similar issue can also come up, when using RichModelSummary.summarize
.
To Reproduce
Take the BoringModel
sample code and add
callbacks=[pl.callbacks.RichProgressBar()]
to the Trainer
.
Expected behavior
βββββββββββββββββββββββββββββ³ββββββββββββββββββββββββββββ
β Test metric β DataLoader 0 β
β‘ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β test_loss β -4.4067792892456055 β
βββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββ
Testing ββββββββββββββββββββββββββββββββββββββββ 1/1 0:00:00 β’ 0:00:00 0.00it/s
Environment
* CUDA:
- GPU:
- NVIDIA GeForce GTX 1050
- available: True
- version: 11.3
* Packages:
- numpy: 1.22.3
- pyTorch_debug: False
- pyTorch_version: 1.11.0+cu113
- pytorch-lightning: 1.6.0
- tqdm: 4.63.2
* System:
- OS: Linux
- architecture:
- 64bit
- ELF
- processor:
- python: 3.10.4
- version: #1 SMP PREEMPT Mon Mar 28 09:16:36 UTC 2022
Fix
Instead of creating a new Console
and printing to it, RichModelSummary.summarize
and EvaluationLoop._print_results
should check if trainer
has a progress_bar_callback
of type RichProgressBar
and if so, it should use trainer.progress_bar_callback.progress.console
.
Edit: Actually a better solution might be using rich.get_console()
instead of creating new instances of rich.console.Console()
everywhere and if you need to change the kwargs
(because user passed console_kwargs
in RichProgressBar
) use rich.reconfigure(**console_kwargs)
.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Sorry, I am kind of busy right now. I am trying to submit issues as I run into them, but I donβt currently have the time to properly fix them. If this issue is still not fixed in a couple of weeks, I might revisit it and submit the PRs, but for now Iβll have to pass.
@carmocca
rich==12.2.0