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
Fix duplicate progress output in Jupyter #2804
Conversation
45f62a8
to
5170ddb
Compare
FWIW, the relevant code is in calls to It's specifically a problem with I still don't precisely know why the show_cursor calls trigger OutputWidget thinking there's a newline. This may have to do with the lifecycle of the OutputWidget's capture and when exactly show_cursor is called. I'm not sure. It may also be a bug in OutputWidget's handling of control characters and/or import time
from rich.console import Console
from rich.progress import Progress
with Progress(console=Console(force_terminal=False, force_jupyter=True)) as p:
for i in p.track(range(10), description="jupyer, no terminal"):
time.sleep(0.01)
with Progress(console=Console(force_terminal=True, force_jupyter=False)) as p:
for i in p.track(range(10), description="terminal, no jupyter"):
time.sleep(0.01)
with Progress(console=Console(force_terminal=True, force_jupyter=True)) as p:
for i in p.track(range(10), description="jupyter+terminal"):
time.sleep(0.01) produces duplicate output only for
|
5170ddb
to
6b7d00f
Compare
6b7d00f
to
12c0488
Compare
Codecov ReportPatch coverage:
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## master #2804 +/- ##
=======================================
Coverage 98.38% 98.38%
=======================================
Files 74 74
Lines 7930 7932 +2
=======================================
+ Hits 7802 7804 +2
Misses 128 128
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Thanks |
Type of changes
Checklist
Description
#2449 caused FORCE_COLOR to forcefully imply a terminal. This environment variable tends to be set in a Jupyter context. When
Console.is_terminal
is True, duplicate output is produced by progress bars (#2740). I haven't tracked down exactly what output whenis_terminal=True
causes the duplicated output (likely something involving carriage returns or control characters, which Jupyter doesn't always get right), but the fact remains that if you're in a Jupyter kernel, you aren't in a terminal.This PR shifts the handling of FORCE_COLOR away from
_force_terminal
and intois_terminal
, where other interactive environment detection happens (idle).Sample output from b89d036:
closes #2740