[PR #1351] [MERGED] refactor(labs/lab_06): migrate fault-tolerance lab to Pattern C (proof lab) #9044

Closed
opened 2026-05-03 01:15:12 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: devHead: refactor/lab06-pattern-c


📝 Commits (1)

  • 3470afd refactor(labs/lab_06): migrate to Pattern C widget-cell pattern

📊 Changes

1 file changed (+4 additions, -14 deletions)

View changed files

📝 labs/vol2/lab_06_fault_tolerance.py (+4 -14)

📄 Description

first of 14 labs to migrate per #1347. this is the proof-of-pattern PR; once CI validates and you sign off, the remaining 13 can follow the same template (or be batched).

bug fixed

two experts independently flagged a dangling mo.stop(partA_prediction.value is None, ...) in the LEDGER_HUD cell at the bottom of this lab. the message "Make your prediction above to unlock this part" has no sensible referent at the bottom of the page, and the HUD's own logic (_a1_ok = partA_prediction.value == "C") already handles None-value correctly. this PR removes it.

the pattern

applies the canonical pattern from vol2/lab_05_dist_train (the only lab that currently XPASSes the widget-gated-cell check). widget cells become pure widget definitions; gating lives inside build_part_X() functions via if partX_prediction.value is None: items.append(mo.callout(...)); return. the internal gates were already written in lab_06 (lines 413, 652, etc.) — the cell-level mo.stop calls were redundant gating on top.

what changes for the student

before: tabs don't render until student answers predictions A → B → C → D in sequence (cell-level gates cascade).

after: all 5 tabs (A, B, C, D, Synthesis) render immediately on load. each tab still shows its own unlock message until that part's prediction is answered. synthesis tab is accessible at any time as an advance organizer, matching the TEMPLATE intent.

5 mo.stop calls removed

  • cell at line 215 (was gated on partA_prediction)
  • cell at line 242 (was gated on partB_prediction)
  • cell at line 267 (was gated on partB_reflection)
  • cell at line 296 (was gated on partC_reflection)
  • cell at line 1468 (LEDGER_HUD, the expert-flagged dangling gate)

cell signatures simplified where the gate dep was only used in the removed mo.stop.

verification

  • marimo check — clean
  • pytest labs/tests/test_engine.py -k lab_06_fault — 2/2 passed (cells execute, produce outputs)
  • pytest labs/tests/test_static.py -k lab_06_fault — 20 passed; test_no_widget_defined_in_gated_cell XPASSED (lab no longer has the pattern)
  • programmatic app.run() — 12 cell outputs, 49 definitions, all 18 expected widgets + tabs cell defined
  • marimo export html-wasm — valid HTML produced

net diff

4 insertions(+), 14 deletions(-) — small and mechanical.

  • #1347 tracks the 14-lab refactor effort
  • #1350 updated the test check to use the multi-widget-leak threshold (less strict than the original test in #1346)
  • if this lands cleanly, vol2/lab_07 through vol2/lab_16 + vol2/lab_01 + vol1/lab_00 follow the same template

🔄 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/1351 **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:** `refactor/lab06-pattern-c` --- ### 📝 Commits (1) - [`3470afd`](https://github.com/harvard-edge/cs249r_book/commit/3470afd8c849e68838250af6de3f02e25ab1d7b2) refactor(labs/lab_06): migrate to Pattern C widget-cell pattern ### 📊 Changes **1 file changed** (+4 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `labs/vol2/lab_06_fault_tolerance.py` (+4 -14) </details> ### 📄 Description first of 14 labs to migrate per #1347. this is the proof-of-pattern PR; once CI validates and you sign off, the remaining 13 can follow the same template (or be batched). ## bug fixed two experts independently flagged a dangling `mo.stop(partA_prediction.value is None, ...)` in the LEDGER_HUD cell at the bottom of this lab. the message "Make your prediction above to unlock this part" has no sensible referent at the bottom of the page, and the HUD's own logic (`_a1_ok = partA_prediction.value == "C"`) already handles None-value correctly. this PR removes it. ## the pattern applies the canonical pattern from `vol2/lab_05_dist_train` (the only lab that currently XPASSes the widget-gated-cell check). widget cells become pure widget definitions; gating lives inside `build_part_X()` functions via `if partX_prediction.value is None: items.append(mo.callout(...)); return`. the internal gates were already written in lab_06 (lines 413, 652, etc.) — the cell-level `mo.stop` calls were redundant gating on top. ## what changes for the student before: tabs don't render until student answers predictions A → B → C → D in sequence (cell-level gates cascade). after: all 5 tabs (A, B, C, D, Synthesis) render immediately on load. each tab still shows its own unlock message until that part's prediction is answered. synthesis tab is accessible at any time as an advance organizer, matching the TEMPLATE intent. ## 5 mo.stop calls removed - cell at line 215 (was gated on partA_prediction) - cell at line 242 (was gated on partB_prediction) - cell at line 267 (was gated on partB_reflection) - cell at line 296 (was gated on partC_reflection) - cell at line 1468 (LEDGER_HUD, the expert-flagged dangling gate) cell signatures simplified where the gate dep was only used in the removed `mo.stop`. ## verification - `marimo check` — clean - `pytest labs/tests/test_engine.py -k lab_06_fault` — 2/2 passed (cells execute, produce outputs) - `pytest labs/tests/test_static.py -k lab_06_fault` — 20 passed; `test_no_widget_defined_in_gated_cell` XPASSED (lab no longer has the pattern) - programmatic `app.run()` — 12 cell outputs, 49 definitions, all 18 expected widgets + tabs cell defined - `marimo export html-wasm` — valid HTML produced ## net diff `4 insertions(+), 14 deletions(-)` — small and mechanical. ## related - #1347 tracks the 14-lab refactor effort - #1350 updated the test check to use the multi-widget-leak threshold (less strict than the original test in #1346) - if this lands cleanly, vol2/lab_07 through vol2/lab_16 + vol2/lab_01 + vol1/lab_00 follow the same template --- <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-05-03 01:15:12 -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#9044