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

Python: Investigate enabling streaming output from ipykernel #284

Open
petetronic opened this issue Mar 15, 2023 · 4 comments
Open

Python: Investigate enabling streaming output from ipykernel #284

petetronic opened this issue Mar 15, 2023 · 4 comments

Comments

@petetronic
Copy link
Collaborator

For use cases such as progress bar output, we don't see the progressive ANSI control characters, as ipykernel buffers output and sends the final state of the output instead.

We need to investigate ipykernel as to whether we can get it to stream output instead.

@petetronic petetronic added this to the Internal Preview milestone Mar 15, 2023
@softwarenerd
Copy link
Contributor

For example, this does not work because progressive output is not being streamed:

from time import sleep
from alive_progress import alive_bar
for i in range(10):
    with alive_bar(100, ctrl_c=False, title=f'Download {i}') as bar:
        for i in range(100):
            sleep(0.02)
            bar()

@petetronic
Copy link
Collaborator Author

When we get to investigate this, we should consider if it is related to sys.stdout.isatty() returning False for our Python process.

@jmcphers
Copy link
Collaborator

Interestingly enough this does work for some kinds of progressive output. If you use pip install from inside Python, then pip streams progress bars to standard output, and they render beautifully during download and installation.

IPyKernel distinguishes between stdout text (which is streamed) and computational results from Python itself (which are not).

The reason output streaming "works" from R is that we treat everything as standard output, even intermediate computational results. This is itself a bug. See #281.

@seeM seeM changed the title Console: Investigate enabling streaming output from ipykernel Python Python: Investigate enabling streaming output from ipykernel Jun 29, 2023
@seeM
Copy link
Contributor

seeM commented Feb 7, 2024

It looks like Jupyter Notebook has the same behavior as Positron with alive_bar.

Jupyter Notebook:

Screen.Recording.2024-02-07.at.14.54.03.mov

Positron Version: 2024.02.0 (Universal) build 1500:

Screen.Recording.2024-02-07.at.14.55.45.mov

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

6 participants