Contributing to Hypergraph-DB¶
Thank you for your interest in contributing to Hypergraph-DB! We welcome contributions from the community and are grateful for your help in making this project better.
Code of Conduct¶
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code.
π€ How to Contribute¶
There are many ways to contribute to Hypergraph-DB:
- π Report bugs - Help us identify and fix issues
- π‘ Suggest features - Share ideas for new functionality
- π Improve documentation - Help make our docs clearer and more comprehensive
- π§ Submit code - Fix bugs or implement new features
- π§ͺ Write tests - Help improve our test coverage
- π Translate - Help make the project accessible in more languages
π οΈ Development Setup¶
Prerequisites¶
- Python 3.8 or higher
- uv (recommended) or pip
- Git
Setting up the Development Environment¶
-
Fork and clone the repository:
-
Install dependencies:
-
Run tests to ensure everything works:
-
Set up pre-commit hooks (optional but recommended):
π€ Submitting Changes¶
Pull Request Process¶
-
Create a new branch from
main
: -
Make your changes following our style guidelines
-
Add tests for new functionality
-
Update documentation if needed
-
Run tests and ensure they pass:
-
Run type checking:
-
Format your code:
-
Commit your changes with a clear message:
-
Push your branch:
-
Create a Pull Request on GitHub
Commit Message Guidelines¶
We follow the Conventional Commits specification:
feat:
- A new featurefix:
- A bug fixdocs:
- Documentation only changesstyle:
- Changes that do not affect the meaning of the coderefactor:
- A code change that neither fixes a bug nor adds a featuretest:
- Adding missing tests or correcting existing testschore:
- Changes to the build process or auxiliary tools
π Reporting Issues¶
When reporting issues, please include:
- Bug Description: Clear description of the problem
- Environment: Python version, OS, package version
- Reproduction Steps: Minimal code example that reproduces the issue
- Expected Behavior: What you expected to happen
- Actual Behavior: What actually happened
- Stack Trace: If applicable, include the full error message
Please provide as much detail as possible when reporting issues.
π Documentation¶
We use MkDocs with the Material theme for documentation:
Building Documentation Locally¶
# Install documentation dependencies
uv sync --extra docs
# Serve documentation locally
uv run mkdocs serve
# Build documentation
uv run mkdocs build
Documentation Guidelines¶
- Write clear, concise explanations
- Include code examples for new features
- Update both English and Chinese versions when possible
- Use proper Markdown formatting
- Add diagrams or images when helpful
π§ͺ Testing¶
Running Tests¶
# Run all tests
uv run pytest
# Run tests with coverage
uv run pytest --cov=hyperdb
# Run specific test file
uv run pytest tests/test_hypergraph.py
# Run tests matching a pattern
uv run pytest -k "test_add_vertex"
Writing Tests¶
- Write tests for all new functionality
- Use descriptive test names
- Follow the existing test structure
- Include edge cases and error conditions
- Aim for high test coverage
Test Structure¶
def test_feature_name():
"""Test description."""
# Arrange
hg = HypergraphDB()
# Act
result = hg.some_method()
# Assert
assert result == expected_value
π Style Guidelines¶
Python Code Style¶
We use the following tools to maintain code quality:
Code Guidelines¶
- Type Hints: Use type hints for all public APIs
- Docstrings: Follow NumPy docstring style
- Variable Names: Use descriptive names (
vertex_id
notvid
) - Function Names: Use verbs for functions (
add_vertex
notvertex_add
) - Class Names: Use PascalCase (
HypergraphDB
) - Constants: Use UPPER_SNAKE_CASE (
MAX_VERTICES
)
Example Docstring¶
def add_vertex(self, vertex_id: Hashable, attributes: Optional[Dict[str, Any]] = None) -> None:
"""Add a vertex to the hypergraph.
Parameters
----------
vertex_id : Hashable
Unique identifier for the vertex.
attributes : dict, optional
Dictionary of vertex attributes, by default None.
Raises
------
ValueError
If vertex_id already exists in the hypergraph.
Examples
--------
>>> hg = HypergraphDB()
>>> hg.add_vertex(1, {"name": "Alice", "age": 30})
"""
π·οΈ Release Process¶
Releases are handled by maintainers and follow semantic versioning:
- Major (X.0.0): Breaking changes
- Minor (0.X.0): New features, backward compatible
- Patch (0.0.X): Bug fixes, backward compatible
π Getting Help¶
If you need help or have questions:
- Check the documentation
- Search existing issues
- Create a new discussion
- Join our community channels (if available)
π License¶
By contributing to Hypergraph-DB, you agree that your contributions will be licensed under the Apache License 2.0.
Thank you for contributing to Hypergraph-DB! π