I have used
for several years now with great success and 🔥 rapid reloads. It allows me to move super fast when developing libraries and modules. They have made some great updates this year that allows class modules to be automatically be updated.
🔥 Blazing Fast
💥 Keeps me in the comfort of my text editor
👏 Allows me to use Jupyter when I need
👟 Extremely Reliable
One of the biggest benefits that I find is that it shortens the distance between my module/library code and test code inside of a terminal/notebook. Now I primarily use jupyter notebooks for the presentation aspect. I develop code from the comfort of my editor with all of the tools I have setup, and run the functions in a notebook to get the output. From there I might do some aggregations or plots, but the 🥩 meat of development is done outside of jupyter.
Now I primarily use jupyter notebooks for the presentation aspect.
This is a short script that I use to setup ipython so that it automatically reloads modules. This allows me to use a separate terminal and editor, and keep data in memory while developing functions.
ipython profile create
Then edit the created file
c.InteractiveShellApp.extensions = ['autoreload'] c.InteractiveShellApp.exec_lines = ['%autoreload 2'] c.InteractiveShellApp.exec_lines.append('print("Warning: disable autoreload in ipython_config.py to improve performance.")')
Some of the known remaining caveats are:
Replacing code objects does not always succeed: changing a @property in a class to an ordinary method or a method to a member variable can cause problems (but in old objects only). Functions that are removed (eg. via monkey-patching) from a module before it is reloaded are not upgraded. C extension modules cannot be reloaded, and so cannot be autoreloaded.
🤲 Nearly everything...
- new/updated functions
- new/updated functions
- new/updated class methods
- new/updated class attributes
🔄 needs restart
config files that are side loaded with modules typically do not get updated in my experience, and I tend to restart the session.
init class methods do not get reran, but the session does not need to be reloaded. The class instance will just need to be re-instanciated.
💨 Watch it go
Here is a gif of me taking autoreload out for a test drive. When creating the session test_autoreload.py does not even exist. From there new functions, classes, attributes, and methods are added in the file and all live reload into ipython.
💥 Exactly the Same
Since jupyter uses ipython in be background Jupyter will use the same
file to have autoreload enabled by default.
Take the splash into rapid development of python functions with minimal distance between your modules/library and your ipython/jupyter session.
This article covers how I setup automatic imports in ipython