Thank you for your interest in contributing to H-RAG! This guide will help you get started.
- Code of Conduct
- Development Setup
- Making Changes
- Testing
- Code Style
- Pull Request Process
- Reporting Issues
This project follows the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.
- Python 3.10 or higher
- Git
# Fork the repository on GitHub, then clone your fork
git clone https://github.com/AnasAmchaar/HRAG.git
cd H-RAG
# Create a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install in development mode with all extras
pip install -e ".[dev,demo]"
# (Optional) Install pre-commit hooks
pre-commit install# Run tests to confirm everything works
pytest
# Run linter
ruff check hrag/
# Run type checker
mypy hrag/Create a descriptive branch for your changes:
git checkout -b feature/add-docx-support
git checkout -b fix/clustering-edge-case
git checkout -b docs/improve-api-referenceWrite clear, concise commit messages:
feat: add DOCX file format support to chunker
fix: handle edge case when all vectors are noise in HDBSCAN
docs: add configuration reference to README
test: add tests for empty document ingestion
# Run all tests
pytest
# Run with coverage
pytest --cov=hrag --cov-report=html
# Run a specific test file
pytest tests/test_chunker.py
# Run a specific test
pytest tests/test_chunker.py::TestChunking::test_single_chunk
# Skip slow tests
pytest -m "not slow"- Place tests in the
tests/directory - Name test files
test_<module>.py - Use pytest fixtures from
conftest.pywhere possible - Aim for clear, descriptive test names that explain the expected behavior
class TestMyFeature:
def test_handles_empty_input(self):
"""Empty input should return an empty result without errors."""
result = my_function([])
assert result == []This project uses Ruff for linting and formatting.
- Line length: 100 characters
- Imports: Sorted with
isort(via Ruff) - Type hints: Use wherever practical
- Docstrings: Google-style docstrings for all public functions and classes
- Logging: Use
logginginstead ofprint()in library code
# Check for issues
ruff check hrag/
# Auto-fix issues
ruff check hrag/ --fix
# Format code
ruff format hrag/- Update your fork with the latest
mainbranch - Create a feature branch from
main - Make your changes with clear, focused commits
- Add or update tests for your changes
- Run the full test suite and ensure all tests pass
- Update documentation if needed (README, docstrings, etc.)
- Open a Pull Request with a clear description of your changes
- Tests pass locally (
pytest) - Linter passes (
ruff check hrag/) - New code has docstrings and type hints
- Changes are documented (README, CHANGELOG if needed)
- Commit messages are clear and descriptive
When filing a bug report, please include:
- Python version (
python --version) - H-RAG version (
hrag --version) - Operating system
- Steps to reproduce the issue
- Expected vs actual behavior
- Error messages or tracebacks
For feature requests, please describe:
- The problem you're trying to solve
- Your proposed solution (if any)
- Alternatives you've considered
If you have questions about contributing, feel free to open a Discussion on GitHub.