Overview
Add a markdown-rendering pipeline to PyAutoBuild: curated flagship workspace examples are executed for real and rendered to .md files with their output images, committed to the workspace repo, so new users browsing GitHub can read the examples cleanly formatted with plots visible. GitHub already renders the output-stripped .ipynb mirror, so a no-image .md mirror adds nothing — the whole value is the executed images, which is why the set stays small and curated. This task builds the generator and pilots it on autolens_workspace; rollout to the remaining dataset types, the other workspaces and HowTo is phase 2.
Plan
- Build a generator in PyAutoBuild that converts each curated script to a notebook (reusing the existing py→ipynb machinery), executes it for real, and renders
.md + PNG output images into a markdown/ folder mirroring scripts/, plus an index page.
- Curated list is workspace-owned config (
config/build/markdown_examples.yaml); anything under a features/ folder is refused by rule.
- Execution is never TEST_MODE (truncated sampling produces wrong images). Model-fits rely on PyAutoFit's completed-run resume: the first build pays one full real sampling run per modeling script, and every regeneration loads the completed result near-instantly with correct plots. A per-script timeout guard fails loudly rather than truncating.
- Regeneration is manual / at-release, only when a flagged script changes — never per-commit.
- Pilot on autolens_workspace: root
start_here.py, the imaging five (start_here, simulator, likelihood_function, fit, modeling), and guides/{galaxies,lens_calc,tracer}.py. Commit the generated .md + images and link the index prominently from the README.
- Ship two PRs behind the four-leg gate: PyAutoBuild (generator + tests) and autolens_workspace (config, generated artifacts, README link). Ends at PR-open; merge stays human.
Detailed implementation plan
Affected Repositories
- PyAutoBuild (primary — the generator)
- autolens_workspace (pilot — curated config, generated
markdown/, README link)
Branch Survey
| Repository |
Current Branch |
Dirty? |
| ./PyAutoBuild |
main |
clean |
| ./autolens_workspace |
main |
1 stray untracked dataset.fits (left alone) |
Suggested branch: feature/markdown-example-renderings
Worktree root: ~/Code/PyAutoLabs-wt/markdown-example-renderings/
Implementation Steps
PyAutoBuild/autobuild/generate_markdown.py — new CLI, run from the workspace root like generate.py (python ../PyAutoBuild/autobuild/generate_markdown.py autolens [--only <substring>]):
- Read the curated list from
<workspace>/config/build/markdown_examples.yaml: a flat list of entries, each {script: <path relative to workspace root>, max_minutes: <int, default 60>}.
- Hard guards: refuse any script path containing
features/; refuse to run if PYAUTO_TEST_MODE is set (wrong images); error loudly on a missing script.
- Per script:
build_util.py_to_notebook(...) (reuse — do NOT re-implement the docstring→markdown-cell conversion; do NOT call inject_colab_setup), execute the notebook with cwd = workspace root and cell timeout = max_minutes*60 (nbclient or jupyter nbconvert --to notebook --execute), then nbconvert --to markdown into markdown/<script relpath without scripts/ prefix>/ — nbconvert emits <name>.md + <name>_files/*.png alongside.
- Inject a header line into each
.md: auto-generated notice + links back to the source .py and .ipynb.
- Generate
markdown/README.md index from the curated list (title + one-line hook per example, taken from the script's opening docstring title).
git add -f all generated outputs (mirrors copy_to_notebooks); verify none are swallowed by .gitignore (git check-ignore) — images must be tracked.
- PyAutoBuild tests (
tests/) — unit tests for config parsing, the features/ and TEST_MODE guards, and script→markdown path mapping. No execution in tests.
autolens_workspace/config/build/markdown_examples.yaml — the pilot list: start_here.py (workspace root), scripts/imaging/{start_here,simulator,likelihood_function,fit,modeling}.py, scripts/guides/{galaxies,lens_calc,tracer}.py. Generous max_minutes for imaging/modeling.py (real sampling, first run only).
- Run the pilot build in the task worktree with the PyAuto venv: only
imaging/modeling.py (and possibly the two start_here scripts if they sample) pays a real search; all others are fast real runs. The completed-run cache lands in the worktree's gitignored output/ — re-derivable, so worktree cleanup losing it is acceptable (images are committed).
autolens_workspace/README.md — prominent link near the top: browse the examples with output images → markdown/README.md.
- Verify rendering on GitHub — check the PR's rich diff / branch view shows the images inline (relative
<name>_files/ paths must resolve).
- Ship —
ship_library for PyAutoBuild, ship_workspace for autolens_workspace (library-first gate), four-leg autonomous-ship gate, PR-open.
Key Files
PyAutoBuild/autobuild/generate.py — existing py→ipynb pipeline; pattern for config resolution, iter_script_paths, git add -f
PyAutoBuild/autobuild/build_util.py — py_to_notebook (reused as-is)
autolens_workspace/config/build/ — home of the new markdown_examples.yaml (same pattern as copy_files.yaml)
autolens_workspace/scripts/imaging/*.py, scripts/guides/*.py, start_here.py — the pilot curated set
Phase 2 (separate prompt, filed when this ships)
Remaining autolens dataset types (interferometer, point_source, multi, group, weak; cluster is known-heavy — needs a runtime decision), autogalaxy_workspace + autofit_workspace curated sets, and the HowTo trio (curated list there still to be decided). The generator is built repo-agnostic so phase 2 is config + execution only.
Autonomy
--auto, effective safe (docs ≤ medium after phasing; header safe). Plan recorded here per the contract; run proceeds to PR-open behind the four-leg gate. No Heart YELLOW acknowledgement was given at launch — any YELLOW at ship parks the run.
Original Prompt
Click to expand starting prompt
Markdown renderings (with images) of curated workspace + HowTo examples
Type: docs
Target: PyAutoBuild
Difficulty: small
Autonomy: safe
Priority: normal
Status: formalised
Generate markdown (.md) renderings of a small curated subset of flagship examples across the workspaces (autofit/autogalaxy/autolens_workspace) AND the HowTo tutorials (HowToFit/HowToGalaxy/HowToLens), executed with real output images, so new users browsing GitHub can read them cleanly formatted with plots visible. Scope decided at intake: curated subset ONLY (skip a blanket no-image .md mirror — GitHub already renders the output-stripped .ipynb files natively, so no-image .md adds little); images committed in each workspace/HowTo repo next to its .md (PNGs at fixed dpi, .gitignore must not swallow them), not hosted externally. Generator slots into the PyAutoBuild pipeline alongside the existing py->ipynb generation: execute flagged scripts, nbconvert to markdown, write .md + image dir, plus an index page linked prominently from workspace and HowTo READMEs ('Browse the examples with output'). Regeneration is manual/at-release (real runs, not TEST_MODE), only when a flagged script changes. Original motivation verbatim: 'we could also make markdown (.md) files from the .py files... on github when a user browses the github webpages they can literally read every example there in a way that is more cleanly formatted than .py files... could do for a small subset of examples (e.g. to entice new users).'
Curated list (user-decided 2026-07-10): each workspace's start_here.py plus, per dataset type, simulator.py, likelihood_function.py, fit.py and modeling.py; NOTHING from any features/ folder; autolens_workspace guides/galaxies, guides/lens_calc and guides/tracer.py; and the base workspace start_here.py. Execution-time constraint: the image build must NOT spend ages sampling, but PYAUTO_TEST_MODE truncates the search and would produce WRONG images — think carefully here (e.g. run modeling searches once to completion and cache/load results for regeneration, or use fast-but-real search settings validated to give correct plots; TEST_MODE output images are unacceptable).
Overview
Add a markdown-rendering pipeline to PyAutoBuild: curated flagship workspace examples are executed for real and rendered to
.mdfiles with their output images, committed to the workspace repo, so new users browsing GitHub can read the examples cleanly formatted with plots visible. GitHub already renders the output-stripped.ipynbmirror, so a no-image.mdmirror adds nothing — the whole value is the executed images, which is why the set stays small and curated. This task builds the generator and pilots it on autolens_workspace; rollout to the remaining dataset types, the other workspaces and HowTo is phase 2.Plan
.md+ PNG output images into amarkdown/folder mirroringscripts/, plus an index page.config/build/markdown_examples.yaml); anything under afeatures/folder is refused by rule.start_here.py, the imaging five (start_here,simulator,likelihood_function,fit,modeling), andguides/{galaxies,lens_calc,tracer}.py. Commit the generated.md+ images and link the index prominently from the README.Detailed implementation plan
Affected Repositories
markdown/, README link)Branch Survey
dataset.fits(left alone)Suggested branch:
feature/markdown-example-renderingsWorktree root:
~/Code/PyAutoLabs-wt/markdown-example-renderings/Implementation Steps
PyAutoBuild/autobuild/generate_markdown.py— new CLI, run from the workspace root likegenerate.py(python ../PyAutoBuild/autobuild/generate_markdown.py autolens [--only <substring>]):<workspace>/config/build/markdown_examples.yaml: a flat list of entries, each{script: <path relative to workspace root>, max_minutes: <int, default 60>}.features/; refuse to run ifPYAUTO_TEST_MODEis set (wrong images); error loudly on a missing script.build_util.py_to_notebook(...)(reuse — do NOT re-implement the docstring→markdown-cell conversion; do NOT callinject_colab_setup), execute the notebook with cwd = workspace root and cell timeout =max_minutes*60(nbclient orjupyter nbconvert --to notebook --execute), thennbconvert --to markdownintomarkdown/<script relpath without scripts/ prefix>/— nbconvert emits<name>.md+<name>_files/*.pngalongside..md: auto-generated notice + links back to the source.pyand.ipynb.markdown/README.mdindex from the curated list (title + one-line hook per example, taken from the script's opening docstring title).git add -fall generated outputs (mirrorscopy_to_notebooks); verify none are swallowed by.gitignore(git check-ignore) — images must be tracked.tests/) — unit tests for config parsing, thefeatures/and TEST_MODE guards, and script→markdown path mapping. No execution in tests.autolens_workspace/config/build/markdown_examples.yaml— the pilot list:start_here.py(workspace root),scripts/imaging/{start_here,simulator,likelihood_function,fit,modeling}.py,scripts/guides/{galaxies,lens_calc,tracer}.py. Generousmax_minutesforimaging/modeling.py(real sampling, first run only).imaging/modeling.py(and possibly the twostart_herescripts if they sample) pays a real search; all others are fast real runs. The completed-run cache lands in the worktree's gitignoredoutput/— re-derivable, so worktree cleanup losing it is acceptable (images are committed).autolens_workspace/README.md— prominent link near the top: browse the examples with output images →markdown/README.md.<name>_files/paths must resolve).ship_libraryfor PyAutoBuild,ship_workspacefor autolens_workspace (library-first gate), four-leg autonomous-ship gate, PR-open.Key Files
PyAutoBuild/autobuild/generate.py— existing py→ipynb pipeline; pattern for config resolution,iter_script_paths,git add -fPyAutoBuild/autobuild/build_util.py—py_to_notebook(reused as-is)autolens_workspace/config/build/— home of the newmarkdown_examples.yaml(same pattern ascopy_files.yaml)autolens_workspace/scripts/imaging/*.py,scripts/guides/*.py,start_here.py— the pilot curated setPhase 2 (separate prompt, filed when this ships)
Remaining autolens dataset types (interferometer, point_source, multi, group, weak; cluster is known-heavy — needs a runtime decision), autogalaxy_workspace + autofit_workspace curated sets, and the HowTo trio (curated list there still to be decided). The generator is built repo-agnostic so phase 2 is config + execution only.
Autonomy
--auto, effective safe (docs ≤ medium after phasing; header safe). Plan recorded here per the contract; run proceeds to PR-open behind the four-leg gate. No Heart YELLOW acknowledgement was given at launch — any YELLOW at ship parks the run.Original Prompt
Click to expand starting prompt
Markdown renderings (with images) of curated workspace + HowTo examples
Type: docs
Target: PyAutoBuild
Difficulty: small
Autonomy: safe
Priority: normal
Status: formalised
Generate markdown (.md) renderings of a small curated subset of flagship examples across the workspaces (autofit/autogalaxy/autolens_workspace) AND the HowTo tutorials (HowToFit/HowToGalaxy/HowToLens), executed with real output images, so new users browsing GitHub can read them cleanly formatted with plots visible. Scope decided at intake: curated subset ONLY (skip a blanket no-image .md mirror — GitHub already renders the output-stripped .ipynb files natively, so no-image .md adds little); images committed in each workspace/HowTo repo next to its .md (PNGs at fixed dpi, .gitignore must not swallow them), not hosted externally. Generator slots into the PyAutoBuild pipeline alongside the existing py->ipynb generation: execute flagged scripts, nbconvert to markdown, write .md + image dir, plus an index page linked prominently from workspace and HowTo READMEs ('Browse the examples with output'). Regeneration is manual/at-release (real runs, not TEST_MODE), only when a flagged script changes. Original motivation verbatim: 'we could also make markdown (.md) files from the .py files... on github when a user browses the github webpages they can literally read every example there in a way that is more cleanly formatted than .py files... could do for a small subset of examples (e.g. to entice new users).'
Curated list (user-decided 2026-07-10): each workspace's start_here.py plus, per dataset type, simulator.py, likelihood_function.py, fit.py and modeling.py; NOTHING from any features/ folder; autolens_workspace guides/galaxies, guides/lens_calc and guides/tracer.py; and the base workspace start_here.py. Execution-time constraint: the image build must NOT spend ages sampling, but PYAUTO_TEST_MODE truncates the search and would produce WRONG images — think carefully here (e.g. run modeling searches once to completion and cache/load results for regeneration, or use fast-but-real search settings validated to give correct plots; TEST_MODE output images are unacceptable).