Live online slides with SageMath, Jupyter notebooks, RISE and Binder

Scenario

Viviane is writing slides for a talk; she would like to include live SageMath computations in her slides. She also would like to publish her slides online, letting anyone – during and after her talk – browse the slides and play around with the provided examples.

Note: most of this blog can be adapted for any other computational system that can be run in Jupyter like, for mathematics, GAP, Pari/GP, or Singular.

Some instances

Suggestion of solution

We will use the above slides from the repository https://github.com/nthiery/harmonic-modules as running example.

Components involved

Installation

Install Jupyter’s RISE extension in Sage. From the terminal:

sage -pip install RISE
echo "jupyter-nbextension install rise --py --sys-prefix" | sage -sh
echo "jupyter-nbextension enable rise --py --sys-prefix"  | sage -sh

Notes:

Authoring and showing slides

Open the Jupyter notebook that you want to turn into slides – or create a new one – ; we will assume it’s called talk.ipynb. Activate the Slideshow metadata:

View -> Cell Toolbar -> Slideshow

Choose the role each cell should play: for example start a new slide (Slide), add a fragment to the current slide (Fragment), or don’t show up (Note).

Activate the slideshow by clicking in the corresponding button in the toolbar.

For further details on authoring, showing, and configuring the slideshow, see the RISE documentation.

Publishing the slides on a web page

This assumes that you have access on a web server to publish HTML files that embed javascript.

The slides can be converted to static HTML pages with embedded javascript with:

jupyter nbconvert talk.ipynb --to slides

The produced file talk.slides.html can then be copied to the web server. Readers will be able to see and navigate the slides; however they won’t be able to modify and run the examples.

Publishing live slides on Binder

Add the notebook to a public git repository, for example on github.

Add metadata to that git repository to specify the software required to run the computations. For SageMath, you can add the following Dockerfile at the root of the repository.

Go to mybinder.org, specify the address of the git repository (here https://github.com/nthiery/harmonic-modules/ ) and the name of the file (here talk.ipynb`). Click launch, and voilà!

You can get from the binder page a URL to access directly the live slides.

Note: the SageMath docker image is relatively big. Therefore the first times the slides are accessed, or if it has not been accessed in a while, Binder will typically take a couple minutes to launch: it indeed needs to fetch the base SageMath image, build the new image containing the Jupyter extensions and the notebook, and then copy this image around between it’s various machines (that building the image, that storing them, and those running them).

Alternatives

Instead of publishing on Binder, one may author the slides on cocalc, and use its publish feature. (TODO: double check that RISE works on cocalc).

Instead of using a Jupyter notebook, one may author in HTML (or some format that can be converted to HTML), and use ThebeLab or [SageCell][http://sagecell.sagemath.org/]to enable live computations.

Advantages and drawbacks

Traditionally, most mathematicians author their slides using LaTeX+Beamer, and display and publish them in PDF format.

To do

Time and expertise required

Assuming Viviane is familiar with Jupyter, writing her first slides using RISE will take a few minutes and mastering it a few hours.

Assuming Viviane is familiar with version control and Jupyter (basic lab skills taught at Software Carpentry, and the required software required is packaged (conda, debian, docker container, …), the publishing part could take two hours the first time, and minutes later on (typically by having a preconfigured repository where one stores all of one’s presentations)..

What’s new since OpenDreamKit started

OpenDreamKit contribution

SageMath Jupyter Front Page Open Science and Reproducibility Binder Use Cases Reproducibility Best Practice

<