plotly / plotly/plotly.py

Circular Import Dependency in Plotly Templates

Offen
#5,281 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug P1
Vorherrschende Sprache
Python
Sterne
18.8k
Forks
2.8k
Ø Merge
16 Std. 26 Min.
Gemergte PRs (30 T.)
21

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere den Fehler mit plotly==5.24.1 und plotly-resampler==0.10.0 und untersuche anschließend plotly.graph_objs.init.py sowie layout/template/data/_heatmapgl.py. Verfolge die Importreihenfolge aus dem gemeldeten FigureResampler-Beispiel. Als abgeschlossen gilt die Aufgabe, wenn das Beispiel die Abbildung importiert und erstellt, ohne dass zuvor manuell ein plotly.graph_objs-Import erforderlich ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.