Skip to content

Viewing IPython notebooks in GitLab

Created by: martijnvermaat

Dear GitLab maintainers,

With this pull request I intend to get some feedback on extending GitLab with live inline rendering of IPython Notebooks.

Introduction and rationale

The IPython Notebook is a web-based interactive environment for editing documents containing both executable code and rich text. The platform is becoming increasingly popular in the scientific community amongst others.

These documents are serialized as JSON and can be converted to HTML, PDF, and other formats using the IPython nbconvert tool. Static HTML renderings can also be shared over the web using the IPython Notebook Viewer and indeed this is quite popular for viewing notebooks stored in GitHub.

However, due to GitLab's focus being more on repositories with controlled access, it is not possible to use the IPython Notebook Viewer service with notebooks stored in GitLab. Even if it were possible, this would bring unwanted security issues since everything on the Notebook Viewer is public.

Implementation

This pull request is an ad-hoc implementation of live inline rendering of notebooks in GitLab. Clicking a notebook file in the GitLab web interface will convert the notebook to HTML using the IPython nbconvert tool and include it in the GitLab blob view as a base64 encoded data URI for an IFrame. The obvious benefit here is that everything happens inside the GitLab access controlled view of the blob.

You can find some more documentation on the patch here.

Since this is only a proof-of-concept, I can point out some obvious areas for improvement:

  • Somehow cache the nbconvert results.
  • Test (and presumably fix) files (in the same repository) linked from the notebook.
  • Add unit tests.

Request for feedback

I think this would be a great feature for IPython Notebook and GitLab users and it would give GitLab a clear advantage over GitHub for hosting IPython Notebook, especially in private repositories.

Are you interested in a feature like this? If so, let's discuss necessary improvements. If not, I'll try to keep my own branch up-to-date (and still welcome any feedback!).

Merge request reports

Loading