Skip to content
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

raise error for sidecar or popout when not supported #3309

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

from ipywidgets import widget_serialization
from ipypopout import PopoutButton
from ipypopout.popout_button import get_kernel_id

from jdaviz.components.toolbar_nested import NestedJupyterToolbar
from jdaviz.configs.cubeviz.plugins.viewers import WithSliceIndicator
Expand Down Expand Up @@ -126,6 +127,8 @@ def show_widget(widget, loc, title): # pragma: no cover
display(widget)

elif loc.startswith('sidecar'):
if not get_kernel_id():
Copy link
Member Author

@kecnry kecnry Nov 19, 2024

Choose a reason for hiding this comment

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

@mariobuikhuizen - is this sufficient, or would accessing getBaseUrl() be more appropriate (in which case can that be exposed back to python in ipypopout)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think there is a 1 on 1 mapping of where ipypopout and sidecar work. I think sidecar has different requirements than ipypopout.

Copy link
Member Author

Choose a reason for hiding this comment

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

do you have any suggestions on which conditions to use for each for now then?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know how to detect if sidecar is available.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, then I think this is better than nothing for now and we can always revise the condition going forward 🤷‍♂️

raise RuntimeError(f"loc='{loc}' is not supported. Use loc='inline' or run within a JupyterLab environment.") # noqa
from sidecar import Sidecar

# Use default behavior if loc is exactly 'sidecar', else split anchor from the arg
Expand All @@ -136,6 +139,8 @@ def show_widget(widget, loc, title): # pragma: no cover
display(widget)

elif loc.startswith('popout'):
if not get_kernel_id():
raise RuntimeError(f"loc='{loc}' is not supported. Use loc='inline' or run within a JupyterLab environment.") # noqa
anchor = None if loc == 'popout' else loc.split(':')[1]

# Default behavior (no anchor specified): display popout in new window
Expand Down
Loading