plotly / plotly/plotly.py

Circular Import Dependency in Plotly Templates

オープン
#5,281 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P1
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
21

説明

The issue is that plotly's template system has a circular import dependency:

  1. plotly.graph_objs.__init__.py imports all trace types including Heatmapgl
  2. During this import process, it also loads template data
  3. layout/template/data/_heatmapgl.py tries to import Heatmapgl from plotly.graph_objs
  4. 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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。