Skip to content

Commit b7eff1e

Browse files
Jammy2211claude
authored andcommitted
Add AI agent configs, issue templates, and update contributing guide
- AGENTS.md, .github/copilot-instructions.md for AI agent support - notify-workspaces.yml to dispatch API updates to autofit_workspace - Issue templates for feature requests and bug reports - CONTRIBUTING.md updated with AI-first workflow and code example guidance Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 95223b4 commit b7eff1e

7 files changed

Lines changed: 295 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: Bug Report
3+
about: Report a bug or unexpected behaviour
4+
title: 'fix: '
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
## Description
10+
11+
<!-- Clear description of the bug -->
12+
13+
## Steps to Reproduce
14+
15+
1.
16+
2.
17+
3.
18+
19+
## Expected Behaviour
20+
21+
<!-- What should happen -->
22+
23+
## Actual Behaviour
24+
25+
<!-- What actually happens -->
26+
27+
## Environment
28+
29+
- OS:
30+
- Python version:
31+
- Package version:
32+
33+
## Original Prompt
34+
35+
<details>
36+
<summary>Click to expand starting prompt</summary>
37+
38+
<!-- If this issue was created from an AI prompt, paste the original prompt here -->
39+
40+
</details>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: Feature / Task Request
3+
about: Propose a new feature, improvement, or task
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
## Overview
10+
11+
<!-- 2-4 sentence summary of what this task is and why it matters -->
12+
13+
## Plan
14+
15+
<!-- High-level bullet-point plan, human readable, no code -->
16+
17+
<details>
18+
<summary>Detailed implementation plan</summary>
19+
20+
### Affected Repositories
21+
<!-- List repos this touches, mark primary -->
22+
23+
### Implementation Steps
24+
<!-- Step-by-step with file paths and specifics -->
25+
26+
### Key Files
27+
<!-- List files that will be modified -->
28+
29+
</details>
30+
31+
## Example Code
32+
33+
<!-- If your feature involves a specific calculation, algorithm, or small piece of functionality,
34+
include example code here. Even a rough script, a working prototype, or a snippet showing
35+
the existing behaviour you want changed helps enormously.
36+
37+
Code gives AI agents and human contributors concrete context and dramatically reduces
38+
misunderstandings. Delete this section if not applicable. -->
39+
40+
```python
41+
# Paste your example code here
42+
```
43+
44+
## Original Prompt
45+
46+
<details>
47+
<summary>Click to expand starting prompt</summary>
48+
49+
<!-- If this issue was created from an AI prompt, paste the original prompt here -->
50+
51+
</details>

.github/copilot-instructions.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copilot Coding Agent Instructions
2+
3+
You are working on **PyAutoFit**, a Python probabilistic programming library for model fitting and Bayesian inference.
4+
5+
## Key Rules
6+
7+
- Run tests after every change: `python -m pytest test_autofit/`
8+
- Format code with `black autofit/`
9+
- All files must use Unix line endings (LF, `\n`)
10+
- If changing public API (function signatures, class names, import paths), clearly document what changed in your PR description — downstream packages depend on this
11+
12+
## Architecture
13+
14+
- `autofit/non_linear/search/` — Non-linear search algorithms (MCMC, nested sampling, MLE)
15+
- `autofit/mapper/` — Model composition and prior machinery
16+
- `autofit/graphical/` — Graphical models and expectation propagation
17+
- `autofit/aggregator/` — Results aggregation
18+
- `autofit/database/` — SQLAlchemy results database
19+
- `test_autofit/` — Test suite
20+
21+
## Sandboxed runs
22+
23+
```bash
24+
NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib python -m pytest test_autofit/
25+
```
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Notify downstream workspaces when a PR is merged to main.
2+
#
3+
# Sends a repository_dispatch event to each workspace repo so they can
4+
# trigger an automated API update (via Copilot coding agent or similar).
5+
#
6+
# Required secret:
7+
# WORKSPACE_DISPATCH_TOKEN — PAT with repo scope on the target workspace
8+
# repositories.
9+
10+
name: Notify Workspaces
11+
12+
on:
13+
pull_request:
14+
types: [closed]
15+
branches: [main]
16+
17+
jobs:
18+
dispatch:
19+
if: github.event.pull_request.merged == true
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
workspace:
24+
- Jammy2211/autofit_workspace
25+
steps:
26+
- name: Send repository_dispatch
27+
env:
28+
GH_TOKEN: ${{ secrets.WORKSPACE_DISPATCH_TOKEN }}
29+
run: |
30+
gh api --method POST \
31+
-H "Accept: application/vnd.github+json" \
32+
"/repos/${{ matrix.workspace }}/dispatches" \
33+
-f "event_type=api-update" \
34+
-f "client_payload[pr_number]=${{ github.event.pull_request.number }}" \
35+
-f "client_payload[pr_title]=${{ github.event.pull_request.title }}" \
36+
-f "client_payload[pr_branch]=${{ github.event.pull_request.head.ref }}" \
37+
-f "client_payload[pr_url]=${{ github.event.pull_request.html_url }}"

AGENTS.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# PyAutoFit — Agent Instructions
2+
3+
**PyAutoFit** is a Python probabilistic programming language for model fitting and Bayesian inference.
4+
5+
## Setup
6+
7+
```bash
8+
pip install -e ".[dev]"
9+
```
10+
11+
## Running Tests
12+
13+
```bash
14+
python -m pytest test_autofit/
15+
python -m pytest test_autofit/non_linear/
16+
python -m pytest test_autofit/mapper/
17+
```
18+
19+
### Sandboxed / Codex runs
20+
21+
```bash
22+
NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib python -m pytest test_autofit/
23+
```
24+
25+
## Key Architecture
26+
27+
- **Non-linear searches** (`non_linear/search/`): MCMC (emcee), nested sampling (dynesty, nautilus), MLE (LBFGS, pyswarms)
28+
- **Model composition** (`mapper/`): `af.Model`, `af.Collection`, prior distributions
29+
- **Analysis** (`non_linear/analysis/`): base `af.Analysis` class with `log_likelihood_function`
30+
- **Aggregator** (`aggregator/`): results aggregation across runs
31+
- **Database** (`database/`): SQLAlchemy backend for results storage
32+
- **Graphical models** (`graphical/`): expectation propagation
33+
34+
## Key Rules
35+
36+
- All files must use Unix line endings (LF)
37+
- Format with `black autofit/`
38+
39+
## Working on Issues
40+
41+
1. Read the issue description and any linked plan.
42+
2. Identify affected files and write your changes.
43+
3. Run the full test suite: `python -m pytest test_autofit/`
44+
4. Ensure all tests pass before opening a PR.
45+
5. If changing public API, note the change in your PR description — downstream packages (PyAutoArray, PyAutoGalaxy, PyAutoLens) and workspaces may need updates.

CLAUDE.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# PyAutoFit
2+
3+
**PyAutoFit** is a Python probabilistic programming language for model fitting and Bayesian inference.
4+
5+
- Authors: James Nightingale, Richard Hayes
6+
- Requires Python >= 3.9
7+
- Package name: `autofit`
8+
9+
## Repository Structure
10+
11+
- `autofit/` - Main package
12+
- `non_linear/` - Non-linear search algorithms
13+
- `search/mcmc/` - MCMC (emcee, zeus)
14+
- `search/mle/` - Maximum likelihood (LBFGS, pyswarms)
15+
- `search/nest/` - Nested sampling (dynesty, nautilus, ultranest)
16+
- `samples/` - Posterior samples handling
17+
- `paths/` - Output path management
18+
- `analysis/` - Analysis base classes
19+
- `mapper/` - Model and prior machinery
20+
- `prior/` - Prior distributions
21+
- `prior_model/` - Prior model composition
22+
- `model.py` - Core model class
23+
- `graphical/` - Graphical models and expectation propagation
24+
- `aggregator/` - Results aggregation across runs
25+
- `database/` - SQLAlchemy-based results database
26+
- `interpolator/` - Model interpolation
27+
- `config/` - Default config files packaged with library
28+
- `test_autofit/` - Test suite (pytest)
29+
- `docs/` - Sphinx documentation
30+
31+
## Key Dependencies
32+
33+
- `dynesty==2.1.4` - Nested sampling
34+
- `emcee>=3.1.6` - MCMC
35+
- `pyswarms==1.3.0` - Particle swarm optimisation
36+
- `scipy<=1.14.0` - Optimisation
37+
- `SQLAlchemy==2.0.32` - Database backend
38+
- `anesthetic==2.8.14` - Posterior analysis/plotting
39+
- Optional: `nautilus-sampler`, `ultranest`, `zeus-mcmc`, `getdist`
40+
41+
## Running Tests
42+
43+
```
44+
pytest test_autofit
45+
pytest test_autofit/non_linear
46+
pytest test_autofit/mapper
47+
```
48+
49+
## Codex / sandboxed runs
50+
51+
When 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:
52+
53+
```bash
54+
NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib pytest test_autofit
55+
```
56+
57+
This 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.
58+
59+
## Shell Commands
60+
61+
- Prefer simple shell commands
62+
- Avoid chaining with `&&` or pipes; run commands separately
63+
64+
## Related Repos
65+
66+
- **autofit_workspace** (tutorials/examples): `../autofit_workspace`

CONTRIBUTING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
# AI-Assisted Development
2+
3+
This project uses an AI-first development workflow. Most features, bug fixes, and improvements are implemented through AI coding agents (Claude Code, GitHub Copilot, OpenAI Codex) working from structured issue descriptions.
4+
5+
## How It Works
6+
7+
1. **Issues are the starting point** — Every task begins as a GitHub issue with a structured format: an overview, a human-readable plan, a detailed implementation plan (in a collapsible block), and optionally the original prompt that generated the issue.
8+
9+
2. **AI agents pick up issues** — Issues can be assigned to AI coding agents (e.g. GitHub Copilot) which read the issue description, `AGENTS.md`, and `CLAUDE.md` for context, then implement the changes autonomously.
10+
11+
3. **Human review** — All AI-generated pull requests are reviewed by maintainers before merging.
12+
13+
## Creating an Issue
14+
15+
When opening an issue, please use the provided issue templates. The **Feature / Task Request** template follows our standard format:
16+
17+
- **Overview** — What and why, in 2-4 sentences
18+
- **Plan** — High-level bullet points (human-readable)
19+
- **Detailed implementation plan** — File paths, steps, key files (in a collapsible block)
20+
- **Original Prompt** — If you used an AI to help draft the issue, include the original prompt
21+
22+
If your feature involves a specific calculation, algorithm, or small piece of functionality — **include example code**. Even a rough script, a working prototype, or a snippet showing the existing behaviour you want to change makes a huge difference. Code examples give AI agents and human contributors concrete context to work from, and dramatically reduce misunderstandings about what you're asking for.
23+
24+
This structure ensures that both human contributors and AI agents can understand and act on the issue effectively.
25+
26+
## Contributing Without AI
27+
28+
Traditional contributions are equally welcome! If you prefer to work without AI tools, simply follow the development setup and pull request guidelines below. The issue templates are helpful for any contributor, AI or human.
29+
30+
---
31+
132
# Contributing
233

334
Contributions are welcome and greatly appreciated!

0 commit comments

Comments
 (0)