Skip to content

CI: fail the event-generation notebook test if it has no code cells - #212

Open
ianna wants to merge 1 commit into
HEP-FCC:mainfrom
ianna:ci-notebook-code-guard
Open

ianna wants to merge 1 commit into
HEP-FCC:mainfrom
ianna:ci-notebook-code-guard

Conversation

@ianna

@ianna ianna commented Oct 8, 2026 •

Copy link
Copy Markdown

What

Adds one test, 2-gen-and-fastsim/2-1-event-generation/README-has-code-cells. It fails if the notebook jupytext produces from the event-generation page contains no code cells (.github/scripts/check_notebook_has_code.py). The other notebook tests are unchanged.

Why

Running a notebook with no code cells always succeeds. With CI's own versions, jupytext 1.16.0 (the stack's) and pandoc 3.10 (installed by test.yml), the event-generation page converts to a single markdown cell and zero code cells:

  • any line starting with ::: (the MyST admonitions) makes jupytext guess that the .md file is pandoc markdown;
  • pandoc only creates code cells from explicitly marked cells, so the page's ordinary code fences remain markdown.

The page's notebook test therefore passes without running anything.

Minimal reproduction: the yaml header plus a python and a bash fence gives 2 code cells; add one :::{admonition} block and you get 0.

Expected result

This PR is expected to turn the new test red until the conversion is fixed. Reproduced on LXPLUS with the stack's jupytext 1.16.0 and pandoc 3.10:

2-gen-and-fastsim/2-1-event-generation/README-has-code-cells (Failed)
.../README.ipynb: 1 cells, 0 code

The other five pages convert the same way. This PR deliberately covers only the generator page. add_nb_code_guard() can be applied to further pages later.

Not in this PR

How to fix the conversion is a separate decision. Removing the ::: lines (or forcing --from md) brings the code cells back, but then every fence on the page runs as a separate %%bash cell: cd and variables don't carry over between cells, and full-size jobs (10,000-event generation, Whizard, KKMCee) would run too. For this page, #211 instead runs tagged fragments.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

A line starting with ":::" (the pages' MyST admonitions) makes jupytext
read a .md file as pandoc markdown, and pandoc only turns explicitly
marked cells into code cells. The page therefore converts to a single
markdown cell, and executing it passes without running anything. Add a
has-code-cells test for the event-generation page so this is reported
instead of hidden. Other pages are left unchanged for now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UKgjg6FJ4R6Jbp3pdhqVQD
@ianna
ianna force-pushed the ci-notebook-code-guard branch from ddc5539 to 6c7464d Compare October 8, 2026 14:26
@ianna ianna changed the title CI: fail notebook tests whose converted page has no code cells CI: fail the event-generation notebook test if it has no code cells Oct 8, 2026

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant