Thank you for your interest in contributing to tsbk (Triton Server Build Kit)! This guide will help you get started with developing and contributing to the project.
- Code of Conduct
- Getting Started
- Development Environment Setup
- Project Structure
- Development Workflow
- Testing
- Code Quality
- Submitting Changes
- Release Process
This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to mlopsplatformteam@grainger.com.
Before contributing, please:
- Check existing issues to see if your feature/bug has been discussed
- Open a new issue to discuss significant changes before starting work
- Fork the repository and create a feature branch for your changes
- Python 3.11+ (Python 3.12 recommended)
- Docker (for running Triton servers and integration tests)
- Poetry 1.8.3+ (for dependency management)
- Git (for version control)
-
Clone the repository
git clone https://github.com/your-user/tritonserver-buildkit.git cd tritonserver-buildkit -
Install Poetry
If you don't have Poetry installed:
pipx install poetry==1.8.3
Or via pip:
pip install poetry==1.8.3
-
Create a virtual environment and install dependencies
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate poetry install --with dev
-
Install pre-commit hooks
pre-commit install
This will automatically run code quality checks before each commit.
-
Verify installation
tsbk --help
-
Create a feature branch
git checkout -b feature/your-feature-name
Branch naming conventions:
feature/- New featuresfix/- Bug fixesdocs/- Documentation changesrefactor/- Code refactoringtest/- Test additions or modifications
-
Make your changes
- Write clean, readable code
- Follow the existing code style (enforced by black and isort)
- Add docstrings to new functions and classes
- Update relevant documentation
-
Write tests
- Add unit tests for new functionality
- Add integration tests if your changes affect end-to-end workflows
- Ensure all tests pass before submitting
tsbk has two test suites: unit tests and integration tests.
Unit tests are fast and don't require external services.
# Run unit tests with coverage
make unit-testsThis command:
- Runs all tests in
tests/unit/ - Generates a coverage report
- Creates an HTML coverage report in
htmlcov/
Integration tests require Docker and test the full workflow including Triton server deployment.
# Run integration tests
make integration-tests
# Stop LocalStack when done
docker compose downIntegration tests verify:
- Building model repositories from YAML configurations
- Running Triton servers in Docker
- Model inference via HTTP and gRPC
- S3 model artifact fetching
- End-to-end CLI commands
# Run a specific test file
pytest tests/unit/test_types.py
# Run a specific test function
pytest tests/unit/test_types.py::test_function_name
# Run with verbose output
pytest -v tests/unit/
# Run with output printed (useful for debugging)
pytest -s tests/unit/- Place unit tests in
tests/unit/ - Place integration tests in
tests/integration/ - Use pytest fixtures (see
conftest.pyfiles) - Mock external services in unit tests
- Use descriptive test names that explain what is being tested
This project uses several tools to maintain code quality:
- black: Code formatter (line length: 121)
- isort: Import statement sorter
- pre-commit: Automated checks before commits
# Run all pre-commit hooks manually
pre-commit run --all-filesPre-commit hooks will automatically run when you commit. If they fail:
- Review the changes made by the hooks
- Stage the fixed files:
git add . - Commit again
- Follow PEP 8 conventions
- Use type hints for function signatures
- Write descriptive variable and function names
- Keep functions focused and single-purpose
- Add docstrings to public functions and classes
- Maximum line length: 121 characters
Example docstring format:
def build_model_repo(config: dict, output_path: str) -> TritonModelRepo:
"""
Build a Triton model repository from configuration.
Args:
config: Dictionary containing model repository configuration
output_path: Path where the model repository will be created
Returns:
TritonModelRepo instance representing the built repository
Raises:
ValueError: If configuration is invalid
"""
...-
Ensure all tests pass:
make unit-tests make integration-tests
-
Ensure code quality checks pass:
pre-commit run --all-files
-
Update documentation if needed:
- Update README.md for user-facing changes
- Update docstrings for API changes
- Add examples if introducing new features
-
Push your branch
git push origin feature/your-feature-name
-
Open a Pull Request
- Go to the repository on GitHub
- Click "New Pull Request"
- Select your feature branch
- Fill out the PR template with:
- Description: What changes does this PR introduce?
- Motivation: Why are these changes needed?
- Testing: How were these changes tested?
- Breaking Changes: Does this break existing functionality?
- Resolves issues: Link to any related issues
-
PR Title Convention
Use conventional commit format:
feat: add support for TensorRT optimizationfix: resolve S3 connection timeout issuedocs: update installation instructionsrefactor: simplify model loading logictest: add integration tests for ensemble models
- Automated Checks: CI will run pre-commit, unit tests, and integration tests
- Code Review: Maintainers will review your code and provide feedback
- Address Feedback: Make requested changes and push updates
- Approval: Once approved, a maintainer will merge your PR
- Keep PRs focused on a single feature or fix
- Write clear commit messages
- Respond promptly to review feedback
- Ensure CI checks pass
- Add tests for new functionality
- Update documentation for user-facing changes
This project uses semantic-release for automated versioning and releases.
We follow Semantic Versioning:
- MAJOR: Breaking changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes (backward compatible)
Commits to the main branch should follow conventional commits to trigger releases:
feat:- Triggers a MINOR version bumpfix:- Triggers a PATCH version bumpfeat!:orBREAKING CHANGE:- Triggers a MAJOR version bumpdocs:,refactor:,test:- No version bump
Example:
feat: add support for TensorRT backend
This adds TensorRT backend support with automatic
FP16 optimization capabilities.
- PRs are merged to
main - Semantic-release analyzes commit messages
- Version is automatically bumped in
pyproject.tomlandsrc/tsbk/__init__.py - GitHub release is created with changelog
- Package is published to PyPI
Note: Contributors don't need to manually manage versions. The release process is automated based on commit messages.
Thank you for contributing to tsbk!