fix(labs/lab_05): import plotly.subplots AFTER micropip install

pre-existing bug caught by loading the dev preview in a real browser.

the setup cell imported `from plotly.subplots import make_subplots` at line 55, BEFORE the `await micropip.install([..., "plotly", ...])` at line 60. in WASM (emscripten), plotly isn't available at import time — it's installed at runtime via micropip. the top-level import fails with ModuleNotFoundError, and every downstream cell that depends on the setup cell cascades with "ancestor raised".

fix: move the plotly.subplots import to after the micropip install block, alongside `import plotly.graph_objects as go` which was already in the right place.

caught only by manual browser verification on the dev preview site. the existing CI checks (marimo check, test_engine in native python, WASM smoke test byte-size check) all passed because they don't actually run the exported HTML in a browser.
This commit is contained in:
Vijay Janapa Reddi
2026-04-16 17:58:13 -04:00
parent befefdd6ab
commit 6d56fff7a1

View File

@@ -52,7 +52,6 @@ async def _():
import math
from pathlib import Path
import numpy as np
from plotly.subplots import make_subplots
# WASM bootstrap
if sys.platform == "emscripten":
@@ -66,6 +65,8 @@ async def _():
if str(_root) not in sys.path:
sys.path.insert(0, str(_root))
# plotly must be imported AFTER micropip install, since it's installed at runtime on WASM
from plotly.subplots import make_subplots
import plotly.graph_objects as go
from mlsysim.labs.state import DesignLedger
from mlsysim.labs.style import COLORS, LAB_CSS, apply_plotly_theme