Skip to content

build-lectures: no _build/.doctrees clear (ipywidget mimetype rendering) #98

Closed as not planned

Description

@mmcky

v0.8.0 validation study: two native pipelines clear the Sphinx doctree cache before the final HTML build to fix ipywidget mimetype rendering — lecture-python-intro (.github/workflows/publish.yml:90), lecture-python-advanced.myst (.github/workflows/publish.yml:91). Composite build-lectures has none: nothing here touches .doctrees; its pre-build HTML steps are only Stage PDF (build-lectures/action.yml:51) and Stage notebooks (build-lectures/action.yml:70).

Intra-job trigger, not a stale cache: jb writes one shared _build/.doctrees, so HTML in a three-format job reads doctrees from the earlier pdflatex and jupyter builds; reproduces cold. That pdflatex → jupyter → html sequence is the migration target (docs/MIGRATION-GUIDE.md:313-332); single-builder consumers like lecture-dp (builder: 'html') are out of scope. Unreproduced — inferred from the native BUG: comment.

No zero-build A/B — no clear-free repo emits widget output:

  • lecture-python-advanced.myst/lectures/matsuyama.md: sole ipywidgets import among migrated repos, cells skip-execution (no mimetype emitted), and that repo clears.

  • lecture-python-intro (also clears): executed rich output in markov_chains_I.md (HTML(anim.to_jshtml())) and inequality.md (plotly).

  • lecture-python-programming.myst: clear-free in production, but no executed widget/animation/plotly output.

  • QuantEcon/test-actions-lecture-intro: composite, no clear, no cache restore, but its canary TOC builds five rich-free lectures (geom_series, short_path, lln_clt, solow, linear_equations) under only_build_toc_files: true, unpublished since 2026-02-10; widening cuts against _toc.yml's no-content-drift criteria — separate decision.

  • Repro: build intro's markov_chains_I and inequality through the composite pdflatex → jupyter → html with no clear; compare to the published native site.

  • Matches → the clear is not load-bearing for current content; close wontfix with the negative result recorded.

  • Diverges → add an optional clear-doctrees input (default off) to the build-lectures HTML path, plus a MIGRATION-GUIDE note for repos coming from native pipelines.

  • Lower priority: the cache stores _build wholesale (restore-jupyter-cache/action.yml:109), so .doctrees rides along on restore — re-check once Optimize preview builds: phased plan for the fastest PR previews (tracking) #92 Phase 1 turns on save-cache: 'true'.

Activity

  1. added
    bug
    low-priority
    on Aug 11, 2026
  2. mmcky commented on Nov 15, 2026

    @mmcky
    ContributorAuthor

    Re-checked against main at v0.20.0 (0fada07) on 2026-11-15, before work on this starts. Most of the facts hold. Line numbers have moved, one path is gone, and the scope is narrower than PLAN and QuantEcon/meta#348 say.

    What holds

    • lecture-python-intro still clears the doctrees before its final html build: in publish.yml (the BUG: comment at :85, the rm at :90, the build at :91), and in ci.yml too (:80, :85, :86). Its publish.yml runs pdflatex, then jupyter, then html.
    • lecture-python-advanced.myst clears them too, now at publish.yml:100 and ci.yml:87.
    • lecture-python-programming (renamed from lecture-python-programming.myst) clears nothing in ci.yml, publish.yml or cache.yml. Its publish.yml already runs html last (pdflatex at :94, jupyter at :103, html at :118).
    • No action in this repository touches .doctrees. build-lectures' staging steps are now at build-lectures/action.yml:162 (the PDF) and :188 (the notebooks).
    • The builders share _build/.doctrees, and build-jupyter-cache runs jupyter, pdflatex, then html (build-jupyter-cache/action.yml:297, :310, :323), so its html build reads the doctrees the other two wrote.
    • It is still unreproduced. Nothing on record goes beyond the native BUG: comment.

    What has moved

    • docs/MIGRATION-GUIDE.md no longer exists. The migration steps are in Migrating an existing repository, which is where the note in the third outcome belongs.
    • The cache: build-jupyter-cache saves the whole of _build (build-jupyter-cache/action.yml:474), and restore-jupyter-cache's default cache-type: build restores it, removing only the html (restore-jupyter-cache/action.yml:262), so .doctrees comes back with it. Since feat(restore-jupyter-cache): the templates restore the execution cache, keyed on the environment too (#270) #280 the templates restore cache-type: 'execution' (templates/ci.yml:174), which leaves .doctrees out.
    • The canary, QuantEcon/test-actions-lecture-intro, still builds no rich output: its toc keeps five lectures chosen to need no network, so it can't carry the repro.

    Where the executed rich output is

    Repository Clears doctrees Executed widget, animation or interactive plotly output
    lecture-python-intro Yes markov_chains_I.md: HTML(anim.to_jshtml()) at :890 and :984. inequality.md: a plotly fig.show() at :767–:775
    lecture-python-advanced.myst Yes None found. matsuyama.md's interactive cell is skip-execution (:801); the plotly lectures render static PNGs, with every fig.show() commented out
    lecture-python-programming No None. plotly appears only as a link (about_py.md:430)

    So this issue bears on lecture-python-intro alone. lecture-python-programming already builds html last on shared doctrees in production with nothing to clear, so its move to the full chain doesn't wait on this.

    For the repro

    • The lecture matrix (test-containers-lectures.yml) builds html first, so as it stands it can't show this. The repro needs html last, after jupyter and pdflatex, with no clear, which is how build-jupyter-cache runs them.
    • markov_chains_I needs no network. inequality's plotly figure is built from World Bank data fetched at build time (inequality.md:723, and :553 and :572 before it), and the page also reads two remote CSVs (:250, :622). An empty or failed response there is not a result for this issue.
    • Both lectures are compared with intro's published pages.

    Claude Code (on behalf of mmcky), organiser session

  3. mmcky commented on Nov 15, 2026

    @mmcky
    ContributorAuthor

    Reproduced: no difference. The doctrees clear is not load-bearing. Built in the quantecon image (jupyter-book 1.0.4.post1, myst-nb 1.4.0, Sphinx 7.4.7) with this repository's build-lectures, on a toc trimmed to lecture-python-intro's markov_chains_I and inequality, plus a synthetic page with an executed ipywidgets slider and two plotly figures. Run 43683024646.

    An html build after jupyter and pdflatex on one _build/.doctrees, with no clear, renders every page the same as one after rm -r _build/.doctrees. That holds in build-jupyter-cache's order (jupyter, pdflatex, html) and in the native pipelines' order (pdflatex, jupyter, html, where html reuses the doctrees the jupyter build read). It also holds when html reuses doctrees that pdflatex read. Both animations on markov_chains_I, and the slider's widget view and state, render in every build. Apart from Sphinx's ?v= query on three CSS links, which depends only on whether _build/html already existed, the pages are byte-identical. A negative control, html with text/plain first, shows the failure mode, and the comparison caught it.

    This is what myst-nb's design predicts. It stores every mimetype of an output in the doctree and chooses one per builder at write time (SelectMimeType, a post-transform), so no builder's choice is kept for the next. In build-jupyter-cache's order, html re-reads every page anyway, because the pdflatex build changes numfig_secnum_depth for a book with parts. A PR's html build over a restored cache-type: build cache re-reads every page too, since a fresh checkout makes every source newer than its doctree.

    inequality gave no result: the World Bank API failed in all three runs. Its plotly figure would show nothing on any builder in any case: plotly 6's default renderer in a kernel emits only application/vnd.plotly.v1+json, which myst-nb drops. That is a separate lecture-python-intro matter, not this issue.

    Closing as not needed: build-lectures gets no clear-doctrees input. A repository coming from a native pipeline can drop its rm -r _build/.doctrees.

    Claude Code (on behalf of mmcky)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglow-priority

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions