-
Notifications
You must be signed in to change notification settings - Fork 44
Add hot reload #731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add hot reload #731
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clear and comprehensive, thank you!
I made a few minor suggestions and updated the PR description to depend on the merging of the napari PR.
|
||
## How to enable hot reloading | ||
|
||
Hot relaoding is enabled when napari is launched in **developer mode**. You can activate developer mode in one of two ways: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hot relaoding is enabled when napari is launched in **developer mode**. You can activate developer mode in one of two ways: | |
Hot reloading is enabled when napari is launched in **developer mode**. You can activate developer mode in one of two ways: |
|
||
## Hot reloading your plugin | ||
|
||
By default, hot reloading only applies to the napari core libraries (napari and napari-builtins). IF you're working on a plugin and want your changes. to reload as well, you'll need to explicitly include it when launching napari. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, hot reloading only applies to the napari core libraries (napari and napari-builtins). IF you're working on a plugin and want your changes. to reload as well, you'll need to explicitly include it when launching napari. | |
By default, hot reloading only applies to the napari core libraries (napari and napari-builtins). If you're working on a plugin and want your changes to hot reload as well, you'll need to explicitly include your plugin when launching napari. |
|
||
## How it works | ||
|
||
The `qtreload` system monitors changes to registered modules and reloads them using Python’s import machinery. It watches for changes to the `.py` and `.qss`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The `qtreload` system monitors changes to registered modules and reloads them using Python’s import machinery. It watches for changes to the `.py` and `.qss`. | |
The `qtreload` system monitors changes to registered modules and reloads them using Python’s import machinery. It watches for changes to `.py` and `.qss` files. |
* If you've **added** a new property, that property will be added to the class/object. | ||
* If you've **edited** a property, that change might not be reflected | ||
* If you've **edited** UI, that change will only take effect if you close and reopen the widget that was changed (so main windows will not be changed but if you edit a container for a layer type and then remove and add that layer, the change **will** be reflected) | ||
* code within the `__init__.py` file cannot be reloaded (sorry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* code within the `__init__.py` file cannot be reloaded (sorry) | |
* code within the `__init__.py` file cannot be reloaded |
* If you've **edited** a property, that change might not be reflected | ||
* If you've **edited** UI, that change will only take effect if you close and reopen the widget that was changed (so main windows will not be changed but if you edit a container for a layer type and then remove and add that layer, the change **will** be reflected) | ||
* code within the `__init__.py` file cannot be reloaded (sorry) | ||
* new files are not actively watched - you can manually reload the list of files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* new files are not actively watched - you can manually reload the list of files | |
* new files are not actively watched---you can manually reload the list of files |
* code within the `__init__.py` file cannot be reloaded (sorry) | ||
* new files are not actively watched - you can manually reload the list of files | ||
|
||
When `.qss` file changes, it emits an event which is handled by the application - in napari's case, it simply reloads the stylesheet and applies it to the entire application. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When `.qss` file changes, it emits an event which is handled by the application - in napari's case, it simply reloads the stylesheet and applies it to the entire application. | |
When `.qss` file changes, it emits an event which is handled by the application. In the case of napari, it simply reloads the stylesheet and applies it to the entire application. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lukasz-migas. A few suggestions on wording for readability.
|
||
# Hot reloading in development mode | ||
|
||
When working on napari itself or developing plugins, manually restarting the application after every code change can quickly become tedious. To speed up the development cycle, napari supports **hot-reloading**, allowing you to reload code changes on the fly without closing and reopening the app. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When working on napari itself or developing plugins, manually restarting the application after every code change can quickly become tedious. To speed up the development cycle, napari supports **hot-reloading**, allowing you to reload code changes on the fly without closing and reopening the app. | |
When working on napari or developing plugins, manually restarting the application after every code change can quickly become tedious. To speed up the development cycle, napari supports **hot-reloading** code changes without closing and reopening the app. |
|
||
## What is hot reloading? | ||
|
||
Hot reloading enables napari to automatically reload Python modules during runtime, making development significantly more efficient. With this feature enabled, you can: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hot reloading enables napari to automatically reload Python modules during runtime, making development significantly more efficient. With this feature enabled, you can: | |
Hot reloading automatically reloads Python modules during runtime, making napari development significantly more efficient. With this feature enabled, you can: |
* Make changes to the napari or napari-builtins source code | ||
* Or make changes to **your** plugin source code (use `--dev_module YOUR_PLUGIN_NAME` to add to list of watched modules) | ||
* Instantly see those changes reflected in the running app | ||
* Avoid repetitive app restarts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Make changes to the napari or napari-builtins source code | |
* Or make changes to **your** plugin source code (use `--dev_module YOUR_PLUGIN_NAME` to add to list of watched modules) | |
* Instantly see those changes reflected in the running app | |
* Avoid repetitive app restarts | |
* Make changes to the napari or napari-builtins source code | |
* Make changes to **your** plugin source code (use `--dev_module YOUR_PLUGIN_NAME` to add to list of watched modules) | |
* See changes reflected instantly in the running app | |
* Avoid repetitive, manual app restarts |
References and relevant issues
Documentation update to add information about upcoming
hot-reload
functionality to napari.Depends on napari/napari#8007
Description