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

Stream output is not rendered correctly in jupyter-collaboration 3 #16934

Closed
trungleduc opened this issue Nov 6, 2024 · 3 comments
Closed

Stream output is not rendered correctly in jupyter-collaboration 3 #16934

trungleduc opened this issue Nov 6, 2024 · 3 comments

Comments

@trungleduc
Copy link
Member

Description

By using Jupyter Collaboration 3 with JupyterLab 4.3.0, the stream output of a saved notebook will be rendered in one column.

colab-bug3.mp4

Reproduce

  • Create an environment with JupyterLab 4.3.0 and Jupyter Collaboration 3.0.0
  • Create a new notebook with the following content:
text = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam urna
libero, dictum a egestas non, placerat vel neque. In imperdiet iaculis fermentum. 
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia 
Curae; Cras augue tortor, tristique vitae varius nec, dictum eu lectus. Pellentesque 
id eleifend eros. In non odio in lorem iaculis sollicitudin. In faucibus ante ut 
arcu fringilla interdum. Maecenas elit nulla, imperdiet nec blandit et, consequat 
ut elit."""
print(text)
  • Save the notebook then restart JupyterLab
  • Remove all hidden cache:
 rm -fr .ipynb_checkpoints. .jupyter_ystore.db
  • Start JupyterLab and open the above notebook

Expected behavior

The culprit is in this function: https://github.com/jupyterlab/jupyterlab/blob/main/packages/outputarea/src/model.ts#L514

  export function normalize(value: nbformat.IOutput): void {
    if (nbformat.isStream(value)) {
      if (Array.isArray(value.text)) {
        value.text = (value.text as string[]).join('\n');
      }
    }
  }

Since in RTC mode, the output text is a list of characters, and this normalize function appends \n to all of them. Removing the '\n' argument of the join function fixes the issue.

Context

jupyter-collaboration     3.0.0              pyhd8ed1ab_0    conda-forge
jupyter-collaboration-ui  1.0.0              pyhd8ed1ab_0    conda-forge
jupyter-docprovider       1.0.0              pyhd8ed1ab_0    conda-forge
jupyter-lsp               2.2.5              pyhd8ed1ab_0    conda-forge
jupyter_client            8.6.3              pyhd8ed1ab_0    conda-forge
jupyter_core              5.7.2              pyh31011fe_1    conda-forge
jupyter_events            0.10.0             pyhd8ed1ab_0    conda-forge
jupyter_server            2.14.2             pyhd8ed1ab_0    conda-forge
jupyter_server_fileid     0.9.2              pyhd8ed1ab_0    conda-forge
jupyter_server_terminals  0.5.3              pyhd8ed1ab_0    conda-forge
jupyter_server_ydoc       1.0.0              pyhd8ed1ab_0    conda-forge
jupyter_ydoc              3.0.0              pyhd8ed1ab_0    conda-forge
jupyterlab                4.3.0              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.3.0              pyhd8ed1ab_1    conda-forge
jupyterlab_server         2.27.3             pyhd8ed1ab_0    conda-forge
Troubleshoot Output
Paste the output from running `jupyter troubleshoot` from the command line here.
You may want to sanitize the paths in the output.
Command Line Output
Paste the output from your command line running `jupyter lab` here, use `--debug` if possible.
Browser Output
Paste the output from your browser Javascript console here, if applicable.
@trungleduc trungleduc added bug tag:Real Time Collaboration status:Needs Triage Applied to new issues that need triage labels Nov 6, 2024
@trungleduc trungleduc changed the title Stream output is not rendered correct in jupyter-collaboration 3 Stream output is not rendered correctly in jupyter-collaboration 3 Nov 6, 2024
@JasonWeill JasonWeill removed the status:Needs Triage Applied to new issues that need triage label Nov 12, 2024
@ellisonbg
Copy link
Contributor

Thanks, I have seen this one as well.

@davidbrochart
Copy link
Contributor

This has been fixed in jupyter-ydoc v3.0.2.

@trungleduc
Copy link
Member Author

Thanks @davidbrochart

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