Contributing
We welcome contributions to Timber. Here's how to get started.
Development Setup
git clone https://github.com/kossisoroyce/timber.git
cd timber
pip install -e ".[dev]"
pytest tests/ -v # 144 tests should pass
Requirements: Python 3.10+, a C compiler (gcc or clang).
Project Structure
timber/
├── ir/ # Intermediate Representation
├── frontends/ # 5 model format parsers
│ ├── xgboost_parser.py
│ ├── lightgbm_parser.py
│ ├── sklearn_parser.py
│ ├── catboost_parser.py
│ ├── onnx_parser.py
│ └── auto_detect.py
├── optimizer/ # 6 optimization passes
│ ├── pipeline.py
│ ├── dead_leaf.py
│ ├── constant_feature.py
│ ├── threshold_quant.py
│ ├── branch_sort.py
│ ├── pipeline_fusion.py
│ └── vectorize.py
├── codegen/ # 3 code generation backends
│ ├── c99.py
│ ├── wasm.py
│ └── misra_c.py
├── runtime/ # Python ctypes predictor
├── audit/ # Audit report generation
├── store.py # Local model store
├── serve.py # HTTP server
└── cli.py # CLI entry point
Adding a New Front-End
- Create
timber/frontends/<framework>_parser.py - Implement
parse_<framework>_model(path) → TimberIR - Register in
auto_detect.py(detection + dispatch) - Add tests in
tests/test_<framework>_parser.py
Adding an Optimizer Pass
- Create
timber/optimizer/<pass_name>.py - Implement as a function:
TimberIR → TimberIR - Register in
timber/optimizer/pipeline.py - Add tests
Adding a Code Backend
- Create
timber/codegen/<backend>.py - Follow the pattern of
c99.py: take IR, returndict[str, str] - Add tests
Running Tests
pytest tests/ -v # Full suite
pytest tests/test_store.py -v # Specific file
pytest tests/ --cov=timber --cov-report=html # Coverage
Pull Request Process
- Fork the repo, create a branch from
main - Write tests for new functionality
- All 144+ tests must pass
- Keep commits focused
- Open a PR with a clear description
Code Style
- Type hints on all function signatures
- Docstrings on public classes/functions
- Follow existing patterns
License
Contributions are licensed under Apache-2.0.