Getting Started
This guide will help you install Quick Metric and set up your development environment.
Prerequisites
| Requirement | Version | Description |
|---|---|---|
| Python | 3.9+ | Required for modern type hints and dependency compatibility |
| Git | Latest | Version control system for cloning the repository |
| uv (Optional) | Latest | Fast Python package manager (recommended for dependency management) |
Pipeline Integration
Quick Metric includes optional support for pipeline integration with oops-its-a-pipeline. This dependency is automatically installed and enables advanced workflow capabilities. All pipeline functionality is optional for standalone metric processing.
Installation
Choose your preferred installation method:
Install directly from the GitHub repository:
Development Installation
For development work, see the Development Setup section below.
Quick Start Example
Here's a minimal example to verify your installation:
from quick_metric import metric_method, generate_metrics
import pandas as pd
@metric_method
def count_records(data):
"""Count the number of records in the DataFrame."""
return len(data)
# Create sample data
data = pd.DataFrame({
'category': ['A', 'B', 'A', 'C'],
'value': [10, 20, 30, 40]
})
# Define configuration
config = {
'basic_count': {
'method': ['count_records'],
'filter': {}
}
}
# Generate metrics
results = generate_metrics(data, config)
print(results['basic_count']['count_records']) # Should print: 4
If this example runs successfully, you're ready to explore the Usage Guide!
Development Setup
For contributing to Quick Metric or working with the source code:
git clone https://github.com/nhsengland/quick_metric.git # (1)!
cd quick_metric # (2)!
uv venv # (3)!
source .venv/bin/activate # (4)!
uv pip install -e ".[dev,docs]" # (5)!
uv pip install pre-commit # (6)!
uv run pre-commit install # (7)!
- Clone the repository from GitHub
- Navigate to the project directory
- Create a virtual environment using uv
- Activate the virtual environment (On Windows:
.venv\Scripts\activate) - Install in development mode with all dependencies
- Install pre-commit for code quality hooks
- Set up pre-commit hooks to run automatically on commits
git clone https://github.com/nhsengland/quick_metric.git # (1)!
cd quick_metric # (2)!
python -m venv .venv # (3)!
source .venv/bin/activate # (4)!
pip install -e ".[dev,docs]" # (5)!
pip install pre-commit # (6)!
pre-commit install # (7)!
- Clone the repository from GitHub
- Navigate to the project directory
- Create a virtual environment using Python's built-in venv
- Activate the virtual environment (On Windows:
.venv\Scripts\activate) - Install in development mode with all dependencies
- Install pre-commit for code quality hooks
- Set up pre-commit hooks to run automatically on commits
Contribution Guidelines
This project follows modern Python development practices:
- Linting & Formatting: We use
rufffor code formatting and linting - Testing:
pytestwith structured unit and end-to-end tests - Dependency Management:
uvis preferred for faster dependency resolution - Documentation:
mkdocswith Material theme - Docstrings: NumPy-style docstring format
For detailed contribution guidelines, see our Contributing Guide.
Pre-commit Hooks
We strongly recommend setting up pre-commit hooks during development. These automatically run code quality checks before each commit, preventing issues early in the development process. Pre-commit hooks are included in both development setup methods above.
Development Workflow
Testing
uv run python -m pytest # (1)!
uv run python -m pytest tests/unit/test_output_formats.py # (2)!
uv run python -m pytest --cov=quick_metric # (3)!
uv run python -m pytest --cov=quick_metric --cov-report=html # (4)!
- Run all tests in the project
- Run a specific test file
- Run tests with coverage reporting
- Generate an HTML coverage report for detailed analysis
Code Quality
uv run ruff format quick_metric/ tests/ # (1)!
uv run ruff check quick_metric/ tests/ # (2)!
make lint # (3)!
- Format code automatically according to project standards
- Check for linting issues and code quality problems
- Run all quality checks using the Makefile (if available)
Documentation
- Serve documentation locally with live reload for development
- Build static documentation files for deployment
- Deploy to GitHub Pages (maintainers only)
Next Steps
Now that you have Quick Metric installed, explore these resources:
- Usage Guide - Comprehensive guide to all Quick Metric features
- API Reference - Detailed API documentation
- Configuration Guide - Learn how to write effective YAML configurations