-
Notifications
You must be signed in to change notification settings - Fork 76
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
Context-aware plugin relevancy #2711
Conversation
Would this also be useful for downstream to configure their own setup like in #2696 ? |
Sure, I wasn't planning to make this public API (since once you make it irrelevant, there is no longer public API access), but the code snippet I put in the issue would definitely be simplified by this without having to do a list comprehension. Something like:
|
* removes from the tray * replaces content with a message in any existing (non-tray) instances
5500f47
to
9edd445
Compare
Re-opening this for consideration now that we'll need this downstream for lcviz soon and also would be useful for dev work on the DQ plugin. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2711 +/- ##
==========================================
+ Coverage 88.67% 88.70% +0.03%
==========================================
Files 108 108
Lines 16266 16305 +39
==========================================
+ Hits 14424 14464 +40
+ Misses 1842 1841 -1 ☔ View full report in Codecov by Sentry. |
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#plugin-name'" | ||
description='Plugin description.' | ||
:link="'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#plugin-name'" | ||
:irrelevant_msg="irrelevant_msg" |
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.
Maybe add explanation on when devs should consider something "irrelevant" or not. Do we still need "disabled" then? What are the differences when devs decide which one to use?
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 distinction with disabled is meaningful. "irrelevant" extends upon the “disabled” plugin feature, which marks a plugin as disabled with a message in the UI, but does not “remove” it from the plugin tray or API. "irrelevant" additionally removes plugins from the UI and public API. The plugin won’t be visible in viz.plugins. But if you already assigned the plugin user API to a variable, that will still work.
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.
So once it is marked as irrelevant, can it become relevant again later in the same session? I think this was discussed before but I don't remember and none of those discussions are documented in the diff.
Is the only use for this to hide a WIP 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.
Is the only use for this to hide a WIP plugin?
It can have more general uses. We could also use it to put plugins away depending on the state of the app or viewer.
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 is a traitlet, so we can respond to anything we want to toggle its "relevancy", yes. Disabled leaves the plugin in the tray but just replaces the UI with a message (which is useful for cases where you want to tell the user WHY something disappeared). Imagine merging specviz and cubeviz, its obvious that the slice plugin is irrelevant without cube data, but hiding spectral analysis because of a unit conversion switch probably deserves showing a message. We can clarify a pattern for when to use each as they are used more often - and the under-the-hood implementation is very similar, so should be easy to migrate from one to the other when warranted.
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'm not really sure where to document this in the docs and I think it'll be a bit liquid for a while until we get a clear idea of how we want to use this... for now, there at least is a good papertrail in this discussion - and the PR description, so thanks for brining it up)
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.
Can we clarify the pattern now as you envisioned and clean it up later? We cannot guarantee new devs would be able to dig up this conversation here. A few sentences in the dev docs at least would be searchable in RTD.
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.
ok, done
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 enough that I can't find a comment that is_relevant
.
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! I guess we can clean this up if we find bugs when actually trying to use it.
Description
This pull request implements infrastructure for plugins to determine when they are relevant/irrelevant based on the state of the application as a whole (data, viewers, units, etc). When a plugin determines itself to be irrelevant, then:
viz.plugins
This is distinct from the existing "disabled" capabilities which only replaces the content with a message, but leaves the plugin in the list of options. There are cases where that might be less intrusive (change in units, etc), whereas this is designed more for the use-case of a more freeform configuration. For example: lcviz should only show the slice plugin if there is cube-like data (and this could then allow us to consider merging cubeviz, specviz2d, and specviz down the road).
Change log entry
CHANGES.rst
? If you want to avoid merge conflicts,list the proposed change log here for review and add to
CHANGES.rst
before merge. If no, maintainershould add a
no-changelog-entry-needed
label.Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
trivial
label.