FigureWidget + go.Image.source breaks notebook kernel in VSCode
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
I encounter a bug in VSCode notebook when using a FigureWidget for a go.Image trace using source string instead of z attribute (px.imshow optimization).
The bug is: once you hover the image with mouse the kernel is unresponsive, i.e. you can't run any cell anymore.
The bug is not present when running the notebook through Jupyter web interface.
Reproducible example
import numpy as np
import plotly.express as px
import plotly.graph_objects as go
from plotly.utils import image_array_to_data_uri
img = (np.random.rand(10, 10, 3) * 255).astype(np.uint8)
img_str = image_array_to_data_uri(img)
# --- Using normal go.Figure is OK
# px.imshow(img) # OK
# go.Figure(go.Image(z=img)) # OK
# go.Figure(go.Image(source=img_str)) # OK
# --- Using go.FigureWidget and Image.z is OK
# go.FigureWidget(go.Image(z=img)) # OK
# --- Using go.FigureWidget and Image.source is NOT OK
# go.FigureWidget(px.imshow(img)) # NOK
go.FigureWidget(go.Image(source=img_str)) # NOK
Versions
$ conda list | grep -E 'plotly|ipykernel|pillow|numpy|pandas'
ipykernel 6.26.0 pyhf8b6a83_0 conda-forge
numpy 1.26.0 py312heda63a1_0 conda-forge
pandas 2.1.3 py312hfb8ada1_0 conda-forge
pillow 10.1.0 py312hf3581a9_0 conda-forge
plotly 5.18.0 pyhd8ed1ab_0 conda-forge
$ code --version
1.84.2
1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
x64
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the supplied FigureWidget example in a VSCode notebook, comparing go.Image(source=...) with go.Image(z=...) and the equivalent Jupyter web run. Trace the FigureWidget notebook interaction triggered by hovering the source-backed image; the issue is done when hovering no longer leaves the kernel unresponsive and normal cell execution continues.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook, python, vscode
- Domain
- data-visualization, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100