-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add show() method as preferred entrypoint #965
Conversation
Codecov Report
@@ Coverage Diff @@
## main #965 +/- ##
==========================================
- Coverage 85.14% 85.07% -0.08%
==========================================
Files 91 91
Lines 8325 8366 +41
==========================================
+ Hits 7088 7117 +29
- Misses 1237 1249 +12
Continue to review full report at Codecov.
|
I have no objection, as long as viz.app still works, for back-compatibility in published notebooks. |
I have two hesitancies, which don’t necessarily mean you have to leave your hill:
|
@PatrickOgle: Yes! This entirely maintains backwards compatibility. This is just an additional helper method, and as with all helper methods, it provides an additional, more human-accessible, entrpoint to jdaviz functionality
|
@duytnguyendtn - Exactly, the notebook knows to interpret that returned object and display it. I guess my slight issue is that using the "verb" |
For an outside interpreter, I wonder if I can trigger the desktop app to fire with the user's instance of the viz tool. I feel that would adequately answer that usecase. It looks like we might want to add some "environment detection", i.e.:
I'm not sure what to do with |
No objections. I do not see how our current users (even the advanced ones) would complain about this. |
@duytnguyendtn I like that idea, except that the desktop app would need to communicate with the original instance which was likely started without a kernel, so that might be quite difficult to implement in the current infrastructure. For now maybe its worth just detecting if the current session does not support showing and raise an error during |
@kecnry I opted to raise a warning instead and return the app anyways just in case the user has an interactive environment that we don't know about. What do you think? @camipacifici Ooh, I like the idea of |
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 looks good to me, and works.
Need a rebase to resolve conflicts. |
@duytnguyendtn nice to see you got a secret off your chest 😄 You could also use def show(self):
display(self.app) |
ebb7f63
to
557234a
Compare
Moved to draft to address discussion for display modes referenced in #952 (comment) |
ea08b77
to
a654546
Compare
RuntimeWarning) | ||
display(self.app) | ||
|
||
def show_in_sidecar(self, anchor=None, title=None): |
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.
Do we want to deprecate this?
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.
See #965 (comment)
location = 'sidecar' if anchor is None else f"sidecar:{anchor}" | ||
return self.show(loc=location, title=title) | ||
|
||
def show_in_new_tab(self, title=None): |
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.
Do we want to deprecate this?
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.
If we want to deprecate it, shouldn't we through a DeprecationWarning and leave it for a little bit?
…n/jdaviz into closet_of_skeletons
Ok, I think I addressed everything in #965 (review) so long as @pllim is okay with the Deprecation Warning? Since we removed the sidecar return, I also had to remove a lot of the coverage, and I think we're still trying to figure out how to test UI elements so I think the coverage will have to suffer a little bit to get this in. Otherwise, we're good for the final review! |
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 think we're very close. Just a few more comments. 😅
|
||
|
||
def test_show_inline(specviz_helper): | ||
res = specviz_helper.show_inline() | ||
def test_show_popout(specviz_helper): |
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.
Does this test actually exposes a bug here? I thought you wanted "popout" to emit a NotImplementedError
.
Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>
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.
Let's get this in for the release. Thanks!
Hehe... whoops, you beat me to the punch! Hopefully 82c0fe4 passes the tests! So I was going to reply to your comment #965 (comment) that the reason I was trying to catch a RuntimeError is because I chained the exception to explicitly say that there was an error in the displaying; hence I wrap the original error with a generic RuntimeError with a more user friendly explanation. |
But that got me thinking the test should check for the chained NotImplementedError so I pushed I do have duytnguyendtn@aa658ea which changes that test to check for that chained NotImplementedError. Didn't quite make it to the merge. Did we want to merge that to resolve #965 (comment)? |
Oh, ooops. Would you mind opening a follow-up PR then? If you want to change the kind of exception that is actually raised, should get it in before the release. |
On it! |
p.s. Looking at your diff, I think it might be clearer to have those that raise |
Description
Backstory
Ok I'm going to finally admit to a nearly 18 month secret I've been hiding since I originally wrote the first helper for specviz. I've always had negative opinions about
viz.app
. I feel like it's not intuitive and not apparent to a brand new user, and almost forces them to read the documentation first before even trying to take it for a spin (which I imagine some may see as a good thing, but I'm going to argue I don't have to read Chrome's documentation when I launch it!). So I addedspecviz.show()
as a wrapper to thespecviz.app
call:jdaviz/jdaviz/configs/specviz/helper.py
Lines 200 to 201 in 392e1b6
Here's the secret... it doesn't work. It never worked. I struggled for SO LONG at the time but I couldn't fix it; I just didn't understand what front-end wizardry made
viz.app
work.. So... I kept my mouth shut because I felt so strongly it should be there, and swore one day I would fix it. You can even see how old this is because it's only in the Specviz helper, and not in the base helper class; this was before I even wrote the base helper class, and the only helper we had was Specviz!With @eteq's introduction of #952, I now further think this should be the way to show our viz tools, because a helper method would allow us to add options and arguments to a SINGLE entry point, rather than separate helpers for each launching mode (i.e.
viz.show(mode=sidecar)
,viz.show(new_tab=True)
rather than separateviz.show_in_new_tab()
andviz.show_in_sidecar()
In my review of #952, I had a real bruhhh moment. The reason why it never worked was because I never returned the app...
... They say the mistakes of the past show how much you've grown. As an optimist, I choose to view it through this lens 😅 I'm legitimately giddy seeing this PR finally in fruition. Now I can finally put this issue to rest...
As a warning, I WILL die on top of this hill!! BYOP (Bring Your Own Pitchforks!)
tl;dr What actually changed??
This PR adds
viz.show()
as a helper method to the base ConfigHelper class, and updates all notebooks and documentation to showviz.show()
rather thanviz.app
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.CHANGES.rst
?