Does Jupyter remove+coalesce large number of stderror outputs?

I present an example below where a given cell in the notebook JSON has thousands of stderr outputs (seems like they indicate % of progress of some operation). As soon as I open this notebook in Jupyter, the underlying JSON changes. It -

  • removes most of the outputs &
  • combines the remaining outputs section into a single output

Can someone please briefly explain (or point me to) the logic of how Jupyter decides which outputs to ignore/remove?

Example

Checkout _notebooks/2020-03-16-covid19_growth_bayes.ipynb in this Pull Request.

You can see the raw JSON here. And here is the rendered version of the same file on nbviewer.

10th cell in this file has thousands of small outputs like shown below,

All of those progress bar outputs are removed as soon as you open the file in nbviewer or Jupyter,

Do you see those \r characters? Those are in there so that the content stays on the same line and overwrites the previous progress bar. Depending on which frontend you are using, it may collapse all those and delete the text that is overwritten.

1 Like

That makes sense. I will employ something similar in ReviewNB. Currently I am showing all those progress bars in the diff UI.

Thanks @jasongrout.

See https://github.com/jupyterlab/jupyterlab/blob/ce2376b46c8de70075d457d7345440b02e56241d/packages/outputarea/src/model.ts#L446-L479 and https://github.com/jupyterlab/jupyterlab/blob/ce2376b46c8de70075d457d7345440b02e56241d/packages/outputarea/src/model.ts#L306-L332

1 Like

Nice. Thank you @jasongrout for linking to the source.