[PR #1386] [MERGED] fix(labs): widget return-tuple sweep across 33 labs + static regression guard (#1332) #6509

Closed
opened 2026-04-21 22:23:03 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: devHead: fix/labs-widget-return-audit


📝 Commits (1)

  • 80b916f fix(labs): widget return-tuple sweep + static test for regressions (#1332)

📊 Changes

34 files changed (+419 additions, -326 deletions)

View changed files

📝 labs/tests/test_static.py (+82 -0)
📝 labs/vol1/lab_00_introduction.py (+5 -2)
📝 labs/vol1/lab_01_ml_intro.py (+11 -15)
📝 labs/vol1/lab_02_ml_systems.py (+13 -17)
📝 labs/vol1/lab_03_ml_workflow.py (+6 -8)
📝 labs/vol1/lab_04_data_engr.py (+8 -4)
📝 labs/vol1/lab_05_nn_compute.py (+9 -4)
📝 labs/vol1/lab_06_nn_arch.py (+8 -4)
📝 labs/vol1/lab_07_ml_frameworks.py (+8 -4)
📝 labs/vol1/lab_08_model_train.py (+9 -4)
📝 labs/vol1/lab_09_data_selection.py (+9 -4)
📝 labs/vol1/lab_10_model_compress.py (+8 -4)
📝 labs/vol1/lab_11_hw_accel.py (+8 -4)
📝 labs/vol1/lab_12_perf_bench.py (+8 -4)
📝 labs/vol1/lab_13_model_serving.py (+9 -4)
📝 labs/vol1/lab_14_ml_ops.py (+8 -4)
📝 labs/vol1/lab_15_responsible_engr.py (+8 -4)
📝 labs/vol1/lab_16_ml_conclusion.py (+10 -4)
📝 labs/vol2/lab_01_introduction.py (+11 -5)
📝 labs/vol2/lab_02_compute_infra.py (+10 -5)

...and 14 more files

📄 Description

what

sweeps the whole labs tree to fix a marimo dataflow bug class that left widgets invisible to the tabs cell in 17 of 33 labs. reported by @asgalon in #1332 for lab_02 + lab_03 (fixed in #1385); this pr does the rest and locks the regression out via a new static test.

the bug

marimo routes widget state strictly through each cell's return tuple. every @app.cell that defined helper widgets (sliders, dropdowns) alongside the terminal partX_prediction returned only the prediction. the helpers were defined but never reached the tabs cell — they were effectively dead allocations. sliders never rendered after the prediction unlocked; chart inputs never re-ran on change. every static and engine test still passed because the cells executed fine in isolation.

the audit script (/tmp/audit_widget_returns.py) found:

scope before after
labs scanned 33 33
offending labs 17 0
unreturned widgets 175 0

(the 42 "hits" that remain in the updated audit are all widgets defined inside the tabs cell itself, consumed by its own build_part_* closures via scope — they don't need to flow outward. the new static test excludes those.)

changes

  1. codemod over all 33 labs. every widget cell's return (...) tuple now lists every mo.ui.* it defines, alphabetical. every tabs-cell signature is rewritten to declare every widget it references. no logic, labels, or UI copy touched.
  2. TestWidgetReturnCompleteness in labs/tests/test_static.py. fails on any new cell defining a widget without returning it (render sinks like tabs/_tabs and tabs-cell-local widgets excluded). 33 / 33 labs pass; a regression is blocked at CI time.

test plan

  • labs/tests/test_static.py + tests/test_engine.py: 825 passed 4 skipped 1 xfailed (up from 792 — 33 new test runs)
  • marimo check spot-sampled on several labs: exit 0
  • audit script: 17 → 0 offending labs on the meaningful check
  • CI green on this pr

closes the main thread of #1332. @asgalon's "updated example values" suggestion for Lab 02 and the tabs-cell widget extraction cleanup left as follow-ups.


🔄 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/1386 **Author:** [@profvjreddi](https://github.com/profvjreddi) **Created:** 4/17/2026 **Status:** ✅ Merged **Merged:** 4/17/2026 **Merged by:** [@profvjreddi](https://github.com/profvjreddi) **Base:** `dev` ← **Head:** `fix/labs-widget-return-audit` --- ### 📝 Commits (1) - [`80b916f`](https://github.com/harvard-edge/cs249r_book/commit/80b916f3d6aa62dc7e791bccf4dcbc2958754b71) fix(labs): widget return-tuple sweep + static test for regressions (#1332) ### 📊 Changes **34 files changed** (+419 additions, -326 deletions) <details> <summary>View changed files</summary> 📝 `labs/tests/test_static.py` (+82 -0) 📝 `labs/vol1/lab_00_introduction.py` (+5 -2) 📝 `labs/vol1/lab_01_ml_intro.py` (+11 -15) 📝 `labs/vol1/lab_02_ml_systems.py` (+13 -17) 📝 `labs/vol1/lab_03_ml_workflow.py` (+6 -8) 📝 `labs/vol1/lab_04_data_engr.py` (+8 -4) 📝 `labs/vol1/lab_05_nn_compute.py` (+9 -4) 📝 `labs/vol1/lab_06_nn_arch.py` (+8 -4) 📝 `labs/vol1/lab_07_ml_frameworks.py` (+8 -4) 📝 `labs/vol1/lab_08_model_train.py` (+9 -4) 📝 `labs/vol1/lab_09_data_selection.py` (+9 -4) 📝 `labs/vol1/lab_10_model_compress.py` (+8 -4) 📝 `labs/vol1/lab_11_hw_accel.py` (+8 -4) 📝 `labs/vol1/lab_12_perf_bench.py` (+8 -4) 📝 `labs/vol1/lab_13_model_serving.py` (+9 -4) 📝 `labs/vol1/lab_14_ml_ops.py` (+8 -4) 📝 `labs/vol1/lab_15_responsible_engr.py` (+8 -4) 📝 `labs/vol1/lab_16_ml_conclusion.py` (+10 -4) 📝 `labs/vol2/lab_01_introduction.py` (+11 -5) 📝 `labs/vol2/lab_02_compute_infra.py` (+10 -5) _...and 14 more files_ </details> ### 📄 Description ## what sweeps the whole labs tree to fix a marimo dataflow bug class that left widgets invisible to the tabs cell in 17 of 33 labs. reported by @asgalon in #1332 for lab_02 + lab_03 (fixed in #1385); this pr does the rest and locks the regression out via a new static test. ## the bug marimo routes widget state strictly through each cell's return tuple. every `@app.cell` that defined helper widgets (sliders, dropdowns) alongside the terminal `partX_prediction` returned only the prediction. the helpers were defined but never reached the tabs cell — they were effectively dead allocations. sliders never rendered after the prediction unlocked; chart inputs never re-ran on change. every static and engine test still passed because the cells executed fine in isolation. the audit script (`/tmp/audit_widget_returns.py`) found: | scope | before | after | |-|-|-| | labs scanned | 33 | 33 | | offending labs | 17 | 0 | | unreturned widgets | 175 | 0 | (the 42 "hits" that remain in the updated audit are all widgets defined inside the tabs cell itself, consumed by its own `build_part_*` closures via scope — they don't need to flow outward. the new static test excludes those.) ## changes 1. **codemod over all 33 labs.** every widget cell's `return (...)` tuple now lists every `mo.ui.*` it defines, alphabetical. every tabs-cell signature is rewritten to declare every widget it references. no logic, labels, or UI copy touched. 2. **`TestWidgetReturnCompleteness` in `labs/tests/test_static.py`.** fails on any new cell defining a widget without returning it (render sinks like `tabs`/`_tabs` and tabs-cell-local widgets excluded). 33 / 33 labs pass; a regression is blocked at CI time. ## test plan - [x] `labs/tests/test_static.py` + `tests/test_engine.py`: 825 passed 4 skipped 1 xfailed (up from 792 — 33 new test runs) - [x] `marimo check` spot-sampled on several labs: exit 0 - [x] audit script: 17 → 0 offending labs on the meaningful check - [ ] CI green on this pr closes the main thread of #1332. @asgalon's "updated example values" suggestion for Lab 02 and the tabs-cell widget extraction cleanup left as follow-ups. --- <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-21 22:23:03 -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#6509