Thank you for your interest in contributing to WASP2! This document provides guidelines and instructions for contributing.
- Code of Conduct
- First-Time Contributors
- Development Setup
- Running Tests
- Code Style
- Branch Workflow
- Issue Guidelines
- Pull Request Process
- Troubleshooting
- License
This project follows the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
New to WASP2? Welcome! Here's how to get started:
- Look for issues labeled
good first issueorhelp wanted - Comment on the issue to let maintainers know you're working on it
- Fork the repository and follow the Development Setup
- Submit your PR following the Pull Request Process
We welcome contributions of all sizes, from typo fixes to new features!
WASP2 is a hybrid Python/Rust project. You'll need both toolchains to build from source.
| Requirement | Version | Notes |
|---|---|---|
| Python | 3.10+ | 3.10, 3.11, 3.12 supported (conda env uses 3.11) |
| Rust | 1.70+ | Edition 2021 |
| Git | 2.0+ | For version control |
| C compiler | gcc/clang | Required for native extensions |
Note: WASP2 is developed and tested on Linux and macOS. Windows is not officially supported.
-
Clone the repository:
git clone https://github.com/mcvickerlab/WASP2.git cd WASP2 -
Create a Python virtual environment:
Using conda (recommended):
conda env create -f environment.yml conda activate WASP2
Or using venv:
python -m venv .venv source .venv/bin/activate # Linux/macOS pip install -e ".[dev]" # Includes maturin and dev tools
-
Install the Rust toolchain (if not already installed):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source ~/.cargo/env
-
Build the Rust extension:
# Development build (faster compile, debug symbols) maturin develop -m rust/Cargo.toml # Release build (optimized) maturin develop --release -m rust/Cargo.toml
-
Install pre-commit hooks:
pip install pre-commit pre-commit install
-
Verify the installation:
make verify-cli
The project includes a Makefile with common development commands:
make help # Show all available commands
make build # Build Rust extension and install package
make rust-dev # Build Rust extension in debug mode
make test # Run all tests
make lint # Run all linters
make format # Format all code
make security # Run security checks (bandit, cargo audit)# Run all tests
pytest tests/ -v
# Run quick validation tests
pytest tests/test_validation_quick.py -v
# Run specific test markers
pytest tests/ -v -m "unit" # Unit tests only
pytest tests/ -v -m "integration" # Integration tests only
pytest tests/ -v -m "rust" # Rust backend tests
pytest tests/ -v -m "not slow" # Exclude slow tests
# Run with coverage
pytest tests/ --cov=src --cov-report=htmlcd rust
cargo testFor contributors with access to test data:
# Download test data from GitHub release
make download-sanity-data
# Run sanity tests
make test-sanityWe use ruff for linting and formatting:
# Check for issues
ruff check src/ tests/
# Auto-fix issues
ruff check --fix src/ tests/
# Format code
ruff format src/ tests/Key style settings (configured in pyproject.toml):
- Line length: 100 characters
- Target Python version: 3.10
- Import sorting: isort-compatible via ruff
We use cargo fmt and clippy:
cd rust
# Format code
cargo fmt
# Run linter
cargo clippy -- -D warningsPre-commit hooks run automatically on git commit. To run manually:
pre-commit run --all-filesThe hooks include:
- ruff: Python linting and formatting
- pre-commit-hooks: File hygiene (trailing whitespace, end-of-file, YAML validation, large files, merge conflicts, private keys, AST validation)
- bandit: Python security linting
- gitleaks: Secret detection
- basedpyright: Type checking
Run security checks before submitting PRs:
# Python security audit
bandit -c pyproject.toml -r src/
# Dependency vulnerability scan
pip-audit
# Rust security audit
cd rust && cargo auditWe use a feature branch workflow with PRs to main:
feature/* ─┐
fix/* ─┼──→ main
docs/* ─┘
feature/<description>- New featuresfix/<description>- Bug fixesdocs/<description>- Documentation updatesrefactor/<description>- Code refactoringtest/<description>- Test additions or fixes
-
Create a feature branch from
main:git checkout main git pull origin main git checkout -b feature/your-feature-name
-
Make your changes and commit:
git add . git commit -m "feat: add your feature description"
-
Push and create a pull request:
git push -u origin feature/your-feature-name
We follow Conventional Commits:
| Prefix | Purpose |
|---|---|
feat: |
New feature |
fix: |
Bug fix |
docs: |
Documentation changes |
style: |
Code style changes (formatting, no logic change) |
refactor: |
Code refactoring |
test: |
Adding or updating tests |
chore: |
Maintenance tasks |
perf: |
Performance improvements |
ci: |
CI/CD changes |
- Search existing issues to avoid duplicates
- Check the documentation for answers
- Ensure you're using the latest version
Include:
- WASP2 version (
pip show wasp2orpython -c "import wasp2; print(wasp2.__version__)") - Python version (
python --version) - Operating system and version
- Minimal reproducible example
- Expected vs. actual behavior
- Full error traceback
Include:
- Clear description of the proposed feature
- Use case and motivation
- Example of how it would be used
No Contributor License Agreement (CLA) is required. By submitting a PR, you agree your contributions will be licensed under the MIT License.
-
Ensure your code passes all checks:
make lint make test -
Update documentation if needed (docstrings, README, etc.)
-
Add tests for new functionality
-
Create the pull request:
- Use a clear, descriptive title
- Reference any related issues (e.g., "Fixes #123")
- Describe what changes were made and why
- Include any relevant screenshots or output
-
Address review feedback promptly
- Code follows the project's style guidelines
- Tests pass locally (
make test) - Linting passes (
make lint) - Security checks pass (
make security) - New code is tested
- Documentation is updated (if applicable)
- Commit messages follow conventional commits
Maturin build fails with "cargo not found":
source ~/.cargo/env # Add Rust to PATHPre-commit hooks fail on first run:
pre-commit run --all-files # Run once to cache hooksImport errors after building:
pip install -e ".[dev]" --force-reinstallRust extension not loading:
maturin develop --release -m rust/Cargo.toml
python -c "import wasp2_rust; print('OK')"By contributing to WASP2, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to WASP2!