Skip to content

[Experimental] Build the lectures with QuantEcon/mystmd instead of jupyter-book - #363

Open
kp992 wants to merge 62 commits into
mainfrom
jb2
Open

[Experimental] Build the lectures with QuantEcon/mystmd instead of jupyter-book#363
kp992 wants to merge 62 commits into
mainfrom
jb2

Conversation

@kp992

@kp992 kp992 commented Jul 23, 2025

Copy link
Copy Markdown

Experimental setup for building the lectures with the QuantEcon MyST stack. This PR is built on top of #345.

Current toolchain

Both workflows now build with the QuantEcon fork of the MyST CLI and the new theme, so the Netlify preview shows the latest content rendered by the latest tooling.

Piece What the branch uses Where it is set
MyST CLI QuantEcon/mystmd main, cloned and built from source with bun; quantecon/VERSION.yml is printed to the log so every build records the qe-vN fork state it ran with (currently v1.10.1 (qe-v8)) .github/workflows/ci.yml, .github/workflows/build-ipynb.yml
Theme quantecon-theme.mystmd v2.2.0, pinned to the release zip lectures/myst.yml (site.template)
Build command myst build --html --execute .github/workflows/ci.yml
Content merged up to date with main

The theme moves off the archived QuantEcon/quantecon-theme bundle (which the branch was still pulling as a floating main.zip) onto a pinned release of the new theme repo. Bump the vX.Y.Z in the site.template URL to take a newer theme; the fork stays on main deliberately, so the preview tracks the latest tooling.

The build was not actually using the fork

Worth calling out separately, because it had been green and invisible: until this update the HTML preview was built by jupyter book build, which cannot use the fork. jupyter-book 2.x is a thin Python shim — jupyter_book/__main__.py execs a compiled mystmd bundle vendored inside its own wheel (jupyter_book/dist/jupyter-book.cjs) and exposes no hook to point it at another CLI. The globally installed fork was simply ignored, and only the build-ipynb workflow (which calls myst directly) ever exercised it.

The last run before the fix shows it plainly: the jupyter-book HTML build emitted 27 × 'output' unknown export output extension: exports/<page>.ipynb, because the per-page ipynb export is a fork feature (myst-to-ipynb, qe-v1) that upstream does not know about. The same commit built by the fork's myst build --ipynb emitted none and exported 23 clean notebooks. The HTML build now runs myst build --html --execute — the same engine and the same flags, since jupyter-book 2.x is mystmd, just our build of it.

Everything else in this update

  • Merged main. Brings in the new Polars lecture, the numba rewrite, the pandas_panel switch to remote CSVs, and the translation-sync workflows. The one conflict was ci.yml, where main and this branch have rewritten the same job for different builders — resolved in favour of this branch's job, keeping main's runner spec and action bumps.
  • myst.yml TOC re-synced with _toc.yml. It had drifted: autodiff and the new polars lecture were missing, workspace appeared twice, and one part title differed. The two files now list exactly the same 27 pages.
  • project.github corrected to lecture-python-programming — it pointed at lecture-python-programming.myst, which now only survives as a rename redirect. The theme derives the notebook-launch repo from this value plus a .notebooks suffix, so a stale name means broken launch buttons.
  • JAX is now installed in the build. Previous preview builds were rendering ModuleNotFoundError cells for jax_intro, autodiff and numpy_vs_numba_vs_jax, because this job installed only myst_requirements.txt while the jupyter-book 1.x job on main installs jax[cuda13] separately. Same install, same runner family.
  • CI actions moved to current majors and Node 20 → 24 (the theme's .nvmrc; it runs as a Remix server during myst build --html). This also clears the Node 20 runtime deprecation warnings. The unused configure-pages step is gone — this job deploys to Netlify, not Pages.
  • Removed committed execution artifacts (foo.py, newfile.txt, numbers.txt, output.txt, output2.txt, test_table.csv, us_cities.txt). All are written by %%file / %%writefile cells in the lectures themselves, all are matched by .gitignore, and none exist on main.

Still open

  • Nothing fails the build on a notebook execution error. Execution errors are reported and the build carries on, which is how the JAX failures above survived green builds. main gained a gate for the jupyter-book 1.x path in CI: gate the first jb build so notebook errors cannot pass green #588; the fork's CLI has myst build --strict for this, but it should be turned on only once the remaining build diagnostics are triaged, or it will fail on unrelated warnings.
  • Launch-button URLs are left on the theme defaults (<repo>.notebooks, branch main, notebooks at the repo root), matching the layout of lecture-python-programming.notebooks. Worth clicking through in the preview to confirm the page location resolves as expected.

@github-actions

github-actions Bot commented Jul 23, 2025

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request July 23, 2025 01:19 Inactive
@kp992
kp992 requested a review from mmcky July 23, 2025 01:20
@kp992 kp992 added the do-not-merge Approved-looking but must not be merged yet (hold / pin) label Jul 23, 2025
@mmcky

mmcky commented Jul 23, 2025

Copy link
Copy Markdown
Contributor

@kp992 thanks for opening this. Excellent work! It is exciting to see how close we are now.

From my review it looks like there a just a few issues and features we need before launch.

Bugs:

  1. LHS TOC menu flickers when using the Home page or a top level Part section. It is like it has an auto-stow feature that is triggering when pages are reloaded. It doesn't look great when pages are refreshed.
  2. Code block formatting has too much indentation for Solution blocks

Features:

  1. I see a bunch of new export notebooks being added to the yaml headers of each lecture. Do we need to do some development work on supporting the download notebook link in the theme?
  2. Is index support on the jb2 / mystmd roadmap?

- Add `markdown: commonmark` to all 24 lecture export configs so ipynb
  exports produce plain CommonMark markdown cells compatible with
  vanilla Jupyter Notebook, JupyterLab, and Google Colab
- Add build-ipynb.yml workflow that clones QuantEcon/mystmd@myst-to-ipynb,
  builds from source, exports all ipynb files, and audits for MyST leaks
- All 24 notebooks pass audit (0 MyST syntax leaks)

Uses QuantEcon/mystmd myst-to-ipynb branch which adds:
- CommonMark AST pre-transform (admonitions, math, figures, exercises, etc.)
- Identifier/label stripping to prevent (label)= prefixes
- Image directive stripping for plain ![alt](url) output
- Empty cell filtering and block marker removal
@kp992

kp992 commented Aug 4, 2026

Copy link
Copy Markdown
Author

Thanks @mmcky for pushing this forward. Please let me know if you need help in taking this to finish line.

@mmcky

mmcky commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

thanks @kp992 this is currently updated and built to help us get our theme for mystmd across the line. @DrDrij is doing a pass on that now -- so once that is in place we will then be in a position to migrate.

@DrDrij

DrDrij commented Aug 18, 2026

Copy link
Copy Markdown
Member

Netlify preview only, not a production concern: assets here are served with cache-control: public,max-age=0,must-revalidate, so every navigation makes a blocking revalidation round-trip (~390ms for a 304 with 0 bytes) before first paint. GitHub Pages serves max-age=600, so the deployed lectures are unaffected. If it is worth making the preview behave like production, a _headers file with /build/_assets/* Cache-Control: public,max-age=31536000,immutable is safe — those filenames are content-hashed, so a rebuild changes the URL.

Takes the theme from v2.2.0 to v2.3.0, per the release notes in
QuantEcon/quantecon-theme.mystmd — git-history page headers (automatic,
from this repo's git log at build time), opt-in in-page live compute
via project.thebe (not enabled here), and CDN-free stylesheets
(KaTeX/jupyter-matplotlib self-hosted, Font Awesome dropped), so maths
renders correctly where jsdelivr/cdnjs are blocked.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mmcky

mmcky commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

@DrDrij I have just updated this to the latest release of quantecon-theme.mystmd incorporate recent merges.

mmcky and others added 2 commits August 20, 2026 14:16
Resolves the two ci.yml conflicts, both from main evolving steps that
jb2 rewrote for the mystmd toolchain:

- Install JAX: took main's side — the jax 0.11.0 pin rationale comment
  (jax 0.11.1 hangs fori_loop on CPU paths) and the numpyro install
  apply to the executed lectures regardless of build toolchain.
- The old jupyter-book steps (texlive, build-cache download, the
  jb clean prune from #616, sphinx-tojupyter): kept jb2's side — these
  steps do not exist in the myst pipeline, which builds cold with no
  restored sphinx cache, so the staleness problem the prune step
  addresses cannot occur here.

The execution-cache key hashes ci.yml, so this merge forces a cold
build — the pin, numpyro, and the v2.3.0 theme bump are all validated
by real execution rather than replayed outputs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Takes the icon-only search trigger, PT Serif headings, QuantEcon-blue links,
the Colab-only launcher and the first-paint fixes released today. Bumped
from v2.3.0, so v2.3.1 (static-build asset URLs) and v2.4.0 (content
typography, inline-code regression) come along too.

See QuantEcon/quantecon-theme.mystmd/releases/tag/v2.5.0.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@mmcky

mmcky commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Bumped the theme pin in lectures/myst.yml from v2.3.0 to v2.5.0 (7a392b8), released today. Between those tags the theme picked up the static-build asset URL fixes (2.3.1), lecture content typography and the inline-code backticks regression fix (2.4.0), and in 2.5.0 the icon-only search trigger, PT Serif headings on the Sphinx scale, QuantEcon-blue content links, the Colab-only launcher (the Private JupyterHub option is gone), and the back-to-top / FOUC first-paint fixes. Release notes: https://github.com/QuantEcon/quantecon-theme.mystmd/releases/tag/v2.5.0. No other change on the branch; the existing conflict with main is untouched.

# Conflicts:
#	.github/workflows/ci.yml
Takes the QuantEcon code-token palette and seoul256 text colours (Phase 3),
the language switcher with hreflang alternates, right-to-left support and
the translator credit (Phases 4-5). No new site options are set here yet;
the multilingual ones are for the translated editions.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@mmcky

mmcky commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Bumped the pinned theme to v2.6.0 in b9524ff. It brings the QuantEcon code-token palette and seoul256 text colours (Phase 3), and the language switcher, hreflang alternates, RTL support and translator credit (Phases 4–5). This edition sets none of the new multilingual options, so the only visible change here is the code and text colouring; the switcher appears once languages lists the translated editions.

Patch release carrying the fix for QuantEcon/quantecon-theme.mystmd#186:
on the Netlify preview, pressing Back after following an in-page anchor
replaced the page with an "Application Error" screen, and the "Top"
control did a full reload. No configuration changes are needed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@mmcky

mmcky commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Pinned theme bumped to v2.6.1, the patch release carrying the fix for QuantEcon/quantecon-theme.mystmd#186 (Back after an in-page anchor showed an "Application Error" screen on the Netlify preview; "↑ Top" did a full reload). No configuration changes. The preview built from this commit is the first real-content check of that fix.

v2.7.0 carries the last items of the book-theme parity gate: the pinned,
scroll-tracking "On this page" panel with nested subsections
(QuantEcon/quantecon-theme.mystmd#182), collapsible stderr warnings and the
full OpenGraph/Twitter card set (QuantEcon/quantecon-theme.mystmd#92), and a
layout correction for desktop windows 1280-1327px wide
(QuantEcon/quantecon-theme.mystmd#198). No configuration changes are needed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mmcky

mmcky commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Pinned theme bumped to v2.7.0 in 41b1f83. It carries the last items of the book-theme parity gate: the pinned, scroll-tracking "On this page" panel with nested subsections (QuantEcon/quantecon-theme.mystmd#182), stderr output folded behind a "Code warnings" disclosure (QuantEcon/quantecon-theme.mystmd#92), and a layout correction for desktop windows 1280–1327px wide (QuantEcon/quantecon-theme.mystmd#198). No configuration changes are needed; this branch sets no site.options, so of the new OpenGraph/Twitter tags only og:type and og:site_name appear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge Approved-looking but must not be merged yet (hold / pin)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants