From 1e857e3a44af1c5c1783c6fe0ab640647871c187 Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Wed, 12 Aug 2026 13:07:39 +1000 Subject: [PATCH 1/4] DIAGNOSTIC (do not merge): probe which code cells thebe-lite actually executes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Temporary page to settle QuantEcon/lecture-wasm#64 by measurement rather than inference. It exists to make a silent failure visible. The problem it solves: when a cell does not execute under thebe-lite there is no error and no output — and for an assignment cell, "no output" is also the CORRECT result. Those two states are indistinguishable by eye, which is what made this bug take several wrong turns to pin down. So every cell here appends a marker to a list, and a final top-level REPORT cell prints which markers are present and which are MISSING. One click on that cell names every cell that silently did nothing. Positions probed, all in the same document: A top level - control, must work B top level, `%%file` magic - tests the MAGIC independently of nesting C top level, reads B's file back - did %%file actually write? D inside a gated {exercise-start} - the position that fails in short_path E inside a gated {solution-start} - the position that WORKS in short_path, but only because a malformed directive spills it to root level F inside a plain {note} admonition - is it exercises, or nesting generally? B and C are the ones that matter for the fix: `%%file` under thebe-lite has never actually been tested. It was assumed broken, and that assumption was wrong — the cell it was tried in was nested and never ran at all. If B/C pass at top level, `%%file` is viable and lecture-wasm can converge with the five sibling repos instead of carrying a divergent string-based helper forever. Not for merge. Delete the branch once #64 has its answer. --- lectures/probe_nesting.md | 78 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 lectures/probe_nesting.md diff --git a/lectures/probe_nesting.md b/lectures/probe_nesting.md new file mode 100644 index 0000000..ab5c629 --- /dev/null +++ b/lectures/probe_nesting.md @@ -0,0 +1,78 @@ +--- +title: "PROBE — which code cells actually execute?" +--- + +# Probe: which code cells actually execute under thebe-lite? + +Temporary diagnostic page. **Not for merge.** Run the cells top to bottom, then run +the final REPORT cell — it names every cell that actually executed, so a cell that +silently did nothing is visible rather than ambiguous. + +## Setup (top level — control, must work) + +```{code-cell} ipython3 +ran = [] +ran.append("A_toplevel_setup") +print("A ok") +``` + +## B — top level, `%%file` magic (tests the magic independently of nesting) + +```{code-cell} ipython3 +%%file probe_b.txt +hello-from-B +``` + +```{code-cell} ipython3 +import os +ran.append("C_toplevel_after_magic") +print("C: probe_b.txt exists?", os.path.exists("probe_b.txt")) +if os.path.exists("probe_b.txt"): + print("C: contents =", open("probe_b.txt").read().strip()) +``` + +## D — inside a GATED exercise + +```{exercise-start} +:label: probe_ex +``` +Prose inside the gated exercise. + +```{code-cell} ipython3 +ran.append("D_in_gated_exercise") +print("D ok") +``` +```{exercise-end} +``` + +## E — inside a GATED solution + +```{solution-start} probe_ex +:class: dropdown +``` +```{code-cell} ipython3 +ran.append("E_in_gated_solution") +print("E ok") +``` +```{solution-end} +``` + +## F — inside a plain admonition + +```{note} +```{code-cell} ipython3 +ran.append("F_in_note") +print("F ok") +``` +``` + +## REPORT (top level) + +```{code-cell} ipython3 +expected = ["A_toplevel_setup", "C_toplevel_after_magic", + "D_in_gated_exercise", "E_in_gated_solution", "F_in_note"] +print("EXECUTED:", ran) +print("MISSING :", [e for e in expected if e not in ran]) +import os +print("%%file worked at top level:", os.path.exists("probe_b.txt")) +``` From fdd0b9df903d3a89a46bfe3f80607509bbfabd86 Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Wed, 12 Aug 2026 13:38:14 +1000 Subject: [PATCH 2/4] DIAGNOSTIC: actually add the probe page to the toc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The probe page was committed but never reached the toc, so mystmd did not build it and the preview 404s — 42 pages published, none of them the probe. Cause: the edit that was supposed to add it matched on the wrong indentation (` toc:` / ` - file:` where this file has ` toc:` / ` - file:`), and the script printed a success message unconditionally instead of asserting the replacement had happened. A silent no-op reported as done — the same failure mode this probe exists to expose, which is a fair thing to have walked into. This version asserts the anchor matches exactly once and re-reads the file to confirm the entry is present before exiting. Also drops the `.md` extension to match every other toc entry in this file. --- lectures/myst.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lectures/myst.yml b/lectures/myst.yml index 8ed2593..49fafa4 100644 --- a/lectures/myst.yml +++ b/lectures/myst.yml @@ -35,6 +35,7 @@ project: # - localStorage toc: - file: intro.md + - file: probe_nesting - title: Economic Data children: - file: long_run_growth From 913e762aed6d5a9409a44abcc7c47998ac2f7aa6 Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Wed, 12 Aug 2026 13:42:05 +1000 Subject: [PATCH 3/4] DIAGNOSTIC: fix the probe's own fencing, which broke the REPORT cell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `{note}` container used three backticks around a three-backtick code-cell, so the inner fence closed the outer directive. Everything after it was absorbed: the REPORT cell's value began with the literal markdown ## REPORT (top level) ```{code-cell} ipython3 and would have raised SyntaxError rather than reporting anything — the probe would have failed in a way that says nothing about what it is probing. A container directive wrapping a code-cell needs MORE backticks than the cell. The gated `{exercise-start}` / `{solution-start}` forms are unaffected: they are standalone directives rather than containers, which is why D and E nested correctly while F's block leaked. Now asserts its own structure after writing: exactly 7 code cells, none containing markdown, and the REPORT cell starting where it should. --- lectures/probe_nesting.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lectures/probe_nesting.md b/lectures/probe_nesting.md index ab5c629..6ceec7d 100644 --- a/lectures/probe_nesting.md +++ b/lectures/probe_nesting.md @@ -59,12 +59,12 @@ print("E ok") ## F — inside a plain admonition -```{note} +````{note} ```{code-cell} ipython3 ran.append("F_in_note") print("F ok") ``` -``` +```` ## REPORT (top level) From 6d934fc79e27f3bf90c13a83df3e1de94859f02c Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Wed, 12 Aug 2026 13:42:38 +1000 Subject: [PATCH 4/4] DIAGNOSTIC: give the probe a kernelspec, or it gets no kernel at all MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The page rendered but showed no JupyterLite power button, so nothing on it could be run — the probe was unrunnable for a reason unrelated to what it probes. Cause: its frontmatter carried only `title`. Every real lecture here carries `jupytext` + `kernelspec`, and without a kernelspec mystmd does not treat the page as a notebook, so thebe never attaches a kernel. Frontmatter is now copied from short_path.md, the page this probe is modelling. This is worth recording rather than just fixing, because it is a third distinct way a cell can fail to execute here, each silent in its own way: 1. no kernelspec -> whole page has no kernel, no run controls 2. nested in a directive -> cell renders with controls but is never wired up 3. cell simply not run -> indistinguishable from a cell that ran and printed nothing, which is the normal case for an assignment All three look like "nothing happened". Only the third is the reader's fault, and the probe's REPORT cell is designed to separate it from the other two. --- lectures/probe_nesting.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lectures/probe_nesting.md b/lectures/probe_nesting.md index 6ceec7d..765b390 100644 --- a/lectures/probe_nesting.md +++ b/lectures/probe_nesting.md @@ -1,4 +1,14 @@ --- +jupytext: + text_representation: + extension: .md + format_name: myst + format_version: 0.13 + jupytext_version: 1.16.7 +kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 title: "PROBE — which code cells actually execute?" ---