|
| 1 | +# Contributing to Vector Inference |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Vector Inference! This guide will help you get started with development, testing, and documentation contributions. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- Python 3.10 or newer |
| 10 | +- [uv](https://github.com/astral-sh/uv) for dependency management |
| 11 | + |
| 12 | +### Setting Up Development Environment |
| 13 | + |
| 14 | +1. Clone the repository: |
| 15 | + ```bash |
| 16 | + git clone https://github.com/VectorInstitute/vector-inference.git |
| 17 | + cd vector-inference |
| 18 | + ``` |
| 19 | + |
| 20 | +2. Install development dependencies: |
| 21 | + ```bash |
| 22 | + uv sync --all-extras --group dev |
| 23 | + ``` |
| 24 | + |
| 25 | +3. Install pre-commit hooks: |
| 26 | + ```bash |
| 27 | + pre-commit install |
| 28 | + ``` |
| 29 | + |
| 30 | +!!! tip "Using Virtual Environments" |
| 31 | + If you prefer using virtual environments, you can use `uv venv` to create one: |
| 32 | + ```bash |
| 33 | + uv venv |
| 34 | + source .venv/bin/activate |
| 35 | + ``` |
| 36 | + |
| 37 | +## Development Workflow |
| 38 | + |
| 39 | +### Code Style and Linting |
| 40 | + |
| 41 | +We use several tools to ensure code quality: |
| 42 | + |
| 43 | +- **ruff** for linting and formatting |
| 44 | +- **mypy** for type checking |
| 45 | + |
| 46 | +You can run these tools with: |
| 47 | + |
| 48 | +```bash |
| 49 | +# Linting |
| 50 | +uv run ruff check . |
| 51 | + |
| 52 | +# Type checking |
| 53 | +uv run mypy |
| 54 | + |
| 55 | +# Format code |
| 56 | +uv run ruff format . |
| 57 | +``` |
| 58 | + |
| 59 | +!!! note "Pre-commit Hooks" |
| 60 | + The pre-commit hooks will automatically run these checks before each commit. |
| 61 | + If the hooks fail, you will need to fix the issues before you can commit. |
| 62 | + |
| 63 | +### Testing |
| 64 | + |
| 65 | +All new features and bug fixes should include tests. We use pytest for testing: |
| 66 | + |
| 67 | +```bash |
| 68 | +# Run all tests |
| 69 | +uv run pytest |
| 70 | + |
| 71 | +# Run tests with coverage |
| 72 | +uv run pytest --cov=vec_inf |
| 73 | +``` |
| 74 | + |
| 75 | +## Documentation |
| 76 | + |
| 77 | +### Documentation Setup |
| 78 | + |
| 79 | +Install the documentation dependencies: |
| 80 | + |
| 81 | +```bash |
| 82 | +uv sync --group docs |
| 83 | +``` |
| 84 | + |
| 85 | +### Building Documentation |
| 86 | + |
| 87 | +Build and serve the documentation locally: |
| 88 | + |
| 89 | +```bash |
| 90 | +# Standard build |
| 91 | +mkdocs build |
| 92 | + |
| 93 | +# Serve locally with hot-reload |
| 94 | +mkdocs serve |
| 95 | +``` |
| 96 | + |
| 97 | +### Versioned Documentation |
| 98 | + |
| 99 | +Vector Inference uses [mike](https://github.com/jimporter/mike) to manage versioned documentation. This allows users to access documentation for specific versions of the library. |
| 100 | + |
| 101 | +#### Available Versions |
| 102 | + |
| 103 | +The documentation is available in multiple versions: |
| 104 | + |
| 105 | +- `latest` - Always points to the most recent stable release |
| 106 | +- Version-specific documentation (e.g., `0.5.0`, `0.4.0`) |
| 107 | + |
| 108 | +#### Versioning Strategy |
| 109 | + |
| 110 | +Our versioning strategy follows these rules: |
| 111 | + |
| 112 | +1. Each release gets its own version number matching the package version (e.g., `0.5.0`) |
| 113 | +2. The `latest` alias always points to the most recent stable release |
| 114 | +3. Documentation is automatically deployed when changes are pushed to the main branch |
| 115 | + |
| 116 | +#### Working with Mike Locally |
| 117 | + |
| 118 | +To preview or work with versioned documentation: |
| 119 | + |
| 120 | +```bash |
| 121 | +# Build and deploy a specific version to your local gh-pages branch |
| 122 | +mike deploy 0.5.0 |
| 123 | + |
| 124 | +# Add an alias for the latest version |
| 125 | +mike deploy 0.5.0 latest |
| 126 | + |
| 127 | +# Set the default version to redirect to |
| 128 | +mike set-default latest |
| 129 | + |
| 130 | +# View the deployed versions |
| 131 | +mike list |
| 132 | + |
| 133 | +# Serve the versioned documentation locally |
| 134 | +mike serve |
| 135 | +``` |
| 136 | + |
| 137 | +#### Automatic Documentation Deployment |
| 138 | + |
| 139 | +Documentation is automatically deployed through GitHub Actions: |
| 140 | + |
| 141 | +- On pushes to `main`, documentation is deployed with the version from `pyproject.toml` and the `latest` alias |
| 142 | +- Through manual trigger in the GitHub Actions workflow, where you can specify the version to deploy |
| 143 | + |
| 144 | +!!! info "When to Update Documentation" |
| 145 | + - When adding new features |
| 146 | + - When changing existing APIs |
| 147 | + - When fixing bugs that affect user experience |
| 148 | + - When improving explanations or examples |
| 149 | + |
| 150 | +## Pull Request Process |
| 151 | + |
| 152 | +1. **Fork the repository** and create your branch from `main` |
| 153 | +2. **Make your changes** and add appropriate tests |
| 154 | +3. **Ensure tests pass** and code meets style guidelines |
| 155 | +4. **Write clear documentation** for your changes |
| 156 | +5. **Submit a pull request** with a clear description of the changes |
| 157 | + |
| 158 | +!!! important "Checklist Before Submitting PR" |
| 159 | + - [ ] All tests pass |
| 160 | + - [ ] Code is formatted with ruff |
| 161 | + - [ ] Type annotations are correct |
| 162 | + - [ ] Documentation is updated |
| 163 | + - [ ] Commit messages are clear and descriptive |
| 164 | + |
| 165 | +## Release Process |
| 166 | + |
| 167 | +1. Update version in `pyproject.toml` |
| 168 | +2. Update changelogs and documentation as needed |
| 169 | +3. Create a new tag and release on GitHub |
| 170 | +4. Documentation for the new version will be automatically deployed |
| 171 | + |
| 172 | +## License |
| 173 | + |
| 174 | +By contributing to Vector Inference, you agree that your contributions will be licensed under the project's [MIT License](https://github.com/VectorInstitute/vector-inference/blob/main/LICENSE). |
0 commit comments