Skip to content

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

lukasz-migas
Copy link

@lukasz-migas lukasz-migas commented Jun 12, 2025

References and relevant issues

Documentation update to add information about upcoming hot-reload functionality to napari.
Depends on napari/napari#8007

Description

  • add documentation about what hot reloading is.
  • add information how it can be activated in napari
  • show a couple of exmaples

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jun 12, 2025
Copy link
Member

@psobolewskiPhD psobolewskiPhD left a 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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@TimMonko TimMonko added the highlight highlight this PR in release notes label Jun 25, 2025
Copy link
Contributor

@willingc willingc left a 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:

Comment on lines +11 to +14
* 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation highlight highlight this PR in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants