Monday, February 3, 2020

Getting new copies of Jupyter notebooks with shutil and nbgitpuller

Getting a Fresh Set of Jupyter Notebooks

If you would like to update your copy of notebooks, for example on the Callysto Hub, you can delete the folder and pull the files from GitHub again. This is useful if something no longer works, or if the repository has been updated.

Unfortunately you can’t just select a directory in Jupyter hub and delete it if it contains files. One way to delete a folder, though, is to use the Python command shutil.rmtree() which is a shell utility command that will remove a whole directory tree.

To remove a folder, create a new Python 3 notebook in the same folder as the one you want to delete (but not inside the folder to be deleted).



In a code cell, type (or paste) the following two lines:

import shutil
shutil.rmtree('curriculum-notebooks')

Replace curriculum-notebooks with the name of the folder you would like to delete. Then run the cell, and you should see that the folder no longer exists.



Then you can click on an nbgitpuller link, for example from callysto.ca, that pulls down a new copy of the repository or notebook files that you are interested in.

You can also see the process in this video.