Skip to main content

Introduction

The Deployment module transforms built solutions into runnable software. It provides a unified interface that works the same whether you’re running locally, in Docker, on Modal, or any other platform.

Key Features

FeatureDescription
Unified InterfaceSame run(), stop(), start(), logs() API regardless of deployment target
Full LifecycleStart, stop, and restart deployments programmatically
Plugin ArchitectureStrategies are self-contained packages - add new ones without changing core code
Auto-SelectionLLM-based selector chooses optimal strategy based on your code
Agent-Driven AdaptationCoding agents transform your code and handle deployment

Quick Start

Basic Usage

from src.tinkerer import Tinkerer

# Build a solution
tinkerer = Tinkerer()
solution = tinkerer.evolve("Create a sentiment analysis API")

# Deploy it (AUTO selects best strategy)
software = tinkerer.deploy(solution)

# Use it
result = software.run({"text": "I love this product!"})
print(result)
# {"status": "success", "output": {"sentiment": "positive"}}

# Clean up
software.stop()

Full Lifecycle Management

# Deploy
software = tinkerer.deploy(solution, strategy=DeployStrategy.DOCKER)

# Run
result = software.run({"text": "hello"})

# Stop (terminates container/cloud deployment)
software.stop()

# Restart (re-creates container/re-deploys to cloud)
software.start()

# Run again after restart
result = software.run({"text": "world"})

# Final cleanup
software.stop()

Specify a Strategy

from src.deployment import DeployStrategy

# Force a specific deployment target
software = tinkerer.deploy(solution, strategy=DeployStrategy.MODAL)
software = tinkerer.deploy(solution, strategy=DeployStrategy.DOCKER)
software = tinkerer.deploy(solution, strategy=DeployStrategy.LOCAL)

Using Context Manager

# Auto-cleanup when done
with tinkerer.deploy(solution) as software:
    result = software.run({"input": "data"})
    print(result)
# software.stop() called automatically

Direct Factory Usage

from src.deployment import DeploymentFactory, DeployStrategy, DeployConfig

config = DeployConfig(
    solution=solution,
    env_vars={"API_KEY": "xxx"},
    timeout=300,
)

software = DeploymentFactory.create(DeployStrategy.AUTO, config)

Deployment Flow

The system works in four phases:
┌─────────────────────────────────────────────────────────────────────────┐
│  Phase 1: SELECTION                                                     │
│  ─────────────────                                                      │
│  SelectorAgent analyzes your code and chooses the best strategy         │
│  (skipped if you specify a strategy explicitly)                         │
└─────────────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────────────┐
│  Phase 2: ADAPTATION                                                    │
│  ───────────────────                                                    │
│  AdapterAgent transforms your code for the target platform:             │
│  - Creates deployment files (Dockerfile, modal_app.py, etc.)            │
│  - Adds entry point (main.py with predict() function)                   │
│  - Runs the deployment command                                          │
│  - Reports the endpoint URL                                             │
└─────────────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────────────┐
│  Phase 3: RUNNER CREATION                                               │
│  ────────────────────────                                               │
│  Factory creates the appropriate Runner for the strategy:               │
│  - LocalRunner: imports and calls Python functions                      │
│  - ModalRunner: calls Modal remote functions                            │
│  - DockerRunner: makes HTTP requests to container                       │
└─────────────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────────────┐
│  Phase 4: SOFTWARE WRAPPER                                              │
│  ─────────────────────────                                              │
│  DeployedSoftware wraps the runner with unified interface:              │
│  - Normalizes all responses to {"status": "...", "output": ...}         │
│  - Provides run(), stop(), logs(), is_healthy()                         │
│  - Hides all infrastructure complexity from users                       │
└─────────────────────────────────────────────────────────────────────────┘

Available Strategies

StrategyInterfaceBest ForGPU Support
LOCALFunction importDevelopment, testingNo
DOCKERHTTPMicroservices, containerizationOptional
MODALRemote functionServerless GPU, ML inferenceYes
BENTOMLHTTPProduction ML serving, batchingOptional
LANGGRAPHLangGraph CloudAgent deploymentsNo
See Strategies Reference for detailed information on each.

Response Format

All software.run() calls return a consistent format:
# Success
{
    "status": "success",
    "output": {...}  # Your function's return value
}

# Error
{
    "status": "error",
    "error": "Error message here"
}
This consistency holds regardless of whether you’re running locally or on a cloud platform.

Next Steps