-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
Npe2 enable/disable support #4086
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.
Thanks!
One question - what determines the initial enable/disable status? napari_svg
was disabled the first time I spun this up and I'm not sure why. It made me wonder about the interaction with settings.
this is an unfortunate consequence of the workaround we previously used, wherein we "set to blocked" all plugins that came from npe2, so that npe1 didn't detect them. Our persistence layer doesn't discriminate, and happily saved that preference. This PR contains a better way to skip npe2 plugin discovery by the npe1 plugin engine, but we'll have to figure out how to deal with that previous decision now |
Previously no one could disable their npe2 plugins so the very first time we come across them they should be enabled. We just need a way of detecting and migrating the plugin settings forward. It requires some thought but seems doable? |
napari/plugins/__init__.py
Outdated
_from_npe2.add('napari') | ||
plugin_manager._skip_packages = _from_npe2 | ||
|
||
settings.disabled_plugins = settings.disabled_plugins.difference( |
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.
@nclack, this seems to be working now. before I push on, would be good to get your thoughts. this adds a new disabled_plugins_npe2
field to the settings, and will basically just always remove a field from disabled_plugins
if it is detected to be an npe2 plugin on this line here. (but will not modify anything it finds in settings.disabled_plugins_npe2
). so basically, the first time a plugin transitions to npe2, it will be re-enabled until they disable it again as an npe2 plugin
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.
This works but is there a way to avoid having two disabled_plugins
fields? It looks like you needed to keep two separate lists for the two plugin engines here. Is that right?
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.
yeah, that's what I ended up using. If you can think of a way to keep a single field, that'd be great! :) but it wasn't clear to me how we would determine whether something we found in that one list was an npe2
plugin that someone had intended to disable, or an npe2
plugin that had ended up in that list as a side effect of not wanting the npe1 plugin manager to pay attention to it
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.
(I guess we could encode it in the string itself (napari-svg[npe2]
... but it feels like we'd need to deal with that in a lot of places... forever 😂)
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.
@nclack have another look now. After our chat, seemed like the main way to accomplish this was to introduce the concept of migrations (in this case, a migration would just remove any npe2 plugins from the set of disabled_plugins
). Would appreciate a somewhat close look here to make sure I'm on the right track, and happy to zoom about it again
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.
looks good to me. I love the way migrations are done. There should probably be a test though.
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.
We discussed this in the plugin working group. I think this is fine but we may want to follow up to address backward migrations. Migrations aren't really the point of this pr - the approach here is a good start.
I tested running main
after upgrading the settings w this branch. It predictably complains the first time - the message is printed to console, not an exception.
> napari -vv Validation errors in config file(s).
The following fields have been reset to the default value:
schema_version
value is not a valid tuple (type=type_error.tuple)
Second run there's no message. I think this is acceptable. It works for the problem addressed here, but more complicated migrations will need a proper undo step imo.
Codecov Report
@@ Coverage Diff @@
## main #4086 +/- ##
========================================
Coverage 84.13% 84.13%
========================================
Files 596 598 +2
Lines 49648 49822 +174
========================================
+ Hits 41770 41918 +148
- Misses 7878 7904 +26
Continue to review full report at Codecov.
|
@sofroniewn and @jni, just wanted to draw your attention to one of the things being added in this PR, and that is the "new migration logic" mentioned in the original post (this file). It's minimal at this point, but it provides a mechanism for us to update/migrate the napari |
otherwise, this PR is ready to go, and is required for #4015 |
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.
LGTM, let's get this in - feel free to merge when ready @tlambert03 or i'll merge it tomorrow if still open
exciting!! |
Description
companion PR to napari/npe2#101
turns the enable/disable checkbox back on for npe2 plugins. (will require the next version of npe2)
This PR includes:
plugins/__init__
(to no longer "disabled" npe2 plugins)plugins/_plugin_manager.py
Version
class (pretty much vendored from npe2), could potentially depend on that later and remove here)Type of change
References
How has this been tested?
Final checklist:
trans.
to make them localizable.For more information see our translations guide.