Live and instant reload of Jinja templates and Python source code without restarting OctoPrint.
During plugin development, I found it slow and frustrating to restarting OctoPrint after every modification.
Install via the bundled Plugin Manager or manually using this URL:
https://github.com/clonesht/OctoPrint-DevHelper/archive/main.zip
- Modify the template files
- Enter a part of the local fs path of the template file you want to reload to the
Part of template file path
field. (eg.dev_helper_sidebar
if you want to reload the~/.octoprint/plugins/dev_helper/templates/dev_helper_sidebar.jinja2
file.) - Hit the
Clear cache
button. - It should display
Done: Cleared template cache: 1
at the bottom of the sidebar widget. - When reloading the page you should see the effect of the modifications immediately.
- Modify .py files
- Enter the module (package) name of the plugin you want to reload. (eg. dev_helper)
- Enter the class name from the module you want to update in the memory. (eg. DevHelperPlugin)
- Hit the
Reload class
button. - It should display
Done: Reloaded object: 1
at the bottom of the sidebar widget. - It will reload the module, then update the class instances function source code with the updated one.
- Note: It won't
__init__
the class instances again, so it's not 100% solution, but should be fine in most cases.
- Create a
~/.octoprint/data/dev_helper/enable_eval
file to enable this feature - Run command from JS console using
res = await OctoPrint.simpleApiCommand("dev_helper", "eval", {"cmd": "dir(self)"})