Skip to content

Commit 4c3c068

Browse files
authored
Pin non-working trame-vuetify version (#14080)
1 parent 784ab8d commit 4c3c068

5 files changed

Lines changed: 39 additions & 5 deletions

File tree

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ dependencies:
6565
- trame
6666
- trame-pyvista
6767
- trame-vtk
68-
- trame-vuetify
68+
- trame-vuetify !=3.2.3
6969
- vtk ==9.6.2
7070
- xlrd
7171
- pip:

mne/viz/backends/_notebook.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import os
88
import os.path as op
9+
import warnings
910
from contextlib import contextmanager, nullcontext
1011

1112
from ipyevents import Event
@@ -112,6 +113,37 @@
112113

113114
_JUPYTER_BACKEND = "trame"
114115

116+
117+
class _NotebookPlotter(Plotter):
118+
"""PyVista ``Plotter`` for the notebook backend.
119+
120+
Validate the object returned by show, as PyVista silently falls back static PIL
121+
when the trame Jupyter backend cannot be loaded.
122+
"""
123+
124+
def show(self, *args, **kwargs):
125+
with warnings.catch_warnings(record=True) as caught:
126+
warnings.simplefilter("always")
127+
viewer = super().show(*args, **kwargs)
128+
if not isinstance(viewer, Widget):
129+
reasons = "\n".join(
130+
f"- {w.message}"
131+
for w in caught
132+
if any(key in str(w.message) for key in ("backend", "trame", "static"))
133+
)
134+
raise RuntimeError(
135+
f'The notebook 3D backend is not functional: the "{_JUPYTER_BACKEND}" '
136+
"PyVista Jupyter backend returned a "
137+
f"{type(viewer).__module__}.{type(viewer).__qualname__} instead of an "
138+
"interactive widget. This usually means the installed trame packages "
139+
"(trame, trame-vtk, trame-vuetify, trame-pyvista) are missing or "
140+
"mutually incompatible."
141+
+ (f"\n\nPyVista reported:\n{reasons}" if reasons else "")
142+
)
143+
if kwargs["return_viewer"]:
144+
return viewer
145+
146+
115147
# %%
116148
# Widgets
117149
# -------

mne/viz/backends/_pyvista.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import numpy as np
1919
import pyvista
20-
from pyvista import Line, Plotter, PolyData, close_all
20+
from pyvista import Line, Plotter, PolyData, close_all # noqa: F401 # re-exported
2121
from pyvista.plotting.plotter import _ALL_PLOTTERS
2222
from pyvistaqt import BackgroundPlotter
2323
from vtkmodules.util.numpy_support import numpy_to_vtk
@@ -131,7 +131,9 @@ def _init(
131131

132132
self.store["app_window_class"] = _MNEMainWindow
133133
else:
134-
self._plotter_class = Plotter
134+
from ._notebook import _NotebookPlotter
135+
136+
self._plotter_class = _NotebookPlotter
135137

136138
self._nrows, self._ncols = self.store["shape"]
137139

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ full-no-qt = [
192192
"trame",
193193
"trame-pyvista",
194194
"trame-vtk",
195-
"trame-vuetify",
195+
"trame-vuetify != 3.2.3",
196196
"vtk >= 9.2",
197197
"xlrd",
198198
]

tools/install_pre_requirements.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ python -m pip install $STD_ARGS \
6767
git+https://github.com/h5io/h5io \
6868
git+https://github.com/BUNPC/pysnirf2 \
6969
git+https://github.com/the-siesta-group/edfio \
70-
trame trame-vtk trame-vuetify trame-pyvista nest-asyncio2 jupyter ipyevents ipympl \
70+
trame trame-vtk "trame-vuetify!=3.2.3" trame-pyvista nest-asyncio2 jupyter ipyevents ipympl \
7171
openmeeg imageio-ffmpeg xlrd mffpy traitlets pybv eeglabio defusedxml antio curryreader \
7272
filelock
7373
echo "::endgroup::"

0 commit comments

Comments
 (0)