Skip to content

Use rich output for Jupyter notebooks

Problem to solve

Not all features of Jupyter notebooks display properly in GitLab

Proposal

Integrate the nbviewer.js library to GitLab to solve these rendering issues for good. Something like a w3 would be enough to assess.

Further Details

The linked notebook below is from a Github repo that the Jupyter team often use to demonstrate the latest capabilities. This Rich Output.ipynb file is therefore a good benchmark against which to measure the rendering capabilities of Jupyter Notebooks within Gitlab.

https://github.com/ipython/ipython-in-depth/blob/master/examples/IPython%20Kernel/Rich%20Output.ipynb http://nbviewer.jupyter.org/github/ipython/ipython-in-depth/blob/master/examples/IPython%20Kernel/Rich%20Output.ipynb

I've reproduced some screenshots of where things are broken. Gitlab is on the left, Github in the middle and nbviewer on the right. The rendering within Gitlab is generally good, and in some cases better than Github, but there are still a few glitches, namely:

  • Embedded images have problems rendering and when they do, they appear to show a clipped version of the original.

  • Latex rendering is not working at all.

  • Embedded web-page links are not working ... the nbviewer rendering on the right is correct

GitLab GitHub nbviewer
Embedded Images GL Embedded Images GH Embedded Images nbv
image image image
LaTeX GL LaTeX GH LaTeX nbv
image image image
Embedded webpage GL Embedded webpage GH Embedded webpage nbv
image image image

Release Notes

Jupyter notebooks are documents that contain live code, equations, visualizations, and narrative text. They are widely use for data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and more. They are capable of using "rich output" to show an object's rendered representation, such as HTML, JPEG, SVG, or LaTeX files. However, in order to take advantage of the rich output, users had to open the notebook inside Jupyter.

GitLab 13.8 now shows these files types with "rich output", showing you the rendered version of the file. This is an excellent way both to preview changes to your files as well as consume Jupyter notebook without ever having to leave GitLab.

mockup

Edited by Daniel Gruesso