Circular Import Dependency in Plotly Templates
未关闭
还没有人认领这个 Issue。
bug
P1
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 plotly==5.24.1 和 plotly-resampler==0.10.0 重现该失败,然后检查 plotly.graph_objs.init.py 和 layout/template/data/_heatmapgl.py。根据报告的 FigureResampler 示例跟踪导入顺序。当该示例无需先手动导入 plotly.graph_objs 即可导入并构建图形时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100