How to reset a Jupyter notebook(to resolve kernel crashes)

Symptoms

You are unable to work on a Jupyter notebook during a session after running a code cell. All other notebooks you are connected to are also unresponsive.

Cause

Loading too much data to a Jupyter notebook during a session(e.g. by printing 5000 rows in your notebook) can cause the notebook to refuse to open as well as make other notebooks unresponsive. If you can't even right click in your notebook, congrats, you just did it :D.

Attempting to open such a notebook often causes the kernel of your Jupyter server to become unavailable preventing you from being able to work on your other notebooks.

Solution

You need to clear the Jupyter notebook of all its code cell results. To do this, do the following

  1. Open a new browser session to Europa.
  2. Start a terminal session
Starting a terminal session

3. Examine the URL of the notebook that is causing the kernel's issue to figure out it's path. For the notebook URL in the picture below, the path is R-Programming/Day1/labs/L5_DataVisualization.ipynb

4. Run the nbclean script(/dsa/scripts/nbclean.py) and specify the path to the notebook that has the problem. This clears all code cell outputs in the notebook so you can resume your work. You'll need to run all code cells again to get the outputs computed.

Clearing the code cell outputs

Finally, note what code cell you ran that caused the issue and reduce the amount of data sent to the notebook. Use head() or tail() instead.

TLDR: Run /dsa/scripts/nbclean.py with the path to the offending notebook to clear all code cell outputs when you cause your jupyter server to become unresponsive