[PR #1349] [CLOSED] refactor(labs): remove widget-in-gated-cell pattern from 30 labs #5145

Closed
opened 2026-04-19 12:50:15 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: devHead: refactor/lab-widget-cells


📝 Commits (1)

  • 78bc87a refactor(labs): remove widget-in-gated-cell pattern from 30 labs

📊 Changes

32 files changed (+113 additions, -333 deletions)

View changed files

📝 labs/vol1/lab_00_introduction.py (+2 -4)
📝 labs/vol1/lab_01_ml_intro.py (+4 -10)
📝 labs/vol1/lab_02_ml_systems.py (+3 -9)
📝 labs/vol1/lab_03_ml_workflow.py (+3 -9)
📝 labs/vol1/lab_04_data_engr.py (+3 -9)
📝 labs/vol1/lab_05_nn_compute.py (+3 -9)
📝 labs/vol1/lab_06_nn_arch.py (+3 -9)
📝 labs/vol1/lab_07_ml_frameworks.py (+3 -9)
📝 labs/vol1/lab_08_model_train.py (+3 -9)
📝 labs/vol1/lab_09_data_selection.py (+3 -9)
📝 labs/vol1/lab_10_model_compress.py (+4 -12)
📝 labs/vol1/lab_11_hw_accel.py (+4 -12)
📝 labs/vol1/lab_12_perf_bench.py (+3 -9)
📝 labs/vol1/lab_13_model_serving.py (+3 -9)
📝 labs/vol1/lab_14_ml_ops.py (+3 -9)
📝 labs/vol1/lab_15_responsible_engr.py (+3 -9)
📝 labs/vol1/lab_16_ml_conclusion.py (+4 -12)
📝 labs/vol2/lab_01_introduction.py (+4 -12)
📝 labs/vol2/lab_02_compute_infra.py (+4 -12)
📝 labs/vol2/lab_03_communication.py (+4 -12)

...and 12 more files

📄 Description

applies the canonical pattern (already established in vol2/lab_05_dist_train) across 30 of 33 labs. addresses the bulk of #1347.

what and why

widget-defining cells should not contain mo.stop() gates. the tabs cell already handles per-part display gating via if prediction.value is None: return lock_msg inside each build_part_X() function, so the outer gate in widget cells was redundant and caused a dependency cascade bug where later cells could not run until earlier ones unblocked.

surfaced originally in lab_01 (fixed via #1339 manually) and tracked in #1347 as a systematic cleanup.

transformation

for every widget cell matching this pattern:

def _(mo, partX_prediction):
    mo.stop(partX_prediction.value is None, mo.md("..."))
    partX_instrument = mo.ui.slider(...)
    partY_prediction = mo.ui.radio(...)
    return (partY_prediction,)

remove the gate and the prediction dep from the signature:

def _(mo):
    partX_instrument = mo.ui.slider(...)
    partY_prediction = mo.ui.radio(...)
    return (partY_prediction,)

applied only where the prediction dep was used nowhere else in the cell. cells that read the prediction's value for computation were left untouched and stay tracked in #1347.

labs updated (30)

  • vol1/lab_00 (partial: check1 gate removed)
  • vol1/lab_02 through vol1/lab_16 (15 labs, all widget-gate cells cleaned)
  • vol2/lab_01 through vol2/lab_04, vol2/lab_06 through vol2/lab_16 (14 labs)

labs still xfail on widget-gated check (3)

  • vol1/lab_00: check2, check3, context_selector gates read their deps for feedback logic
  • vol1/lab_01: some instrument cells mix gate + instrument use
  • vol2/lab_11: partE synthesis cell has complex dep usage

these 3 need judgment-based per-cell refactor. #1347 stays open for them.

verification

  • marimo check labs/vol{1,2}/*.py — clean across all 33 labs
  • pytest labs/tests/test_static.py — 656 passed, 4 skipped, 3 xfailed, 30 xpassed (before: 33 xfailed, 1 xpassed)

net diff

32 files changed, 113 insertions(+), 333 deletions(-)


🔄 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/1349 **Author:** [@profvjreddi](https://github.com/profvjreddi) **Created:** 4/16/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `refactor/lab-widget-cells` --- ### 📝 Commits (1) - [`78bc87a`](https://github.com/harvard-edge/cs249r_book/commit/78bc87ab9383e6f958412b679bf6b633dafd2bd8) refactor(labs): remove widget-in-gated-cell pattern from 30 labs ### 📊 Changes **32 files changed** (+113 additions, -333 deletions) <details> <summary>View changed files</summary> 📝 `labs/vol1/lab_00_introduction.py` (+2 -4) 📝 `labs/vol1/lab_01_ml_intro.py` (+4 -10) 📝 `labs/vol1/lab_02_ml_systems.py` (+3 -9) 📝 `labs/vol1/lab_03_ml_workflow.py` (+3 -9) 📝 `labs/vol1/lab_04_data_engr.py` (+3 -9) 📝 `labs/vol1/lab_05_nn_compute.py` (+3 -9) 📝 `labs/vol1/lab_06_nn_arch.py` (+3 -9) 📝 `labs/vol1/lab_07_ml_frameworks.py` (+3 -9) 📝 `labs/vol1/lab_08_model_train.py` (+3 -9) 📝 `labs/vol1/lab_09_data_selection.py` (+3 -9) 📝 `labs/vol1/lab_10_model_compress.py` (+4 -12) 📝 `labs/vol1/lab_11_hw_accel.py` (+4 -12) 📝 `labs/vol1/lab_12_perf_bench.py` (+3 -9) 📝 `labs/vol1/lab_13_model_serving.py` (+3 -9) 📝 `labs/vol1/lab_14_ml_ops.py` (+3 -9) 📝 `labs/vol1/lab_15_responsible_engr.py` (+3 -9) 📝 `labs/vol1/lab_16_ml_conclusion.py` (+4 -12) 📝 `labs/vol2/lab_01_introduction.py` (+4 -12) 📝 `labs/vol2/lab_02_compute_infra.py` (+4 -12) 📝 `labs/vol2/lab_03_communication.py` (+4 -12) _...and 12 more files_ </details> ### 📄 Description applies the canonical pattern (already established in `vol2/lab_05_dist_train`) across 30 of 33 labs. addresses the bulk of #1347. ## what and why widget-defining cells should not contain `mo.stop()` gates. the tabs cell already handles per-part display gating via `if prediction.value is None: return lock_msg` inside each `build_part_X()` function, so the outer gate in widget cells was redundant and caused a dependency cascade bug where later cells could not run until earlier ones unblocked. surfaced originally in lab_01 (fixed via #1339 manually) and tracked in #1347 as a systematic cleanup. ## transformation for every widget cell matching this pattern: ```python def _(mo, partX_prediction): mo.stop(partX_prediction.value is None, mo.md("...")) partX_instrument = mo.ui.slider(...) partY_prediction = mo.ui.radio(...) return (partY_prediction,) ``` remove the gate and the prediction dep from the signature: ```python def _(mo): partX_instrument = mo.ui.slider(...) partY_prediction = mo.ui.radio(...) return (partY_prediction,) ``` applied only where the prediction dep was used nowhere else in the cell. cells that read the prediction's value for computation were left untouched and stay tracked in #1347. ## labs updated (30) - `vol1/lab_00` (partial: check1 gate removed) - `vol1/lab_02` through `vol1/lab_16` (15 labs, all widget-gate cells cleaned) - `vol2/lab_01` through `vol2/lab_04`, `vol2/lab_06` through `vol2/lab_16` (14 labs) ## labs still xfail on widget-gated check (3) - `vol1/lab_00`: check2, check3, context_selector gates read their deps for feedback logic - `vol1/lab_01`: some instrument cells mix gate + instrument use - `vol2/lab_11`: partE synthesis cell has complex dep usage these 3 need judgment-based per-cell refactor. #1347 stays open for them. ## verification - `marimo check labs/vol{1,2}/*.py` — clean across all 33 labs - `pytest labs/tests/test_static.py` — 656 passed, 4 skipped, 3 xfailed, 30 xpassed (before: 33 xfailed, 1 xpassed) ## net diff 32 files changed, 113 insertions(+), 333 deletions(-) --- <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-19 12:50:15 -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#5145