Thank you for your interest in contributing to pyAMARES! This document provides guidelines and instructions to help you contribute effectively.
We follow the GitHub Community Code of Conduct to foster an inclusive and respectful community.
Fork the repository on GitHub.
Clone your forked GitHub repository:
# Using SSH (if you have SSH keys set up) git clone git@github.com:YOUR_USERNAME/pyAMARES.git # Or using HTTPS git clone https://github.com/YOUR_USERNAME/pyAMARES.git
Create a virtual environment (
condarecommended):conda create -n pyamares-dev python=3.12 conda activate pyamares-dev
Note
You can replace
pyamares-devwith your preferred environment name.Install development dependencies:
pip install -e ".[dev]"Note
This installs the package in editable mode (
-e) along with all development dependencies specified in the[dev]extra of the project's setup (e.g., inpyproject.tomlorsetup.py). This typically includes tools for documentation, testing, linting, and formatting (likeSphinx,pytest,ruff,pre-commit).Initialize pre-commit hooks:
pre-commit install
Note
This sets up the git hooks defined in
.pre-commit-config.yamlto run automatically before each commit.
- Search existing issues before creating a new one.
- Clearly describe the problem or feature request.
- For bug reports, please include steps to reproduce the issue.
Create a new branch for your changes:
git checkout -b feature/your-feature-name
Make your changes, following our code style guidelines.
Commit your changes:
# Add your changed files git add path/to/your/changed/file.py # Commit with a descriptive message git commit -m "feat: Add concise description of changes"
Note
If you've installed the pre-commit hooks (Step 5 in Setup), code quality checks (like
Ruffformatting/linting) will run automatically on commit. Follow any instructions if checks fail.Push your changes to your fork:
git push origin feature/your-feature-name
Open a Pull Request on the pyAMARES GitHub repository. Provide a clear description of your changes in the Pull Request.
We follow a consistent code style to ensure readability and maintainability. Our code style is primarily enforced by Ruff.
Ruff is an extremely fast Python linter and formatter.
Running Ruff manually:
# Check your code for issues
ruff check .
# Fix issues automatically where possible
ruff check --fix .
# Format your code
ruff format .Configuration:
Our Ruff configuration is defined in pyproject.toml:
.. literalinclude:: ../../pyproject.toml
We use pre-commit to automatically check and format code before each commit, ensuring consistency across the codebase.
The configuration is in .pre-commit-config.yaml. If you've followed the setup instructions, these checks will run automatically when you run git commit.
You can also run them manually across all files:
pre-commit run --all-filesWrite tests using
pytestfor new features and bug fixes. Place tests in thetests/directory.Run tests locally before submitting a Pull Request:
pytest
Ensure your changes do not break existing functionality and that all tests pass.
To build the documentation locally:
Ensure you've installed the necessary dependencies. This is usually covered by
pip install -e ".[dev]"or specifically viapip install -e ".[doc]".Navigate to the documentation directory (often
docs/) and build usingSphinx:# Assuming you are in the root project directory sphinx-build -a docs/source/ docs/build/View the generated documentation by opening
docs/build/index.htmlin your web browser.
- Our documentation is written primarily in reStructuredText (reST) format (
.rstfiles) found in thedocs/source/directory. - Significant parts of the documentation, especially the API reference, are automatically generated from docstrings within the Python code using
Sphinx autodoc. We recommend following the Google Style Python Docstrings format for docstrings for consistency and clarity, though this is not strictly mandated. - Check your local documentation build (using the steps above) for warnings or errors before submitting your changes. Ensure links work, code examples are correct, and formatting looks as expected.
If you need any additional help, please feel free to open a new issue.
Thank you for contributing to pyAMARES!