# Contributing to TensorLake Thank you for your interest in contributing to TensorLake! We welcome contributions from the community and are excited to see what you'll build with us. ## Table of Contents - [Code of Conduct](#code-of-conduct) - [Getting Started](#getting-started) - [Development Setup](#development-setup) - [Contributing Guidelines](#contributing-guidelines) - [Pull Request Process](#pull-request-process) - [Testing](#testing) - [Documentation](#documentation) - [Community](#community) ## Code of Conduct This project and everyone participating in it is governed by our [Code of Conduct](code-of-conduct.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [support@tensorlake.ai](mailto:support@tensorlake.ai). ## Getting Started ### Types of Contributions We welcome many types of contributions, including: - ๐Ÿ› **Bug fixes** - Help us squash bugs and improve reliability - โœจ **New features** - Add new functionality to the SDK - ๐Ÿ“š **Documentation** - Improve our docs, add examples, or write tutorials - ๐Ÿงช **Tests** - Add test coverage or improve existing tests - ๐ŸŽจ **Examples** - Create new examples or improve existing ones - ๐Ÿ”ง **Developer experience** - Improve tooling, CI/CD, or development workflows ### Before You Start 1. **Search existing issues** - Check if someone else has already reported the bug or requested the feature 2. **Create an issue** - For new features or significant changes, please create an issue first to discuss the approach 3. **Start small** - If you're new to the project, consider starting with a "good first issue" ## Development Setup ### Prerequisites - Python 3.10 or higher - [Poetry 2.0.0](https://python-poetry.org/) for Python dependency management - [Rust](https://rustup.rs/) (stable toolchain) โ€” required to build the Rust Cloud SDK extension and CLI binary - Git Install Rust via rustup if you don't have it: ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` ### Setup Instructions 1. **Fork and clone the repository** ```bash git clone https://github.com/YOUR_USERNAME/tensorlake.git cd tensorlake ``` 2. **Choose your development scope** **Public-source changes:** install development dependencies without building the private native Function Agent core: ```bash poetry install --no-root --with=dev make check npm --prefix typescript ci npm --prefix typescript test ``` **Native SDK and Function Agent changes:** check out `tensorlakeai/compute-engine-internal` as a sibling (internal access required), then choose a global or Poetry-managed install: ```bash cd .. git clone git@github.com:tensorlakeai/compute-engine-internal.git cd tensorlake make install-global # or: make install-dev ``` These commands stage the canonical CEI core and function-specific native bindings only for the build, then restore Tensorlake's fail-closed placeholders. Set `COMPUTE_ENGINE_INTERNAL_DIR` if the repositories are not siblings. End users should install a published wheel with `pip install tensorlake`; official releases do not publish a Python source distribution. > **Note:** The shared function-executor protocol sources live under `proto/`. Python gRPC stubs are pre-generated and committed to the repository; run `make build_proto` after modifying the shared `.proto` files. The TypeScript SDK packages the same sources into its function-executor capsule during `npm run build:sdk`. 3. **Verify a native installation** ```bash python -c "import tensorlake; import tensorlake._cloud_sdk" function-executor --help ``` To work on the standalone Rust CLI locally, run `just build-cli` or `just build-cli-full` when you need the private mount/clone feature set. ### Project Structure ``` tensorlake/ โ”œโ”€โ”€ src/tensorlake/ # Python SDK source โ”‚ โ”œโ”€โ”€ applications/ # Serverless applications SDK โ”‚ โ”œโ”€โ”€ cli/ # Python CLI entry points (NDJSON producers) โ”‚ โ””โ”€โ”€ function_executor/ # gRPC function executor server โ”œโ”€โ”€ crates/ โ”‚ โ”œโ”€โ”€ cli/ # Rust CLI binary (tl / tensorlake) โ”‚ โ”œโ”€โ”€ cloud-sdk/ # Rust cloud SDK โ”‚ โ””โ”€โ”€ function-agent-core/ # Private CEI source placeholder and immutable revision โ”œโ”€โ”€ tensorlake.data/scripts/ # Python wrapper scripts installed alongside the CLI โ”œโ”€โ”€ tests/ # Test suite โ”œโ”€โ”€ Makefile # Build and development commands โ”œโ”€โ”€ pyproject.toml # Python SDK configuration (maturin Cloud SDK backend) โ””โ”€โ”€ Cargo.toml # Rust workspace configuration ``` ### How the CLI Works The CLI is a **Rust binary** (`tl` / `tensorlake`) that delegates work to **Python wrapper scripts** for commands that need to import user application code. This split allows the Rust binary to handle argument parsing, authentication, and output rendering, while Python handles SDK logic. For example, `tl deploy app.py` spawns `tensorlake-deploy app.py`, reads its NDJSON output on stdout, and renders it as human-readable text. Wrapper scripts live in `tensorlake.data/scripts/` for local development and are also exposed as Python package entry points. They must be on `PATH` (alongside the standalone Rust binary) for the affected CLI commands to work. | Rust command | Spawns wrapper script | |---|---| | `tl deploy` | `tensorlake-deploy` | | `tl generate-dockerfiles` | `tensorlake-generate-dockerfiles` | `tl sbx image create` is handled directly by the Rust CLI. Programmatic SDK image builds should go through the language-native `Image` DSL APIs rather than passing raw Dockerfile paths into the Python or TypeScript packages. ### Available Makefile Commands ```bash # Global install: build Python SDK wheel with Rust Cloud SDK extension into ~/.local/ make install-global # Virtualenv install: build Rust Cloud SDK extension + install into Poetry venv make install-dev # Same as install-dev but with release optimisations make install-dev-release # Build a distributable wheel with the sibling CEI Function Agent core make build # Regenerate gRPC stubs from .proto files make build_proto # Format Python code (Black + isort) make fmt # Check formatting without modifying files make check # Run all tests make test ``` ### Working on the Rust CLI After editing Rust code in `crates/cli/`, rebuild and reinstall with: ```bash make install-dev ``` Or use Cargo directly for a faster iteration loop (the binary won't be in the venv until you copy it): ```bash cargo build -p tensorlake-cli # binary at target/debug/tl โ€” run it directly or copy to your PATH ``` ## Contributing Guidelines ### Code Style We use several tools to maintain code quality: - **Black** for code formatting - **isort** for import sorting - **flake8** for linting - **mypy** for type checking Run all checks before submitting: ```bash # Format code make fmt # Check formatting and linting make check ``` ### Commit Messages We follow the [Conventional Commits](https://www.conventionalcommits.org/) specification: ``` [optional scope]: [optional body] [optional footer(s)] ``` **Types:** - `feat`: A new feature - `fix`: A bug fix - `docs`: Documentation only changes - `style`: Changes that do not affect the meaning of the code - `refactor`: A code change that neither fixes a bug nor adds a feature - `test`: Adding missing tests or correcting existing tests - `chore`: Changes to the build process or auxiliary tools **Examples:** ``` feat(sandbox): add GPU sandbox support fix(cli): resolve authentication error on Windows docs(examples): add real estate analysis example test(functions): add unit tests for graph validation ``` ### Branch Naming Use descriptive branch names with prefixes: - `feature/description` - For new features - `fix/description` - For bug fixes - `docs/description` - For documentation changes - `test/description` - For test improvements Examples: - `feature/signature-detection` - `fix/cli-auth-windows` - `docs/contributing-guide` ## Pull Request Process ### Before Creating a PR 1. **Update your fork** ```bash git checkout main git pull upstream main git push origin main ``` 2. **Create a feature branch** ```bash git checkout -b feature/your-feature-name ``` 3. **Make your changes** - Write clean, well-documented code - Add tests for new functionality - Update documentation as needed 4. **Test your changes** ```bash make test make check ``` ### Creating the PR 1. **Push your branch** ```bash git push origin feature/your-feature-name ``` 2. **Create the Pull Request** - Use a clear, descriptive title - Fill out the PR template completely - Link any related issues - Add screenshots or examples if applicable ### PR Requirements - โœ… All tests pass (`make test`) - โœ… Code follows style guidelines (`make check`) - โœ… New functionality includes tests - โœ… Documentation is updated - โœ… No merge conflicts with main branch - โœ… PR description clearly explains the changes ### Review Process 1. **Automated checks** - CI/CD will run tests and checks 2. **Code review** - A maintainer will review your code 3. **Feedback** - Address any requested changes 4. **Approval** - Once approved, a maintainer will merge your PR ## Writing Tests - **Unit tests** - Test individual functions and classes - **Integration tests** - Test interactions between components - **Example tests** - Ensure examples work correctly Test file naming convention: - `test_*.py` for unit tests - `test_integration_*.py` for integration tests ### Test Structure ```python import pytest from tensorlake import SomeClass class TestSomeClass: def test_method_returns_expected_value(self): # Arrange instance = SomeClass() # Act result = instance.some_method() # Assert assert result == expected_value ``` ## Documentation ### Types of Documentation 1. **API Documentation** - Auto-generated from docstrings 2. **User Guides** - Step-by-step tutorials 3. **Examples** - Working code samples 4. **Contributing Guide** - This document ### Writing Documentation - Use clear, concise language - Include code examples - Test all code snippets - Update both inline docs and separate documentation files ### Docstring Format We use Google-style docstrings: ```python def process_document(document_path: str, options: Dict[str, Any]) -> Dict[str, Any]: """Process a document using TensorLake AI. Args: document_path: Path to the document to process. options: Configuration options for processing. Returns: Dictionary containing the processed document data. Raises: ValueError: If document_path is invalid. APIError: If the API request fails. Example: >>> result = process_document("contract.pdf", {"extract_signatures": True}) >>> print(result["signatures"]) """ ``` ## Community ### Getting Help - ๐Ÿ“– **Documentation** - Check our [docs](https://docs.tensorlake.ai) - ๐Ÿ’ฌ **Slack** - Join our [community Slack](https://tensorlakecloud.slack.com/) - ๐Ÿ“ง **Email** - Reach out to [support@tensorlake.ai](mailto:support@tensorlake.ai) - ๐Ÿ› **Issues** - Create a [GitHub issue](https://github.com/tensorlakeai/tensorlake/issues) ### Recognition Contributors are recognized in several ways: - Listed in our [Contributors](https://github.com/tensorlakeai/tensorlake/graphs/contributors) page - Mentioned in release notes for significant contributions - Invited to our contributor Discord channels ## Release Process ### Versioning We follow [Semantic Versioning](https://semver.org/): - **MAJOR** version for incompatible API changes - **MINOR** version for new functionality in a backwards compatible manner - **PATCH** version for backwards compatible bug fixes ### Release Checklist Maintainers follow this checklist for releases: - [ ] Update version in `pyproject.toml` - [ ] Update `CHANGELOG.md` - [ ] Run full test suite (`make test`) - [ ] Check code quality (`make check`) - [ ] Build the project (`make build`) - [ ] Create release PR - [ ] Tag release after merge - [ ] Publish to PyPI - [ ] Update documentation - [ ] Announce release ## Questions? Don't hesitate to ask questions! We're here to help: - Open a [GitHub Issue](https://github.com/tensorlakeai/tensorlake/issues) - Join our [Slack community](https://tensorlakecloud.slack.com/) - Email us at [support@tensorlake.ai](mailto:support@tensorlake.ai) Thank you for contributing to TensorLake! ๐Ÿš€