[PR #1353] [MERGED] fix(labs/lab_05): import plotly.subplots AFTER micropip install #8141

Closed
opened 2026-04-27 17:27:01 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/harvard-edge/cs249r_book/pull/1353
Author: @profvjreddi
Created: 4/16/2026
Status: Merged
Merged: 4/16/2026
Merged by: @profvjreddi

Base: devHead: fix/lab05-plotly-import-order


📝 Commits (2)

  • 6d56fff fix(labs/lab_05): import plotly.subplots AFTER micropip install
  • 1c535fc test(labs): catch runtime-installed imports before micropip.install

📊 Changes

2 files changed (+112 additions, -1 deletions)

View changed files

📝 labs/tests/test_static.py (+110 -0)
📝 labs/vol2/lab_05_dist_train.py (+2 -1)

📄 Description

pre-existing bug caught when loading the dev preview site in a real browser. shown in the attached screenshot — every cell downstream of the setup cell cascades with ancestor raised because line 55 imports from plotly.subplots import make_subplots BEFORE line 60 installs plotly via micropip.

why existing CI missed this

check why it didn't catch it
marimo check syntax/structure only, not runtime
test_engine.py native python, plotly already installed
test_static.py AST patterns only
marimo export html-wasm smoke test byte-size check, not actual runtime rendering

only the user's actual Chrome browser caught this — the console showed ModuleNotFoundError: No module named 'plotly' cascading across all downstream cells.

fix

move the from plotly.subplots import make_subplots line to AFTER the micropip install block. plotly is available only at runtime in WASM, so imports must come AFTER await micropip.install([..., 'plotly', ...]).

followup: close the CI gap

should add a playwright step to labs-validate-dev that:

  1. exports a representative lab to WASM
  2. serves it locally with wheels mounted
  3. opens in headless chromium with appropriate flags
  4. waits for Pyodide init + asserts the tabs widget rendered (not a 'made with marimo' blank)

would have caught this before it shipped to dev preview.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/harvard-edge/cs249r_book/pull/1353 **Author:** [@profvjreddi](https://github.com/profvjreddi) **Created:** 4/16/2026 **Status:** ✅ Merged **Merged:** 4/16/2026 **Merged by:** [@profvjreddi](https://github.com/profvjreddi) **Base:** `dev` ← **Head:** `fix/lab05-plotly-import-order` --- ### 📝 Commits (2) - [`6d56fff`](https://github.com/harvard-edge/cs249r_book/commit/6d56fff7a140f2e35396d0c02f0a59b0f402ec5b) fix(labs/lab_05): import plotly.subplots AFTER micropip install - [`1c535fc`](https://github.com/harvard-edge/cs249r_book/commit/1c535fc7e0fbce30467bc699f327515dfe7b0d09) test(labs): catch runtime-installed imports before micropip.install ### 📊 Changes **2 files changed** (+112 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `labs/tests/test_static.py` (+110 -0) 📝 `labs/vol2/lab_05_dist_train.py` (+2 -1) </details> ### 📄 Description pre-existing bug caught when loading the dev preview site in a real browser. shown in the attached screenshot — every cell downstream of the setup cell cascades with `ancestor raised` because line 55 imports `from plotly.subplots import make_subplots` BEFORE line 60 installs plotly via micropip. ## why existing CI missed this | check | why it didn't catch it | |---|---| | `marimo check` | syntax/structure only, not runtime | | `test_engine.py` | native python, plotly already installed | | `test_static.py` | AST patterns only | | `marimo export html-wasm` smoke test | byte-size check, not actual runtime rendering | only the user's actual Chrome browser caught this — the console showed `ModuleNotFoundError: No module named 'plotly'` cascading across all downstream cells. ## fix move the `from plotly.subplots import make_subplots` line to AFTER the micropip install block. plotly is available only at runtime in WASM, so imports must come AFTER `await micropip.install([..., 'plotly', ...])`. ## followup: close the CI gap should add a playwright step to labs-validate-dev that: 1. exports a representative lab to WASM 2. serves it locally with wheels mounted 3. opens in headless chromium with appropriate flags 4. waits for Pyodide init + asserts the tabs widget rendered (not a 'made with marimo' blank) would have caught this before it shipped to dev preview. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-27 17:27:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#8141