-
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
plugin is_active skip_if_no_updates_since_plugin_last_active decorator #2386
Conversation
9cfd0d1
to
d77f932
Compare
* more general implementation of spacetelescope#2326 and then applied across other plugins
d77f932
to
a828626
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #2386 +/- ##
==========================================
- Coverage 90.61% 90.52% -0.10%
==========================================
Files 159 159
Lines 18177 18215 +38
==========================================
+ Hits 16471 16489 +18
- Misses 1706 1726 +20
☔ View full report in Codecov by Sentry. |
# toggles before any *other* messages are received) | ||
ret_ = meth(self, msg) | ||
if meth.__name__ not in self._methods_skip_since_last_active: | ||
self._methods_skip_since_last_active.append(meth.__name__) |
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.
Should this append happen before meth(...)
is invoked, in case it is an intensive method that takes a long time?
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.
that's a good idea.... my only concern is what happens if there is an exception in meth(...)
. But maybe we could wrap meth(...)
in a try/except to remove from the list if it fails (and then raise the original error)? I'll think if there would be any unintended consequences of that, but I can see how otherwise this could still technically result in a (small, but unnecessary) queue of calls.
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 it didn't crash but I did find this using the Specviz2D example notebook. Load the data, open the Spectral Extraction plugin, then run this:
plg = specviz2d.plugins["Spectral Extraction"]
for i in range(5):
plg.bg_width = i
When it completes, the GUI shows width at 4, which is correct. But the markers disappear. They come back if you manually adjust the width to 5 and back to 4.
Not sure if this is something we have to worry about but it is technically public API.
I thought I picked up your commit 1508970 but rebased on latest |
it seemed to have fixed the problem on my end, but let me try to see if I can find another way to reproduce (we may need something like your suggestion above after all). |
I dunno if any small lag is greatly magnified on Windows or something. If you or another dev have access to Windows machine, please try it out there. I want to make sure it is not just me. |
But if this is OS specific, maybe we can open up a follow up issue and defer it. It is uncommon for someone to set such parameters non-stop in a loop, right? |
* so toggling visibilities, etc, logic aren't affected
e8ee042
to
3af058f
Compare
@pllim - I think (hope) this should be much more reliable now. I really went through and refactored quite a few of the methods in spectral extraction so only the expensive extracting step follows this decorator, so that the other "active step" stuff is not affected. |
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 didn't manage to break anything, tested all the plugins that this touches. I think this is good to go in. I think I even mostly understand what it's doing 😅
Let me try one more time on Windows, but I need to review the Footprint one first. |
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 previous problem is gone for me. Thanks!
* was replaced with skip_if_no_updates_since_last_active decorator in spacetelescope#2386
* was replaced with skip_if_no_updates_since_last_active decorator in spacetelescope#2386
including retroactive changelog for spacetelescope#2386 which this builds on
including retroactive changelog for spacetelescope#2386 which this builds on
Description
This pull request implements (and uses) a
@skip_if_no_updates_since_plugin_last_active
decorator for plugin methods that observeis_active
(among other traitlets) to avoid queuing of expensive calls that can result in laggy behavior when browser throttle the pings resulting in constant toggling ofis_active
. This is essentially a more generic implementation of the same principal as #2326 and then applied to all plugins which currently useis_active
.Currently this only needs to be updated from the flattening plugin in lcviz: spacetelescope/lcviz#38, and eventually the binning plugin (unmerged).
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.