Contributing to KMR
Thank you for your interest in contributing to the Keras Model Registry (KMR)! This guide will help you get started with contributing to the project.
๐ Getting Started
Prerequisites
- Python 3.9+
- Poetry (for dependency management)
- Git
- Basic knowledge of Keras 3 and deep learning
Development Setup
-
Fork and Clone the Repository
git clone https://github.com/UnicoLab/keras-model-registry.git cd keras-model-registry
-
Install Dependencies
poetry install
-
Install Pre-commit Hooks
pre-commit install
-
Run Tests
make all_tests
๐ Types of Contributions
๐งฉ Adding New Layers
New layers are the core of KMR. Follow these guidelines:
Layer Requirements
- Keras 3 Only: No TensorFlow dependencies in production code
- Inherit from BaseLayer: All layers must inherit from
kmr.layers._base_layer.BaseLayer
- Full Serialization: Implement
get_config()
andfrom_config()
methods - Type Annotations: Use Python 3.12+ type hints
- Comprehensive Documentation: Google-style docstrings
- Parameter Validation: Implement
_validate_params()
method
File Structure
- File Name:
YourLayer.py
(PascalCase) - Location:
kmr/layers/YourLayer.py
- Export: Add to
kmr/layers/__init__.py
๐๏ธ Adding New Models
Models should inherit from kmr.models._base.BaseModel
and follow similar patterns to layers.
๐งช Adding Tests
Every layer and model must have comprehensive tests:
Test File Structure
- File Name:
test__YourLayer.py
(note the double underscore) - Location:
tests/layers/test__YourLayer.py
ortests/models/test__YourModel.py
Required Tests
- Initialization tests
- Invalid parameter tests
- Build tests
- Output shape tests
- Serialization tests
- Training mode tests
- Model integration tests
๐ Development Workflow
1. Create a Feature Branch
git checkout -b feature/your-feature-name
2. Make Changes
- Write your code following the guidelines above
- Add comprehensive tests
- Update documentation if needed
3. Run Tests
# Run all tests
make all_tests
# Run specific test file
poetry run python -m pytest tests/layers/test__YourLayer.py -v
# Run with coverage
make coverage
4. Documentation
Documentation is automatically generated from docstrings using MkDocs and mkdocstrings. Simply ensure your docstrings follow Google style format and the documentation will be updated automatically when the site is built.
5. Commit Changes
Use conventional commit messages:
git add .
git commit -m "feat(layers): add YourLayer for feature processing"
6. Push and Create Pull Request
git push origin feature/your-feature-name
๐ Commit Convention
We use conventional commits:
feat(layers): add new layer for feature processing
fix(models): resolve serialization issue in TerminatorModel
docs(readme): update installation instructions
test(layers): add tests for YourLayer
refactor(utils): improve data analyzer performance
๐งช Testing Guidelines
Test Coverage
- Minimum 90%: All new code must have 90%+ test coverage
- All Paths: Test both success and failure cases
- Edge Cases: Test boundary conditions and edge cases
Test Categories
- Unit Tests: Individual layer/model functionality
- Integration Tests: Layer combinations and model workflows
- Serialization Tests: Save/load functionality
- Performance Tests: For computationally intensive components
๐ซ What Not to Include
Experimental Components
- Location:
experimental/
directory (outside package) - Purpose: Research and development
- Status: Not included in PyPI package
- Dependencies: May use TensorFlow for testing
Prohibited Dependencies
- TensorFlow: Only allowed in test files
- PyTorch: Not allowed
- Other ML Frameworks: Keras 3 only
๐ Getting Help
- GitHub Issues: GitHub Issues
- GitHub Discussions: GitHub Discussions
- Documentation: Check the docs first
๐ฏ Code Review Process
Review Criteria
- Functionality: Does the code work as intended?
- Tests: Are there comprehensive tests?
- Documentation: Is the code well-documented?
- Style: Does it follow project conventions?
- Performance: Is it efficient?
- Security: Are there any security concerns?
Review Timeline
- Initial Review: Within 48 hours
- Follow-up: Within 24 hours of changes
- Merge: After approval and CI passes
๐ Recognition
Contributors will be recognized in: - README: Listed as contributors - Release Notes: Mentioned in relevant releases - Documentation: Credited for significant contributions
๐ License
By contributing to KMR, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to KMR! Your contributions help make tabular data processing with Keras more accessible and powerful for everyone.