Contributing¶
Contributions to rompy-swan are welcome! This guide covers how to set up a development environment and contribute to the project.
Development Setup¶
Clone the Repository¶
Create a Virtual Environment¶
Install in Development Mode¶
Install Pre-commit Hooks¶
Running Tests¶
With coverage:
Code Style¶
Rompy-swan uses:
- Black for code formatting
- isort for import sorting
- flake8 for linting
- mypy for type checking
Run all checks:
Documentation¶
Build Docs Locally¶
Then open http://localhost:8000 in your browser.
Writing Documentation¶
- Use Markdown for all documentation
- Follow the existing structure in
docs/ - Add docstrings to all public classes and functions
- Include examples in docstrings
Pull Request Process¶
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Update documentation as needed
- Submit a pull request
Adding New Components¶
When adding new SWAN components:
- Create the component class in the appropriate module under
rompy_swan/components/ - Inherit from
BaseComponent - Implement the
cmd()method - Add the
model_typefield as aLiteral - Add tests in
tests/ - Add documentation in
docs/components/
Example:
from typing import Literal
from pydantic import Field
from rompy_swan.components.base import BaseComponent
class MY_COMMAND(BaseComponent):
"""My new SWAN command.
This command does something useful.
Examples
--------
>>> cmd = MY_COMMAND(param=1.0)
>>> print(cmd.render())
MY_COMMAND param=1.0
"""
model_type: Literal["my_command"] = Field(
default="my_command",
description="Model type discriminator",
)
param: float = Field(
default=1.0,
description="Parameter description",
ge=0.0,
)
def cmd(self) -> str:
return f"MY_COMMAND param={self.param}"
Reporting Issues¶
Please report issues on the GitHub issue tracker.
Include:
- Python version
- rompy-swan version
- Minimal reproducible example
- Expected vs actual behavior
Questions¶
For questions, please use GitHub Discussions.