A Cookiecutter template for creating standardised NHS England Reproducible Analytical Pipeline (RAP) projects.
This template provides a standardised project structure for developing Reproducible Analytical Pipelines within NHS England. It includes pre-configured tooling for testing, linting, documentation, and dependency management following modern Python development practices.
Reproducible Analytical Pipelines (RAP) is a set of tools, principles, and techniques to help you improve your analytical processes. With RAP, you leverage open-source tools to make your work more efficient, more reusable, and less error-prone.
The core RAP principles from the NHS RAP Community of Practice are:
| Principle | Description |
|---|---|
| Automation | Minimise manual, error-prone steps through automation |
| Modular, reusable code | Write code in independent, loosely-coupled functions |
| Transparency | Publish code openly under appropriate licences |
| Open-source tools | Use Python, R, and other freely available languages |
| Version control | Use Git to track changes to code |
| Good coding practices | Follow standards like PEP8, use clear documentation |
| Testing | Implement automated tests for reliability |
| Peer review | Review code collaboratively to ensure quality |
Learn more about RAP at the NHS RAP Community of Practice website.
This template requires Python 3.10 or higher. This package is not published to PyPI, so install directly from GitHub:
pipx (recommended for CLI tools):
pipx install git+https://github.com/nhsengland/nhse-rap-cookiecutter.gitSee the pipx documentation for installation instructions.
uv:
uv tool install git+https://github.com/nhsengland/nhse-rap-cookiecutter.gitSee the uv documentation for installation instructions.
pip:
pip install git+https://github.com/nhsengland/nhse-rap-cookiecutter.gitGenerate a new project using the CLI tool:
nhs-rap-templateOr use the official cookiecutter command:
cookiecutter gh:nhsengland/nhse-rap-cookiecutterThe template prompts for the following information:
| Category | Option | Description | Choices |
|---|---|---|---|
| Project | project_name | Human-readable project name | Text |
| description | Brief project description | Text | |
| author_name | Your full name | Text | |
| author_email | Your email address | Text | |
| organization_name | Your organisation (fixed: NHS England) | Text | |
| team_name | Your team name | Text | |
| team_email | Team contact email (optional) | Text | |
| Python | python_version_number | Minimum Python version | 3.10, 3.11, 3.12 |
| environment_manager | Virtual environment tool | virtualenv, conda, pipenv, uv, pixi, poetry, none | |
| dependency_file | Dependency management file | requirements.txt, pyproject.toml, environment.yml, Pipfile | |
| pydata_packages | Include pandas, numpy, matplotlib | yes, no | |
| Options | include_code_scaffold | Include example code modules | yes, no |
| testing_framework | Testing framework | pytest, unittest | |
| license | Project licence | MIT, BSD-3-Clause, none | |
| documentation | Documentation tool | mkdocs, none |
your-project/
├── data/
│ ├── external/ # Data from third-party sources
│ ├── interim/ # Intermediate transformed data
│ ├── processed/ # Final canonical datasets
│ └── raw/ # Original immutable data
├── docs/ # MkDocs documentation with NHS styling
├── models/ # Trained models and predictions
├── notebooks/ # Jupyter notebooks for exploration
├── references/ # Data dictionaries and documentation
├── reports/
│ └── figures/ # Generated graphics
├── tests/
│ ├── pytest/ # Pytest tests
│ └── unittest/ # Unittest tests
├── your_module/ # Source code package
│ ├── __init__.py
│ ├── config.py # Configuration management
│ ├── dataset.py # Data loading and processing
│ ├── features.py # Feature engineering
│ ├── plots.py # Visualisation functions
│ └── modeling/
│ ├── train.py # Model training
│ └── predict.py # Model inference
├── LICENSE
├── Makefile # Convenience commands
├── README.md
└── pyproject.toml # Project configuration and dependencies
After generating a project:
cd your-project-name
uv sync # Set up environment
uv run pre-commit install # Install pre-commit hooks
make test # Run tests
make docs # Build documentationFull documentation: https://nhsengland.github.io/nhse-rap-cookiecutter
See CONTRIBUTING.md for development setup and contribution guidelines.
uv run pytest tests/ -v # Run tests
uv run pytest tests/ --cov=nhse_rap_cookiecutter --cov-report=term # With coverage
uv run ruff format . && uv run ruff check . # Format and lint
make docs-serve # Serve docs with live reloadUnless stated otherwise, the codebase is released under the MIT Licence. This covers both the codebase and any sample code in the documentation.
HTML and Markdown documentation is © Crown copyright and available under the terms of the Open Government 3.0 licence.
This template is based on Cookiecutter Data Science, adapted for NHS England RAP standards and modern Python tooling.