Circular Import Dependency in Plotly Templates
Open
Nobody has claimed this yet.
bug
P1
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
The issue is that plotly's template system has a circular import dependency:
plotly.graph_objs.__init__.pyimports all trace types including Heatmapgl- During this import process, it also loads template data
layout/template/data/_heatmapgl.pytries toimport Heatmapgl from plotly.graph_objs- But plotly.graph_objs is still in the process of being imported!
This occurred when attempting to use plotly and plotly-resampler and a heatmap.
Reproduction of Error
Minimal reproduction code:
import plotly.graph_objs as go
go.Heatmapgl() # ✅ Success
# But this fails:
from plotly_resampler import FigureResampler
fig = FigureResampler(go.Figure()) # ❌ Circular import
Versions affected:
plotly==5.24.1
plotly-resampler==0.10.0
Work around
This can be worked around by forcing import order:
import plotly.graph_objs # Force full initialization first
from plotly_resampler import FigureResampler # Then import resampler
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 failure with plotly==5.24.1 and plotly-resampler==0.10.0, then inspect plotly.graph_objs.init.py and layout/template/data/_heatmapgl.py. Trace the import order from the reported FigureResampler example. Done means the example imports and constructs the figure without requiring a manual plotly.graph_objs import first.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100