Thank you for your interest in contributing to KerasFactory! This guide will help you get started with contributing to the project.
- Python 3.9+
- Poetry (for dependency management)
- Git
- Basic knowledge of Keras 3 and deep learning
-
Fork and Clone the Repository
git clone https://github.com/UnicoLab/KerasFactory.git cd KerasFactory -
Install Dependencies
poetry install
-
Install Pre-commit Hooks
pre-commit install
-
Run Tests
make all_tests
New layers are the core of KerasFactory. Follow these guidelines:
- Keras 3 Only: No TensorFlow dependencies in production code (Tensorflow only for testing)
- Inherit from BaseLayer: All layers must inherit from
kerasfactory.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 Name:
YourLayer.py(PascalCase) - Location:
kerasfactory/layers/YourLayer.py - Export: Add to
kerasfactory/layers/__init__.py
Models should inherit from kerasfactory.models._base.BaseModel and follow similar patterns to layers.
Every layer and model must have comprehensive tests:
- File Name:
test__YourLayer.py(note the double underscore) - Location:
tests/layers/test__YourLayer.pyortests/models/test__YourModel.py
- Initialization tests
- Invalid parameter tests
- Build tests
- Output shape tests
- Serialization tests
- Training mode tests
- Model integration tests
git checkout -b feature/your-feature-name- Write your code following the guidelines above
- Add comprehensive tests
- Update documentation if needed
# 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 coverageDocumentation 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. If you are adding new code, you will have to reference it in a dedicated docuemntation file to fetche the correct docstring.
Use conventional commit messages:
git add .
git commit -m "feat(layers): add YourLayer for feature processing"git push origin feature/your-feature-nameWe use conventional commits:
feat(layers): add new layer for feature processingfix(models): resolve serialization issue in TerminatorModeldocs(readme): update installation instructionstest(layers): add tests for YourLayerrefactor(utils): improve data analyzer performance
- 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
- Unit Tests: Individual layer/model functionality
- Integration Tests: Layer combinations and model workflows
- Serialization Tests: Save/load functionality
- Performance Tests: For computationally intensive components
- Location:
experimental/directory (outside package) - Purpose: Research and development
- Status: Not included in PyPI package
- Dependencies: May use TensorFlow for testing
- TensorFlow: Only allowed in test files
- PyTorch: Not allowed
- Other ML Frameworks: Keras 3 only
- GitHub Issues: GitHub Issues
- GitHub Discussions: GitHub Discussions
- Documentation: Check the docs first
- 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?
- Initial Review: Within 48 hours
- Follow-up: Within 24 hours of changes
- Merge: After approval and CI passes
Contributors will be recognized in:
- README: Listed as contributors
- Release Notes: Mentioned in relevant releases
- Documentation: Credited for significant contributions
By contributing to KerasFactory, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to KerasFactory! Your contributions help make tabular data processing with Keras more accessible and powerful for everyone.