(Re)Execute a Jupyter (colab) notebook cell programmatically by searching for its label.
Note 1: I added the "Re" because the cell needs to be executed at least once as this library is not using the ipynb notebook file, but the interpreter to find the cells and it will work even if the cell was not saved in the notebook file.
Note 2: From version 5.0, Jupyter notebooks can have a tag that could be used to execute specific cells reading the ipynb file or using Javascript inside a notebook. The tag embedded in the notebook file is very useful when using Voila as it is based on the nbconvert. However, ExecThatCell still works using pure IPython. Additionally, Voila will not have any problems with ExecThatCell either, as long as the user remembers the cells will be executed following the order according to how they appear in the notebook file.
Installation (Python3 because you should not use Python2 anymore):
Option #1: Clone the repo so you will get everything
$ git clone https://github.com/ricardodeazambuja/ExecThatCell.git
$ cd ExecThatCell
$ sudo pip3 install .
Option #2: Install directly from git
$ sudo pip3 install git+git://github.com/ricardodeazambuja/ExecThatCell
See the Example.ipynb.
It also works with the IPython interpreter (you know, when you use it directly from a command line without Jupyter). However, to add a label to a cell you need to add a linefeed after it and that means pressing Ctrl+q followed by Ctrl+j.
In the case you just want to execute again a cell that you know the index (the number inside the square brackets after "In"), you could just do something like this (Jupyter notebook, Google Colab or IPython command line version):
i = 10 # the cell index you want to execute again
exec(In[i])
- Test it :D
- colab_utils: Some useful (or not so much) Python stuff for Google Colab notebooks
- Maple-Syrup-Pi-Camera: Low power('ish) AIoT smart camera (3D printed) based on the Raspberry Pi Zero W and Google Coral EdgeTPU
- The CogniFly Project: Open-source autonomous flying robots robust to collisions and smart enough to do something interesting!
- Bee: The Bee simulator is an open source Spiking Neural Network (SNN) simulator, freely available, specialised in Liquid State Machine (LSM) systems with its core functions fully implemented in C.