tensorlake
CLAUDE.md1k starsChanged 3 months agoApache-2.0View on GitHub
TensorLake SDK — a Python SDK for document ingestion (DocumentAI) and serverless agentic applications. Users define applications using decorator-based APIs and deploy them to TensorLake Cloud or run locally. For validations that must run inside the real Tensorlake builder image, use a throwaway Python virtualenv with the published tensorlake package. Do this for live environment checks, not normal repo tests. Key points: - Install from PyPI in a fresh venv: python3 -m venv /tmp/tl-validate-venv && /tmp/tl-validate-venv/bin/python -m pip install -q…
- Reads credentials
- Installs packages
Trending
Steady talk.thin dataabout the whole repository
Who's talking about tensorlakeai/tensorlake
- pandemicsyn/sandbar“[provider-candidate]: Tensorlake Sandboxes”GitHub · Oct 1, 2026
- harbor-framework/harbor“Validate wheel extras before publish”GitHub · Aug 27, 2026
The biggest 2 of 2 mentions linking to the repository that our crawl found. Each line is their own headline.
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
We split this CLAUDE.md into the rules it gives an agent
10 rules. About 0 are common, 3 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 43
Read the token of the current tl context, but never print it.
- Very specific: line 44
Read organization and project from .tensorlake/config.toml and pass them explicitly to SandboxClient.for_cloud(...).
- Very specific: line 45
Create the throwaway sandbox from tensorlake/rootfs-builder, run validation commands, and always delete it with client.delete(sandbox_id) …
- Very specific: line 154
Run python .github/scripts/bump_version.py <new-version>.
- Very specific: line 163
CRITICAL: Always run tests in BOTH local and remote modes: Do NOT skip remote mode or run only local mode unless the user explicitly says …
- Very specific: line 172
Check if indexify-server is running (HTTP ping http://localhost:8900)
- Distinctive: line 173
If not then stop immediately and ask the user to run it.
- Distinctive: line 174
Ask user for the command that runs indexify-dataplane.
- Distinctive: line 176
Run indexify-dataplane using the command given by user.
- Very specific: line 180
When running remote mode tests using poetry run tests/path_to/test_file.py you need to also define env var …
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
TensorLake SDK — a Python SDK for document ingestion (DocumentAI) and serverless agentic applications. Users define applications using decorator-based APIs and deploy them to TensorLake Cloud or run locally.
Common Commands
# Install dependencies and build
make build
# Format code (Black + isort)
make fmt
# Check formatting without modifying
make check
# Run all tests (requires TENSORLAKE_API_URL env var)
make test
# Run a specific test suite
cd tests && ./run_tests.sh --applications
cd tests && ./run_tests.sh --function-executor
cd tests && ./run_tests.sh --document-ai
cd tests && ./run_tests.sh --cli
# Run a single test file
cd tests && poetry run python path/to/test_file.py
# Regenerate gRPC stubs from .proto files
make build_protoManual Cloud Sandbox Validations
For validations that must run inside the real Tensorlake builder image, use a throwaway Python virtualenv with the published tensorlake package. Do this for live environment checks, not normal repo tests.
Key points:
- Install from PyPI in a fresh venv:
python3 -m venv /tmp/tl-validate-venv && /tmp/tl-validate-venv/bin/python -m pip install -q --upgrade pip tensorlake. - Read the token of the current
tlcontext, but never print it.~/.config/tensorlake/contexts.tomlsays whether it is in the OS keychain or incredentials.toml. The published SDK readsTENSORLAKE_API_KEY;TENSORLAKE_PATis not enough for sandbox creation. - Read
organizationandprojectfrom.tensorlake/config.tomland pass them explicitly toSandboxClient.for_cloud(...). Relying only on environment variables can produce missing scope headers. - Create the throwaway sandbox from
tensorlake/rootfs-builder, run validation commands, and always delete it withclient.delete(sandbox_id)in afinallyblock. - Commands run as
tl-userby default. Builder-image checks that startdockerdmust run as root, e.g.sudo -n <script>.
Minimal pattern:
import os
import subprocess
import tomllib
from pathlib import Path
from tensorlake.sandbox import SandboxClient
def token_for(context: str = "default") -> str:
config = Path.home() / ".config/tensorlake"
entry = tomllib.loads((config / "contexts.toml").read_text())["contexts"][context]
if entry.get("storage") == "keychain":
# macOS. The item belongs to `tl`, so the keychain asks once to allow this.
return subprocess.run(
["security", "find-generic-password", "-s", "tensorlake", "-a", context, "-w"],
check=True, capture_output=True, text=True,
).stdout.strip()
credentials = tomllib.loads((config / "credentials.toml").read_text())
return credentials["contexts"][context]["token"]
def local_config() -> dict[str, str]:
out = {}
for raw in Path(".tensorlake/config.toml").read_text().splitlines():
line = raw.strip()
if "=" in line:
key, value = line.split("=", 1)
out[key.strip()] = value.strip().strip('"')
return out
endpoint = "https://api.tensorlake.ai"
token = token_for()
cfg = local_config()
os.environ["TENSORLAKE_API_KEY"] = token
client = SandboxClient.for_cloud(
api_key=token,
api_url=endpoint,
organization_id=cfg["organization"],
project_id=cfg["project"],
)
sandbox = None
try:
sandbox = client.create_and_connect(image="tensorlake/rootfs-builder")
sandbox.write_file("/tmp/validate.sh", b"#!/usr/bin/env bash\nset -euo pipefail\nsudo -n id\n")
result = sandbox.run(
"sh",
["-lc", "chmod +x /tmp/validate.sh && sudo -n /tmp/validate.sh"],
timeout=900,
)
print(result.stdout)
if getattr(result, "exit_code", 0) != 0:
raise RuntimeError(result.stderr)
finally:
if sandbox is not None:
client.delete(sandbox.sandbox_id)Architecture
Three Public APIs
- Applications SDK (
src/tensorlake/applications/) — Decorator-based API for defining serverless functions and applications. Public interface is inapplications/interface/; everything re-exported throughapplications/__init__.pyviafrom .interface import *. - Sandbox SDK (
src/tensorlake/sandbox) - Client for creating Sandboxes where users can run arbitrary code, copy files, install packages and etc. - DocumentAI SDK (
src/tensorlake/documentai/) — Client for document parsing, extraction, and classification.
Applications: Decorator → Function → Runner
Users decorate functions with @application and @function (defined in interface/decorators.py). Decorators create Function objects registered in a global registry (registry.py). Functions support .map() and .reduce() operations and return Future/Awaitable objects for async execution.
Two execution modes:
- Local (
applications/local/) — Direct in-process execution for development/testing viarun_local_application(), implemented by LocalRunner class. - Remote (
applications/remote/) — Cloud deployment viarun_remote_application()and gRPC communication, implemented by AllocationRunner class.
Function Executor
src/tensorlake/function_executor/ — gRPC server that executes user functions in sandboxed environments. Proto definitions in function_executor/proto/. Proto files and generated Python stubs must coexist in the same directory (gRPC limitation).
CLI
src/tensorlake/cli/ — Click-based CLI (tensorlake command). Entry points: tensorlake deploy, tensorlake parse, tensorlake login, tensorlake secrets, etc.
Vendored Dependencies
src/tensorlake/vendor/ contains vendored faker and nanoid libraries. Black and isort are configured to skip this directory.
Key Conventions
- Typed API responses: Deserialize response and error bodies into explicit structs/enums (
serde::Deserializein Rust) and access named fields. Do not parse a body intoserde_json::Valueand extract known fields with.get()/.as_str(). Reuse wire models or add a focused response struct; represent supported legacy shapes with types, defaults, and aliases. Reserve dynamic JSON for individual fields whose contract permits arbitrary JSON, such aserror_details. Preserve raw-body fallback for unrecognized or non-JSON error responses. - Python 3.10+, managed with Poetry 2.0.0
- Formatting: Black + isort (profile "black"). Pre-commit hooks enforce this.
- Tests: Standard
unittestframework withparameterizedfor parameterized tests. Parameterized tests are main used to run the same test code in local and remote modes and ensure the same results. Claude must not create new Python environments to run test. Instead it should use currrent Poetry environment by i.e. usingpoetry run python tests/path_to/test_file.py. - Pydantic v2 for data models throughout.
- gRPC stubs are generated with grpcio-tools 1.60.0 (pinned old version for forward compatibility) and reformatted with Black/isort after generation.
Releasing / version bumps
IMPORTANT: After finishing code changes on a branch, before handing back to the user, remind them to bump the version. All packages (Python, Rust, CLI, TypeScript) are released in lockstep at a single shared version, so a release bumps everything together.
How to bump:
- Run
python .github/scripts/bump_version.py <new-version>. A single command updates every version-bearing file used by the PyPI / crates.io / CLI / npm release workflows:pyproject.toml(root,tensorlakePyPI package)Cargo.toml(root, workspace version — all crates inherit viaversion.workspace = true, includingcrates/cli)crates/rust-cloud-sdk-py/pyproject.tomltypescript/package.json(npm package;publish_npm.yamlreads the version from here)
Cargo.lockandtypescript/package-lock.jsonregenerate on build/install — commit them after they refresh, don't hand-edit.
Running Applications tests
CRITICAL: Always run tests in BOTH local and remote modes. Do NOT skip remote mode or run only local mode unless the user explicitly says to run local or remote only.
Most test files use @parameterized to run each test case in both modes.
Never reduce test scope to work around infrastructure failures. If tests fail due to missing setup (e.g. deploy_applications fails in setUpClass), this means remote mode is not set up yet — follow the remote mode setup procedure below instead of falling back to running only local tests.
Running remote mode tests
Before running a test in remote mode you MUST first ensure all remote mode dependencies are available:
- Check if indexify-server is running (HTTP ping
http://localhost:8900) - If not then stop immediately and ask the user to run it. Do not try to run local mode tests to proceed faster.
- Ask user for the command that runs indexify-dataplane. Do not assume that indexify-dataplane is running or not running. You have to start it yourself to get access to its stdout/stderr so you can investigate test failures yourself.
- Run indexify-dataplane using the command given by user.
The dataplane command stdout/stderr contain logs from indexify-dataplane service and from Function Executors started by indexify-dataplane. Use these Function Executor logs to investigate failures in remote mode.
When running remote mode tests using poetry run tests/path_to/test_file.py you need to also define env var TENSORLAKE_API_URL=http://localhost:8900 by prepending it to the poetry run python command.
Running Local mode tests
Local mode tests don't have any dependency on indexify-dataplane and indexify-server. The logs and backtraces for LocalRunner and related classes are available in stdout/stderr of the test file when you run it. Use these backtraces and logs to investigate local mode test failures.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

