|
| 1 | +# Contributing to MRI-toolkit |
| 2 | + |
| 3 | +Thank you for your interest in contributing to `mri-toolkit`! We welcome contributions from the community, whether it's reporting bugs, suggesting features, or submitting code changes. |
| 4 | + |
| 5 | +This document outlines the guidelines for contributing to ensure a smooth process for everyone involved. |
| 6 | + |
| 7 | +## Table of Contents |
| 8 | +1. [Reporting Issues](#reporting-issues) |
| 9 | +2. [Setting Up Your Development Environment](#setting-up-your-development-environment) |
| 10 | +3. [Code Style and Quality](#code-style-and-quality) |
| 11 | +4. [Running Tests](#running-tests) |
| 12 | +5. [Submitting a Pull Request](#submitting-a-pull-request) |
| 13 | +6. [License](#license) |
| 14 | + |
| 15 | +## Reporting Issues |
| 16 | + |
| 17 | +If you encounter a bug or have a feature request, please use the [GitHub Issues](https://github.com/scientificcomputing/mri-toolkit/issues) tracker. |
| 18 | + |
| 19 | +* **Bugs:** Please provide a detailed description of the issue, including the steps to reproduce it, the expected behavior, and the actual behavior. |
| 20 | +* **Feature Requests:** Describe the feature you would like to see and why it would be useful. |
| 21 | + |
| 22 | +## Setting Up Your Development Environment |
| 23 | + |
| 24 | +To start contributing, you'll need to set up a local development environment. `mri-toolkit` supports Python versions **3.10** and above. |
| 25 | + |
| 26 | +1. **Fork and Clone the Repository:** |
| 27 | + ```bash |
| 28 | + git clone [https://github.com/](https://github.com/)<your-username>/mri-toolkit.git |
| 29 | + cd mri-toolkit |
| 30 | + ``` |
| 31 | + |
| 32 | +2. **Create a Virtual Environment:** |
| 33 | + It is recommended to use a virtual environment to manage dependencies. |
| 34 | + ```bash |
| 35 | + python3 -m venv venv |
| 36 | + source venv/bin/activate # On Windows: venv\Scripts\activate |
| 37 | + ``` |
| 38 | + |
| 39 | +3. **Install Dependencies:** |
| 40 | + Install the package in editable mode along with the test dependencies. |
| 41 | + ```bash |
| 42 | + pip install -e ".[test]" |
| 43 | + ``` |
| 44 | + |
| 45 | +4. **Install Pre-commit Hooks:** |
| 46 | + We use [pre-commit](https://pre-commit.com/) to ensure code quality before commits are made. |
| 47 | + ```bash |
| 48 | + pip install pre-commit |
| 49 | + pre-commit install |
| 50 | + ``` |
| 51 | + |
| 52 | +## Code Style and Quality |
| 53 | + |
| 54 | +We strictly enforce code style and quality standards to maintain a clean codebase. Our CI pipeline will fail if these checks are not met. |
| 55 | + |
| 56 | +* **Linter & Formatter:** We use **Ruff** for both linting and formatting. It is configured in `pyproject.toml` to enforce specific rules (e.g., line length of 100). |
| 57 | +* **Type Checking:** We use **Mypy** for static type checking. |
| 58 | +* **Pre-commit Hooks:** The following checks are run automatically on every commit via `pre-commit`: |
| 59 | + * Trailing whitespace removal |
| 60 | + * End-of-file fixing |
| 61 | + * YAML and TOML syntax checks |
| 62 | + * Ruff (linting and formatting) |
| 63 | + * Mypy (type checking) |
| 64 | + |
| 65 | +To run these checks manually on all files: |
| 66 | +```bash |
| 67 | +pre-commit run --all-files |
| 68 | +``` |
| 69 | +Note that these hooks will run automatically on the staged files when you commit, so you don't need to run them manually every time. |
| 70 | +
|
| 71 | +
|
| 72 | +## Submitting a Pull Request |
| 73 | +1. **Create a New Branch:** |
| 74 | + ```bash |
| 75 | + git checkout -b feature/your-feature-name |
| 76 | + ``` |
| 77 | +2. **Make Your Changes:** Implement your changes and ensure that they adhere to the code style guidelines. |
| 78 | +3. **Run Tests:** Make sure all tests pass before submitting your pull request. |
| 79 | + ```bash |
| 80 | + pytest |
| 81 | + ``` |
| 82 | +4. **Commit Your Changes:** |
| 83 | + ```bash |
| 84 | + git add . |
| 85 | + git commit -m "Add a descriptive commit message" |
| 86 | + ``` |
| 87 | +5. **Push Your Branch:** |
| 88 | + ```bash |
| 89 | + git push origin feature/your-feature-name |
| 90 | + ``` |
| 91 | +6. **Create a Pull Request:** Go to the original repository on GitHub and create a pull request from your branch. Provide a clear description of the changes you made and any relevant information. |
| 92 | +
|
| 93 | +## Running Tests |
| 94 | +
|
| 95 | +We use **pytest** for testing. Before submitting a PR, ensure all tests pass locally. |
| 96 | +
|
| 97 | +1. **Download Test Data:** |
| 98 | + Some tests require specific data. You can download this using the CLI included in the toolkit. |
| 99 | + ```bash |
| 100 | + # Downloads data to the 'test_data' folder (or your preferred location) |
| 101 | + python -m mritk download-test-data test_data |
| 102 | + ``` |
| 103 | + *Note: You may need to set the `MRITK_TEST_DATA_FOLDER` environment variable if you download the data to a custom location.* |
| 104 | +
|
| 105 | +2. **Run the Test Suite:** |
| 106 | + ```bash |
| 107 | + python -m pytest |
| 108 | + ``` |
| 109 | +
|
| 110 | + To generate a coverage report: |
| 111 | + ```bash |
| 112 | + python -m pytest --cov=mritk --cov-report html --cov-report term-missing |
| 113 | + ``` |
| 114 | +
|
| 115 | +## Submitting a Pull Request |
| 116 | +
|
| 117 | +1. **Create a Branch:** Create a new branch for your feature or bug fix. |
| 118 | + ```bash |
| 119 | + git checkout -b feature/my-new-feature |
| 120 | + ``` |
| 121 | +2. **Make Changes:** Implement your changes. Ensure you write tests for new features or bug fixes. |
| 122 | +3. **Commit Changes:** Commit your changes with a descriptive message. The `pre-commit` hooks will run automatically to fix style issues. |
| 123 | +4. **Push:** Push your branch to your fork. |
| 124 | + ```bash |
| 125 | + git push origin feature/my-new-feature |
| 126 | + ``` |
| 127 | +5. **Open a PR:** Go to the original repository and open a Pull Request. |
| 128 | + * The CI pipeline (GitHub Actions) will automatically run tests on Ubuntu, Windows, and macOS across Python versions 3.10–3.14. |
| 129 | + * Ensure all checks pass. |
| 130 | +
|
| 131 | +## License |
| 132 | +
|
| 133 | +By contributing to `mri-toolkit`, you agree that your contributions will be licensed under the [MIT License](LICENSE). |
0 commit comments