Contributing to Rompy
We welcome contributions from the community! This document provides guidelines and instructions for contributing to Rompy, including code changes, documentation improvements, bug fixes, and feature development.
Code of Conduct
Please read and follow our Code of Conduct to ensure a welcoming and inclusive environment for everyone.
How to Contribute
There are several ways you can contribute to Rompy:
- Report bugs and suggest features via GitHub issues
- Contribute code through pull requests
- Improve documentation
- Review pull requests from other contributors
- Help answer questions in the issue tracker
Development Setup
Prerequisites
- Python 3.10 or higher
- Git
- A code editor or IDE of your choice
- Basic familiarity with command-line tools
Setting Up Your Environment
- Fork the repository on GitHub
- Clone your fork:
- Create a virtual environment:
- Install the package in development mode:
- Install pre-commit hooks:
Making Code Changes
Branch Strategy
- Create a feature branch from
main: - Make your changes in the new branch
- Follow the project's coding style and conventions
Code Style
Rompy follows the PEP 8 style guide and uses Black for code formatting. The pre-commit hooks will automatically format your code before commits.
- Use clear, descriptive variable and function names
- Write docstrings for all public functions and classes
- Include type hints where appropriate
- Follow the existing code style in the project
Testing
All contributions should include appropriate tests:
- Add unit tests for new functionality
- Update existing tests if your changes affect current behavior
- Run the test suite before submitting your pull request:
- Ensure all tests pass
Documentation
When contributing code, update the documentation as needed:
- Update docstrings to reflect code changes
- Add or update examples in the documentation
- Update the API documentation if adding new public interfaces
Testing Procedures and Requirements
Running Tests
To run the full test suite:
To run tests for a specific module:
To run tests with coverage:
Writing Tests
- Place tests in the
tests/directory following the same structure as the source code - Use descriptive test function names
- Test both normal and edge cases
- Mock external dependencies when appropriate
Test Requirements
- All new features must include appropriate unit tests
- Bug fixes should include regression tests
- Tests should have clear, descriptive names and assertions
- Aim for high code coverage, especially for critical functionality
Debugging Techniques and Tools
Using Python Debugger (pdb)
Add breakpoints in your code for debugging:
Logging for Debugging
Use the Rompy logging system for debugging:
from rompy.logging import get_logger
logger = get_logger(__name__)
logger.debug("Debug message with variable: %s", variable)
Testing with Different Backends
Test your changes with different backends to ensure compatibility:
# Test with local backend
success = model_run.run(backend=LocalConfig(...))
# Test with Docker backend
success = model_run.run(backend=DockerConfig(...))
Code Review Process
Pull Request Requirements
Before submitting a pull request:
- Ensure all tests pass
- Update documentation as needed
- Add a clear description of the changes
- Include issue references if applicable (e.g., "Fixes #123")
- Add appropriate labels to your pull request
Review Process
- Submit your pull request to the
mainbranch - One or more maintainers will review your changes
- Address any feedback or requested changes
- Once approved, your changes will be merged
Code Review Guidelines
Reviewers will consider:
- Code quality and style adherence
- Correctness and test coverage
- Performance implications
- Impact on existing functionality
- Documentation completeness
Architecture and Design Guidelines
Rompy Architecture
Rompy follows a modular architecture with clear separation of concerns:
- Configuration: Model definitions using Pydantic models
- Execution: Backend-agnostic execution through backend plugins
- Data: Flexible data handling through source and data objects
- Results: Post-processing and output handling
Extending Rompy
To add new functionality:
- New Model Types: Use the plugin system with the
rompy.configentry point - New Data Sources: Extend from
SourceBaseclasses - New Backends: Implement the backend interface and register with
rompy.run - New Processors: Implement the processor interface and register with
rompy.postprocess
Getting Help
If you need help with your contribution:
- Check the existing documentation
- Search existing issues for similar problems
- Ask questions in the issue tracker
- Reach out to the maintainers via GitHub
Recognition
All contributors are recognized in the AUTHORS.rst file. Contributions of any size are valuable to the project.
Pull Request Process
- Create a feature branch
- Add your changes
- Add or update tests as appropriate
- Update documentation
- Ensure all tests pass
- Submit a pull request with a clear description
- Address review feedback
- Wait for approval and merge