Contributing to KerasFactory
Thank you for your interest in contributing to KerasFactory! 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
1 2
git clone https://github.com/UnicoLab/KerasFactory.git cd KerasFactory -
Install Dependencies
1poetry install -
Install Pre-commit Hooks
1pre-commit install -
Run Tests
1make all_tests
๐ Types of Contributions
๐งฉ Adding New Layers
New layers are the core of KerasFactory. Follow these guidelines:
Layer Requirements
- 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 Structure
- File Name:
YourLayer.py(PascalCase) - Location:
kerasfactory/layers/YourLayer.py - Export: Add to
kerasfactory/layers/__init__.py
๐๏ธ Adding New Models
Models should inherit from kerasfactory.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.pyortests/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
1 | |
2. Make Changes
- Write your code following the guidelines above
- Add comprehensive tests
- Update documentation if needed
3. Run Tests
1 2 3 4 5 6 7 8 | |
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. If you are adding new code, you will have to reference it in a dedicated docuemntation file to fetche the correct docstring.
5. Commit Changes
Use conventional commit messages:
1 2 | |
6. Push and Create Pull Request
1 | |
๐ Commit Convention
We 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
๐งช 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 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.