From 62da83d8a8875bdbea22a8d9e5f422940cbc7385 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Thu, 19 Feb 2026 10:45:21 -0500 Subject: [PATCH 1/7] Check property existence, rather than type, when creating 3D viewer traces. --- glue_plotly/common/base_3d.py | 23 +++++++++-------------- glue_plotly/common/scatter3d.py | 18 +++++++++--------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/glue_plotly/common/base_3d.py b/glue_plotly/common/base_3d.py index b2b6749..36a2a4b 100644 --- a/glue_plotly/common/base_3d.py +++ b/glue_plotly/common/base_3d.py @@ -1,4 +1,5 @@ import re +from contextlib import suppress from glue.config import settings from glue_plotly.common import DEFAULT_FONT @@ -29,21 +30,15 @@ def projection_type(viewer_state): def get_resolution(viewer_state): - try: - from glue_vispy_viewers.volume.viewer_state import Vispy3DVolumeViewerState - if isinstance(viewer_state, Vispy3DVolumeViewerState): - return viewer_state.resolution - except ImportError: - pass - - try: - from glue_jupyter.common.state3d import VolumeViewerState - if isinstance(viewer_state, VolumeViewerState): - resolutions = tuple(getattr(state, "max_resolution", None) + resolution = getattr(viewer_state, "resolution", None) + if resolution is not None: + return resolution + + resolutions = tuple(getattr(state, "max_resolution", None) for state in viewer_state.layers) - return max((res for res in resolutions if res is not None), default=256) - except ImportError: - pass + + with suppress(ValueError): + return max((res for res in resolutions if res is not None), default=256) return 256 diff --git a/glue_plotly/common/scatter3d.py b/glue_plotly/common/scatter3d.py index 5dd947d..718160a 100644 --- a/glue_plotly/common/scatter3d.py +++ b/glue_plotly/common/scatter3d.py @@ -10,11 +10,6 @@ from glue_plotly.common import color_info, sanitize from glue_plotly.common.base_3d import bbox_mask -try: - from glue_vispy_viewers.scatter.layer_state import ScatterLayerState -except ImportError: - ScatterLayerState = type(None) - def size_info(layer_state, mask, size_att="size_attribute"): @@ -123,10 +118,15 @@ def traces_for_layer(viewer_state, layer_state, hover_data=None, add_data_label= y = layer_state.layer[viewer_state.y_att] z = layer_state.layer[viewer_state.z_att] - vispy_layer_state = isinstance(layer_state, ScatterLayerState) - cmap_mode_attr = "color_mode" if vispy_layer_state else "cmap_mode" - cmap_attr = "cmap_attribute" if vispy_layer_state else "cmap_att" - size_attr = "size_attribute" if vispy_layer_state else "size_att" + cmap_mode_attr = "color_mode" \ + if hasattr(layer_state, "color_mode") \ + else "cmap_mode" + cmap_attr = "cmap_attribute" \ + if hasattr(layer_state, "cmap_attribute") \ + else "cmap_att" + size_attr = "size_attribute" \ + if hasattr(layer_state, "size_attribute") \ + else "size_att" arrs = [x, y, z] if getattr(layer_state, cmap_mode_attr) == "Linear": cvals = layer_state.layer[getattr(layer_state, cmap_attr)].copy() From c4637fe4122574ca7b50af4a24aab617bfd0f31a Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Sat, 21 Feb 2026 02:41:28 -0500 Subject: [PATCH 2/7] Update requirements in test environments. --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 6cae707..a876571 100644 --- a/tox.ini +++ b/tox.ini @@ -19,9 +19,9 @@ extras = all: jupyter all: 3d commands = - glue118: pip install glue-core==1.18.* glue-jupyter<=0.20.1 - glue119: pip install glue-core==1.19.* glue-jupyter<=0.20.1 - glue120: pip install glue-core==1.20.* glue-jupyter<=0.20.1 + glue118: pip install glue-core==1.18.* glue-jupyter<=0.20.1 glue-qt<=0.4 + glue119: pip install glue-core==1.19.* glue-jupyter<=0.20.1 glue-qt<=0.4 + glue120: pip install glue-core==1.20.* glue-jupyter<=0.20.1 glue-qt<=0.4 glue121: pip install glue-core==1.21.* glue122: pip install glue-core==1.22.* plotly5: pip install plotly~=5.24 From e87c563fc6b1375390b07cf7532139f213f7847b Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Mon, 23 Feb 2026 10:30:31 -0500 Subject: [PATCH 3/7] More updates to test environment requirements. --- tox.ini | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tox.ini b/tox.ini index a876571..ca9f19d 100644 --- a/tox.ini +++ b/tox.ini @@ -19,11 +19,11 @@ extras = all: jupyter all: 3d commands = - glue118: pip install glue-core==1.18.* glue-jupyter<=0.20.1 glue-qt<=0.4 - glue119: pip install glue-core==1.19.* glue-jupyter<=0.20.1 glue-qt<=0.4 - glue120: pip install glue-core==1.20.* glue-jupyter<=0.20.1 glue-qt<=0.4 - glue121: pip install glue-core==1.21.* - glue122: pip install glue-core==1.22.* + glue118: pip install glue-core==1.18.* glue-jupyter<=0.20.1 glue-qt<=0.4 setuptools==81 + glue119: pip install glue-core==1.19.* glue-jupyter<=0.20.1 glue-qt<=0.4 setuptools==81 + glue120: pip install glue-core==1.20.* glue-jupyter<=0.20.1 glue-qt<=0.4 setuptools==81 + glue121: pip install glue-core==1.21.* glue-qt<=0.4 setuptools==81 + glue122: pip install glue-core==1.22.* glue-qt<=0.4 setuptools==81 plotly5: pip install plotly~=5.24 plotly6: pip install plotly>=6 test: pip freeze From 44c52b37fb687cde68c8005242343059c34e7938 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Mon, 23 Feb 2026 10:40:28 -0500 Subject: [PATCH 4/7] More testing version updates. --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index ca9f19d..61fafc5 100644 --- a/tox.ini +++ b/tox.ini @@ -22,8 +22,8 @@ commands = glue118: pip install glue-core==1.18.* glue-jupyter<=0.20.1 glue-qt<=0.4 setuptools==81 glue119: pip install glue-core==1.19.* glue-jupyter<=0.20.1 glue-qt<=0.4 setuptools==81 glue120: pip install glue-core==1.20.* glue-jupyter<=0.20.1 glue-qt<=0.4 setuptools==81 - glue121: pip install glue-core==1.21.* glue-qt<=0.4 setuptools==81 - glue122: pip install glue-core==1.22.* glue-qt<=0.4 setuptools==81 + glue121: pip install glue-core==1.21.* glue-qt<=0.4 glue-jupyter<0.26 setuptools==81 + glue122: pip install glue-core==1.22.* glue-qt<=0.4 glue-jupyter<0.26 setuptools==81 plotly5: pip install plotly~=5.24 plotly6: pip install plotly>=6 test: pip freeze From e71bc89efcd905a2683b7848f643cc7752773620 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Mon, 23 Feb 2026 12:08:45 -0500 Subject: [PATCH 5/7] Update volume layer check in exporter to avoid requiring glue-vispy-viewers import. --- glue_plotly/html_exporters/jupyter/volume.py | 22 +++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/glue_plotly/html_exporters/jupyter/volume.py b/glue_plotly/html_exporters/jupyter/volume.py index 5a8a50b..989508a 100644 --- a/glue_plotly/html_exporters/jupyter/volume.py +++ b/glue_plotly/html_exporters/jupyter/volume.py @@ -1,5 +1,5 @@ import plotly.graph_objs as go -from glue_vispy_viewers.scatter.layer_artist import ScatterLayerArtist +from glue_jupyter.ipyvolume.volume.layer_state import VolumeLayerState from plotly.offline import plot from glue.config import viewer_tool @@ -9,6 +9,18 @@ from glue_plotly.common.volume import traces_for_layer as volume_traces_for_layer from glue_plotly.jupyter_base_export_tool import JupyterBaseExportTool +VOLUME_LAYER_STATES = [VolumeLayerState] +try: + from glue.viewers.volume3d.layer_state import VolumeLayerState3D + VOLUME_LAYER_STATES.append(VolumeLayerState3D) +except ImportError: + try: + from glue_vispy_viewers.volume.layer_state import VolumeLayerState + VOLUME_LAYER_STATES.append(VolumeLayerState) + except ImportError: + pass + + @viewer_tool class PlotlyScatter3DStaticExport(JupyterBaseExportTool): @@ -28,13 +40,13 @@ def save_figure(self, filepath): bds = bounds(self.viewer.state, with_resolution=True) count = 5 for layer in layers: - if isinstance(layer, ScatterLayerArtist): - traces = scatter3d_traces_for_layer(self.viewer.state, layer.state, - add_data_label=add_data_label) - else: + if isinstance(layer.state, tuple(VOLUME_LAYER_STATES)): traces = volume_traces_for_layer(self.viewer.state, layer.state, bds, isosurface_count=count, add_data_label=add_data_label) + else: + traces = scatter3d_traces_for_layer(self.viewer.state, layer.state, + add_data_label=add_data_label) for trace in traces: fig.add_trace(trace) From d13b00dc52c10fa8e4d614feaea9e2a16d54cb70 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Mon, 23 Feb 2026 13:11:59 -0500 Subject: [PATCH 6/7] Guard glue-jupyter import statement as well. --- glue_plotly/html_exporters/jupyter/volume.py | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/glue_plotly/html_exporters/jupyter/volume.py b/glue_plotly/html_exporters/jupyter/volume.py index 989508a..c26a661 100644 --- a/glue_plotly/html_exporters/jupyter/volume.py +++ b/glue_plotly/html_exporters/jupyter/volume.py @@ -1,5 +1,6 @@ +from contextlib import suppress + import plotly.graph_objs as go -from glue_jupyter.ipyvolume.volume.layer_state import VolumeLayerState from plotly.offline import plot from glue.config import viewer_tool @@ -9,17 +10,20 @@ from glue_plotly.common.volume import traces_for_layer as volume_traces_for_layer from glue_plotly.jupyter_base_export_tool import JupyterBaseExportTool -VOLUME_LAYER_STATES = [VolumeLayerState] -try: + +VOLUME_LAYER_STATES = [] + +with suppress(ImportError): + from glue_jupyter.ipyvolume.volume.layer_state import VolumeLayerState + VOLUME_LAYER_STATES.append(VolumeLayerState) + +with suppress(ImportError): from glue.viewers.volume3d.layer_state import VolumeLayerState3D VOLUME_LAYER_STATES.append(VolumeLayerState3D) -except ImportError: - try: - from glue_vispy_viewers.volume.layer_state import VolumeLayerState - VOLUME_LAYER_STATES.append(VolumeLayerState) - except ImportError: - pass +with suppress(ImportError): + from glue_vispy_viewers.volume.layer_state import VolumeLayerState + VOLUME_LAYER_STATES.append(VolumeLayerState) @viewer_tool From c3c2fdaa62e9dd3250c1c249241b509c200772b9 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Mon, 23 Feb 2026 13:13:43 -0500 Subject: [PATCH 7/7] Codestyle fixes. --- glue_plotly/html_exporters/jupyter/volume.py | 1 - 1 file changed, 1 deletion(-) diff --git a/glue_plotly/html_exporters/jupyter/volume.py b/glue_plotly/html_exporters/jupyter/volume.py index c26a661..e9ffe8f 100644 --- a/glue_plotly/html_exporters/jupyter/volume.py +++ b/glue_plotly/html_exporters/jupyter/volume.py @@ -10,7 +10,6 @@ from glue_plotly.common.volume import traces_for_layer as volume_traces_for_layer from glue_plotly.jupyter_base_export_tool import JupyterBaseExportTool - VOLUME_LAYER_STATES = [] with suppress(ImportError):