Thank you for your interest in contributing to this agent-based model for mental health promotion cost-effectiveness research! This document provides guidelines for contributing to the project.
Start by forking the repository to your GitHub account:
# Clone your fork locally
git clone https://github.com/yourusername/abm-simulation.git
cd abm-simulation
# Add the original repository as upstream
git remote add upstream https://github.com/originalusername/abm-simulation.gitFor all contributions, start by creating a GitHub issue:
- Create a new issue with the label
enhancementor typefeature - Clearly describe the proposed feature and its rationale
- Explain how it fits into the existing model architecture
- If you'd like to implement it yourself, comment on the issue with your implementation plan
- Create a new issue with the label or type
bug - Include detailed reproduction steps
- Provide expected vs actual behavior
- Include relevant configuration parameters and error messages
When contributing code:
- Reference the existing issue in your pull request
- Explain your implementation approach
- Note any breaking changes or dependencies
The project uses a centralized configuration system. Never edit .env or .env.example directly.
-
Modify
src/python/config.py- This is the single source of truth for all parameters:# Add new parameter to appropriate section 'new_section': { 'new_parameter': 0.5, # Add default value and documentation 'parameter_description': 'Description of what this parameter does' }
-
Run the extraction script to update
.env:# Extract current parameter values from config.py bash src/shell/extract_env.sh -
Update
.env.examplewith the new parameter:# Update .env.example with new parameter and description bash src/shell/update_env_example.sh -
Test your changes:
# Verify the configuration loads correctly python -c "from src.python.config import get_config; print(get_config().get('new_section', 'new_parameter'))" # Run tests to ensure no regressions python -m pytest src/python/tests/test_config_integration.py -v
# Create and switch to a new branch
git checkout -b feature/your-feature-name
# Or for bug fixes
git checkout -b fix/issue-number-description- Follow the existing code style and patterns
- Add tests for new functionality
- Update documentation as needed
- Ensure all tests pass
# Stage your changes
git add .
# Write a clear commit message
git commit -m "Add: brief description of changes
- Detailed explanation of what was changed
- Why the change was made
- Any breaking changes or migration notes
- References to related issues"
# Example for a new feature
git commit -m "Add: social influence parameter for coping probability
- Added SOCIAL_INFLUENCE_FACTOR parameter to config.py
- Modified compute_coping_probability() in affect_utils.py
- Neighbor affect now influences individual coping success rates
- No breaking changes - uses default value of 0.3
- Closes #123"# Push your branch to GitHub
git push origin feature/your-feature-name
# Create a pull request through GitHub interfaceAll pull requests must include:
- What: Clear explanation of what the change does
- Why: Rationale for the change and problem it solves
- How: Technical implementation details
- Testing: How the change was tested
If your PR includes breaking changes:
- Clearly state what breaks and why
- Provide migration instructions
- Update version numbers if needed
If your PR adds new parameters:
- Confirm you've followed the configuration management process above
- Include the updated
.env.examplein your PR - Document the new parameters in
CONFIGURATION.md
- Follow PEP 8 guidelines
- Use type hints for function parameters and return values
- Maximum line length: 100 characters
- Use descriptive variable and function names
All pull requests must include comprehensive tests. New features will not be accepted without proper test coverage.
- Unit tests for every new function and class (required)
- Integration tests for cross-module interactions (required)
- Test coverage must meet or exceed 90% for modified files
- Edge case testing for boundary conditions and error scenarios
- Performance benchmarks for computationally intensive features
- Regression tests to prevent the bug from reoccurring (required)
- Unit tests for the specific fix (required)
- Integration tests if the fix affects multiple components (required)
- Parameter validation tests for new configuration options (required)
- Type checking tests for configuration value conversion (required)
- Boundary tests for parameter range validation (required)
Test Coverage Requirements:
- Minimum overall coverage: 85%
- Minimum coverage for new/modified files: 90%
- All new utility functions must have 100% coverage
- Use
python -m pytest --cov=src/python --cov-report=html --cov-fail-under=85to verify
- Update docstrings for modified functions
- Add feature documentation in
docs/features/for significant changes - Update
CONFIGURATION.mdfor new parameters
# Install dependencies (uses pixi.toml + pixi.lock)
pixi install
# Activate the environment in a subshell
pixi shell
# Or run a single command in the environment
pixi run python --version
# Activate hooks (required — prevents CI/CD failures)
pixi run install-hooks
**pre-commit** (fast check): Runs `pixi run prettify && pixi run format && pixi run lint` always, and runs tests (`pixi run test-cov && pixi run test-config`) when `*.py` files are staged.
**pre-push** (CI/CD mirror): Runs the full pipeline `pixi run prettify && pixi run format && pixi run lint && pixi run test-cov && pixi run test-config` on every push. This matches the GitHub Actions workflow in `.github/workflows/coverage-test.yml`.This project uses pixi tasks defined in pixi.toml. All common commands are available as tasks:
# Run all tests
pixi run test
# Run specific test categories
pixi run test-integration # Integration tests only
pixi run test-config # Configuration tests only
# Run with coverage (required for PRs)
pixi run test-cov
# Run performance benchmarks
pixi run benchmark
# Pass additional arguments to a task (use -- to separate)
pixi run test -- -v
pixi run test -- -k "your_feature"
pixi run test -- --cov=src.python.new_module --cov-report=html --cov-fail-under=90- Code Quality: Following style guidelines, clear logic, proper error handling
- Testing: Comprehensive test coverage (85%+ required), meaningful test cases, edge case coverage
- Documentation: Updated docstrings, parameter documentation
- Integration: No breaking changes, proper configuration management
- Performance: No significant performance regressions
PRs without adequate testing will be rejected. All new features must include:
- Unit tests for every new function
- Integration tests for cross-module changes
- Test coverage verification with
--cov-fail-under=85 - Edge case and error condition testing
- Address all reviewer comments
- Update your PR with requested changes
- Re-request review when ready
- Be open to alternative approaches
- Follow semantic versioning (MAJOR.MINOR.PATCH)
- Update version in
src/python/config.py - Tag releases with
vX.Y.Zformat
- All tests pass with 85%+ coverage
- New features include comprehensive unit and integration tests
- Documentation updated
- Configuration files updated
- Breaking changes documented
- Performance benchmarks pass
- Test coverage report generated and reviewed
- Issues: Search existing issues before creating new ones
- Discussions: Use for questions and ideas
- Documentation: Check
docs/folder for detailed information - Configuration: See
CONFIGURATION.mdfor parameter details
When asking for help:
- Reference specific files and line numbers when possible
- Include relevant configuration parameters
- Describe expected vs actual behavior
- Mention what you've already tried
Thank you for contributing to this research project! Your contributions help improve mental health promotion strategies and support evidence-based policymaking.
This contributing guide is adapted from best practices for academic software development and research reproducibility.