I’ve just release a new Jupyter Lab extension called autoplay, it runs all the cells of a notebook and hides its code when opening it. In this post I will explain how to install and use it.
This extension is for Jupyter Lab 2. You can install it running
jupyter labextension install jupyterlab-autoplay.
How to use
Here is a short video of how the extension works:
The extension runs automatically when opening a notebook. To configure a notebook:
- Open a create a new notebook
- Setup the notebook for the extension, use the Jupyter Lab command
Set notebook autorun config
A dialog will open and ask you what action should be performed when opening the notebook. Check both options and confirm.
- This will edit the notebook’s metadata so you will need to save it to store the configuration.
- You can now close the notebook and re-open it to see it being run automatically.
Work with a configured notebook
If you need to edit a notebook that has ran, you can show all the hidden cells by clicking on
Show code cells. This won’t affect the notebook settings so no need to go through the configuration again. You can then edit the code, add new cells, etc.
Be careful if you’re using this extension, malicious code could be ran and hidden automatically, so make sure you know that your users are not going to open any dodgy notebook…