-
Notifications
You must be signed in to change notification settings - Fork 7
doc: documentation mega issue sprint #492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1408fd7
doc mega sprint
dionhaefner cbb623b
merge main
dionhaefner 98bbd28
address review
dionhaefner a48248f
review round 2
dionhaefner 09af853
Merge branch 'main' into dion/doc-sprint
dionhaefner 99451b2
polish readme
dionhaefner 1e71ddc
address review
dionhaefner 7f1a112
Merge branch 'main' into dion/doc-sprint
dionhaefner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Notes for AI Agents | ||
|
|
||
| This file contains counter-intuitive aspects of the Tesseract codebase that AI agents should know. | ||
|
|
||
| ## Environment setup | ||
|
|
||
| - **Use `uv` for dependency management.** Install with `uv pip install -e .[dev]`. This is faster and more reliable than plain pip. | ||
|
dionhaefner marked this conversation as resolved.
Outdated
|
||
| - **Run `pre-commit install`** after cloning to set up git hooks. | ||
|
|
||
| ## Testing | ||
|
|
||
| - **Prefer end-to-end tests over unit tests.** Tests that build and run real Tesseracts catch more bugs than mocked unit tests. | ||
| - **Avoid mocks.** If you need complex mocking, write an end-to-end test instead. | ||
| - **Don't test implementation details.** Tests should verify behavior, not internal structure. | ||
| - **Be mindful of slow tests.** End-to-end tests are slow. Check if an existing test can be extended before adding a new one. | ||
|
dionhaefner marked this conversation as resolved.
Outdated
|
||
| - **Don't add mocks for Docker.** Tests that need Docker should be marked as end-to-end tests and skipped in fast test runs. | ||
|
dionhaefner marked this conversation as resolved.
|
||
| - **Rarely test exceptions.** Only test exception handling when control flow is complex or the error message is critical for UX. Don't write tests that just verify an exception is raised. | ||
| - **Never skip or disable tests without asking.** If a test is failing and you want to skip it, ask the user first. Don't add `@pytest.skip`, `@pytest.mark.xfail`, or comment out tests without explicit approval. | ||
|
|
||
| ## Code style | ||
|
|
||
| - **Follow existing patterns.** Look at similar code in the codebase and match its style. Don't introduce new patterns without good reason. | ||
| - **Use pre-commit.** Run `pre-commit run --all-files` before committing. Hooks include Ruff for linting/formatting. | ||
| - **Follow conventional commits.** PR titles must follow the format: `type[(scope)]: description` (e.g., `feat(sdk): add new feature`). | ||
|
|
||
| ## Architecture | ||
|
|
||
| - **The runtime is separate from the CLI.** `tesseract_core.runtime` runs inside containers; `tesseract_core.sdk` and CLI run on the host. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
dionhaefner marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| # Tesseract Design Patterns | ||
|
|
||
| This page provides guidance on common questions around Tesseract design: what should (and shouldn't) be a Tesseract, and how to structure your workflow. | ||
|
|
||
| ## When to use a Tesseract | ||
|
|
||
| Tesseracts are most useful when you need to: | ||
|
|
||
| - **Share software across teams** — Package your code so others can use it without understanding implementation details | ||
| - **Combine heterogeneous software** — Integrate components written in different languages/frameworks into a unified pipeline | ||
| - **Deploy to diverse hardware** — Run the same component on different machines (local, cloud, HPC) without modification | ||
| - **Enable gradient-based optimization** — Expose derivatives for use in optimization or calibration workflows | ||
|
dionhaefner marked this conversation as resolved.
Outdated
|
||
| - **Ensure reproducibility** — Capture dependencies and environment in a container for consistent execution | ||
|
|
||
| ## When NOT to use a Tesseract | ||
|
|
||
| Tesseracts add overhead that isn't always justified: | ||
|
|
||
| - **Single-user, single-environment workflows** — If you're the only one running the code on a single machine, the containerization overhead may not be worth it | ||
| - **Sub-second latency requirements** — Tesseracts are designed for compute kernels that run for at least several seconds; for very fast operations, the container and HTTP overhead becomes significant | ||
| - **Tightly coupled iterations** — If your inner loop calls a function millions of times, that function shouldn't be a Tesseract; instead, wrap the entire loop | ||
| - **Simple scripts** — A quick data transformation script that won't be reused doesn't need Tesseract packaging | ||
|
|
||
| ## How granular should Tesseracts be? | ||
|
|
||
| One of the most common questions is: _"Should I make one big Tesseract or many small ones?"_ | ||
|
|
||
| ### Prefer fewer, coarser Tesseracts when: | ||
|
|
||
| - Operations are tightly coupled and always run together | ||
| - Data transfer between steps would be expensive (e.g., large meshes or tensors) | ||
| - The combined operation is what users actually want to call | ||
| - You need maximum performance (fewer container invocations) | ||
|
|
||
| ### Prefer more, finer Tesseracts when: | ||
|
|
||
| - Components have different hardware requirements (e.g., one needs GPU, one doesn't) | ||
| - Components have conflicting dependencies | ||
| - Different team members own different parts | ||
| - You want to swap out implementations (e.g., different solvers for the same interface) | ||
| - Components are reusable across multiple workflows | ||
|
|
||
| ### A practical rule of thumb | ||
|
|
||
| Think about the **natural unit of work** that makes sense to share. A Tesseract should wrap functionality that: | ||
|
|
||
| 1. Has a clear, well-defined interface (inputs and outputs) | ||
| 2. Represents a meaningful computation (not just a utility function) | ||
| 3. Could reasonably be owned and maintained by one person or team | ||
| 4. Takes at least a few seconds to run (to amortize container overhead) | ||
|
dionhaefner marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## Example: Simulation workflow | ||
|
|
||
| Consider a CFD simulation workflow with these steps: | ||
|
|
||
| 1. Generate mesh from CAD geometry | ||
| 2. Run CFD solver | ||
| 3. Post-process results | ||
| 4. Visualize output | ||
|
|
||
| **Option A: One Tesseract** | ||
|
|
||
| ``` | ||
| CAD → [Mesh + Solve + Post-process + Visualize] → Report | ||
| ``` | ||
|
|
||
| Pros: Simple to deploy, no intermediate data transfer | ||
| Cons: Can't swap solver, can't run meshing on CPU while solving on GPU | ||
|
|
||
| **Option B: Four Tesseracts** | ||
|
|
||
| ``` | ||
| CAD → [Mesh] → [Solve] → [Post-process] → [Visualize] → Report | ||
| ``` | ||
|
|
||
| Pros: Maximum flexibility, clear ownership | ||
| Cons: Data transfer overhead, more complex orchestration | ||
|
|
||
| **Option C: Two Tesseracts (recommended)** | ||
|
|
||
| ``` | ||
| CAD → [Mesh] → [Solve + Post-process + Visualize] → Report | ||
| ``` | ||
|
|
||
| Pros: Separates geometry (often CPU-bound, different expertise) from simulation (often GPU-bound, different team), minimal data transfer for tightly coupled steps | ||
|
|
||
| The right choice depends on your team structure, hardware constraints, and reuse patterns. When in doubt, start with fewer Tesseracts and split them later if needed — it's easier to break apart than to combine. | ||
|
|
||
| ## Designing good interfaces | ||
|
|
||
| ### Keep schemas focused | ||
|
|
||
| Your `InputSchema` and `OutputSchema` should contain only what's needed for the computation. Avoid: | ||
|
|
||
| - Configuration that rarely changes (put it in the Tesseract itself or make it a build-time option) | ||
| - Metadata that's not used in computation | ||
| - Redundant fields that can be derived from others | ||
|
|
||
| ### Use meaningful types | ||
|
|
||
| ```python | ||
| # Less clear | ||
| class InputSchema(BaseModel): | ||
| data: Array[(None, None), Float64] # What is this? | ||
|
|
||
| # More clear | ||
| class InputSchema(BaseModel): | ||
| mesh_coordinates: Array[(None, 3), Float64] = Field( | ||
| description="Node coordinates of the mesh (N nodes x 3 dimensions)" | ||
| ) | ||
| ``` | ||
|
|
||
| ### Design for composability | ||
|
|
||
| If your Tesseract might be chained with others, design interfaces that make this natural: | ||
|
|
||
| ```python | ||
| # Mesh generator output | ||
| class MeshOutput(BaseModel): | ||
| nodes: Array[(None, 3), Float64] | ||
| elements: Array[(None, 4), Int32] | ||
|
|
||
| # Solver input (matches mesh output) | ||
| class SolverInput(BaseModel): | ||
| nodes: Array[(None, 3), Float64] | ||
| elements: Array[(None, 4), Int32] | ||
| boundary_conditions: BoundaryConditions | ||
| ``` | ||
|
|
||
| ## Common anti-patterns | ||
|
|
||
| ### The "kitchen sink" Tesseract | ||
|
|
||
| Don't create a single Tesseract that does everything your project needs. This defeats the purpose of modularity and makes it hard to maintain or reuse. | ||
|
|
||
| ### The "micro-Tesseract" | ||
|
|
||
| Don't wrap trivial operations like `add(a, b)` as Tesseracts. The overhead isn't justified, and such operations should just be regular functions in your pipeline code. | ||
|
|
||
|
dionhaefner marked this conversation as resolved.
Outdated
|
||
| ### Ignoring the single-entrypoint design | ||
|
|
||
| Tesseracts have one `apply` function. If you need multiple entrypoints, create multiple Tesseracts. Don't try to work around this with mode flags: | ||
|
dionhaefner marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```python | ||
| # Anti-pattern: mode switching | ||
| class InputSchema(BaseModel): | ||
| mode: Literal["train", "predict", "evaluate"] | ||
| ... | ||
|
|
||
| # Better: separate Tesseracts | ||
| # - model-trainer (for training) | ||
| # - model-predictor (for inference) | ||
| # - model-evaluator (for evaluation) | ||
| ``` | ||
|
|
||
| ### Stateful operations | ||
|
|
||
| Tesseracts are designed to be stateless and context-free. Each call to `apply` should be independent. If you need state: | ||
|
|
||
| - Pass it explicitly in the input schema | ||
| - Store it in external storage (files, databases) and reference it by path | ||
| - Reconsider whether a Tesseract is the right abstraction | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.