This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
PyAutoBuild is a CI/CD build server for the PyAuto software family (PyAutoConf, PyAutoFit, PyAutoArray, PyAutoGalaxy, PyAutoLens). It automates:
- Building and releasing packages to TestPyPI, then PyPI
- Running workspace Python scripts (integration tests)
- Converting Python scripts to Jupyter notebooks and executing them
- Updating workspace
releasebranches with generated notebooks
The pipeline is triggered via GitHub Actions (release.yml) and is manually dispatched with configurable options.
Before triggering a build, run:
bash /mnt/c/Users/Jammy/Code/PyAutoLabs/PyAutoBuild/pre_build.sh [minor_version]
# minor_version defaults to 1This script does the following for each repo:
| Repo | black | generate.py | commit & push |
|---|---|---|---|
autofit_workspace |
yes | yes (autofit) |
yes |
autogalaxy_workspace |
yes | yes (autogalaxy) |
yes |
autolens_workspace |
yes | yes (autolens) |
yes |
autofit_workspace_test |
yes | no | yes |
autolens_workspace_test |
yes | no | yes |
generate.py is run from the workspace root with PYTHONPATH pointing at PyAutoBuild/autobuild/. Only specific safe directories are committed — never output/, output_model/, or run-generated artefacts. After all workspaces are done, PyAutoBuild itself is committed and pushed, then gh workflow run release.yml dispatches the GitHub Actions release.
Each workspace repo (autofit_workspace, autogalaxy_workspace, autolens_workspace, and their _test variants) has the following expected structure. Only these paths should ever be committed.
| Folder / file | autofit | autogalaxy | autolens | Notes |
|---|---|---|---|---|
config/ |
yes | yes | yes | PyAutoConf config files |
dataset/ |
yes | yes | yes | Input data; force-added with git add -f |
notebooks/ |
yes | yes | yes | Generated from scripts/ by generate.py |
scripts/ |
yes | yes | yes | Source Python scripts |
slam_pipeline/ |
no | no | yes | autolens only |
output/ |
— | — | — | Always empty — kept under git with a .gitignore only |
| Root-level files | yes | yes | yes | README.md, setup.py, pyproject.toml, requirements.txt, *.cfg, *.ini, *.yml, *.yaml, LICENSE* |
output/contents — run results; the folder itself exists only via.gitignoreoutput_model/— model JSON/pickle artefacts written during script executionpath/to/model/or any nested model JSON files written at runtime.fitsfiles outsidedataset/(e.g.image.fits,dataset.fitsgenerated by simulators intoscripts/or other subdirectories)
# Run all tests
pytest
# Run a single test
pytest tests/test_files_to_run.py::test_script_orderWhen running Python from Codex or any restricted environment, set writable cache directories so numba and matplotlib do not fail on unwritable home or source-tree paths:
NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib pytestThis workspace is often imported from /mnt/c/... and Codex may not be able to write to module __pycache__ directories or /home/jammy/.cache, which can cause import-time numba caching failures without this override.
All scripts in autobuild/ are run from within a checked-out workspace directory (not from this repo root). They rely on PYTHONPATH including the PyAutoBuild directory.
run_python.py <project> <directory>— Executes Python scripts in a workspace folder, skipping files listed inconfig/no_run.yamlrun.py <project> <directory> [--visualise]— Executes Jupyter notebooks in a workspace folder, skipping files inconfig/no_run.yamlgenerate.py <project>— Converts Python scripts inscripts/to.ipynbnotebooks innotebooks/, run from within the workspace rootscript_matrix.py <project1> [project2 ...]— Outputs a JSON matrix of{name, directory}pairs for GitHub Actions matrix strategytag_and_merge.py --version <version>— Tags library repos for release
generate.py → generate_autofit.py + build_util.py:
add_notebook_quotes.pytransforms triple-quoted docstrings into# %%cell markers in a temp.pyfileipynb-py-convertconverts the temp file to.ipynbbuild_util.uncomment_jupyter_magic()restores commented-out Jupyter magic commands (e.g.# %matplotlib→%matplotlib)- Generated notebooks are
git add -fed directly
build_util.find_scripts_in_folder() enforces a specific ordering:
- Scripts with "simulator" in the path (data must be generated first)
- Scripts named
start_here.py - All other scripts
no_run.yaml— Per-project lists of script/notebook stems to skip during executioncopy_files.yaml— Per-project lists of files to copy as-is tonotebooks/instead of convertingvisualise_notebooks.yaml— Per-project lists of notebooks to run when--visualiseflag is usednotebooks_remove.yaml— Notebooks to remove
BUILD_PYTHON_INTERPRETER— Python interpreter to use for script execution (defaults topython3)PYAUTOFIT_TEST_MODE— Set to1for workspace runs,0for*_testworkspace runsPYAUTO_WORKSPACE_SMALL_DATASETS— Set to1for workspace runs (caps grids to 15x15), not set for*_testrunsPYAUTO_FAST_PLOTS— Set to1for workspace runs (skipstight_layout()in subplots and critical curve/caustic overlays in plots), not set for*_testrunsJAX_ENABLE_X64— Set toTrueduring CI runs
The workflow (release.yml) is manually dispatched with inputs:
minor_version— appended to date-based version (format:YYYY.M.D.minor)skip_scripts/skip_notebooks/skip_release— flags to skip pipeline stagesupdate_notebook_visualisations— runs notebooks with--visualiseand pushes toreleasebranch
The find_scripts job uses script_matrix.py to dynamically generate the matrix for parallel run_scripts and run_notebooks jobs.