---
title: Deployments
description: Deploy dlt pipelines, jobs, and interactive applications to the dltHub platform with ad-hoc runs or a versioned deployment manifest
keywords: [dlthub platform, deploy, deployment, jobs, decorators, manifest, reconciliation]
---
# Deployments

The dltHub platform offers two ways to get your code running in the cloud:

- **Ad-hoc launch** — point `dlthub run` or `dlthub serve` at a Python file. Best for quickly trying a script.
- **Manifest-based deploy** — declare jobs in `__deployment__.py` and run `dlthub deploy`. Required for scheduling, follow-up triggers, freshness checks, and multi-job workspaces.

Both methods require a configured workspace — see [Workspace setup](workspace-setup.md) if you haven't done that yet.

## Quick deploy: ad-hoc launch

The fastest way to run an existing script on the dltHub platform is to point `run` or `serve` at a Python file:

```cli
# run the batch script locally first to catch missing dependencies or broken config
dlthub local run fruitshop_pipeline.py

# Deploy and run a batch script (runs with the `prod` profile)
dlthub run fruitshop_pipeline.py

# Stream logs in your terminal until the run completes
dlthub run fruitshop_pipeline.py -f

# Serve an interactive app (notebook, dashboard, MCP). On the platform it runs with the default profile with read data access
dlthub local serve fruitshop_notebook.py    # local
dlthub serve fruitshop_notebook.py          # remote
```

Under the hood, the CLI generates a single-job deployment manifest from that file and syncs it to the dltHub platform. This **ad-hoc deploy** is great for getting started but does not support:

- Scheduled triggers (cron, intervals)
- Follow-up jobs (run B after A succeeds)
- Freshness constraints
- Multi-job workspaces deployed as a unit

For all of these you need **job decorators** and a **deployment module**, described next.

## Jobs and deployments

A dltHub platform workspace can contain many jobs scheduled on different cadences, chained together by triggers and freshness constraints. The three building blocks are:

- **Job decorators** that attach scheduling and metadata to Python functions
- **`__deployment__.py`** that declares which jobs exist in the workspace
- **`dlthub deploy`** that syncs the entire job graph to the dltHub platform in one step

### Job decorators

The `dlt.hub.run` module provides four decorators:

| Decorator          | Used for                                                                                                                       |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| `@run.pipeline`    | A batch job bound to a named `dlt.pipeline` (gets pipeline-aware retries and dataset linking)                                  |
| `@run.job`         | A general-purpose batch job (any Python function — data quality checks, reports, custom scripts)                               |
| `@run.interactive` | A long-running HTTP service (notebook, MCP server, Streamlit app, REST API)                                                    |
| `@run.agent`       | A background agent that runs unattended, for example to inspect a failed job run (see [Background agents](../agents/index.md)) |

Example: an ingestion pipeline that runs every 5 minutes and is tagged for bulk operations.

```py notype
import dlt
from dlt.hub import run
from dlt.hub.run import trigger

@run.pipeline(
    "github_pipeline",
    trigger=trigger.every("5m"),
    expose={"tags": ["ingest"], "display_name": "GitHub commits ingest"},
)
def load_commits():
    """Load commits and contributors from the GitHub REST API."""
    pipeline = dlt.pipeline(
        pipeline_name="github_pipeline",
        destination="warehouse",
        dataset_name="github_data",
    )
    pipeline.run(github_rest_api_source())
```

A general-purpose job, scheduled hourly:

```py notype
@run.job(
    trigger=trigger.schedule("0 * * * *"),
    expose={"display_name": "GitHub data quality"},
)
def run_dq_checks():
    """Validate ingested data; the job fails if any check fails."""
    if not all_passed:
        raise RuntimeError("Data quality checks failed")
```

For the full catalog of `trigger=` options (cron, intervals, follow-ups, freshness, refresh cascade), see [Triggers and scheduling](triggers.md). For per-job options like `execute=`, `retry=`, `require=`, and `expose=`, see [Job configuration](job-configuration.md).

### Job results

A job can report a structured result of its run. Pass a JSON-serializable value to `run.result()`. It returns the value unchanged, so you can return it as well:

```py notype
@run.job(trigger=trigger.schedule("0 6 * * *"))
def daily_report():
    rows = count_rows()
    return run.result({"rows": rows, "tables": 12}, type="etl_summary")
```

- Only the job that the runner started records a result. A job called from another job as a plain function doesn't overwrite it, and a second call replaces the first.
- `type` names the shape of the payload, `job.etl_summary` here. It defaults to the job name.
- After the run, `dlthub local run` prints the job result and the runner sends it to the dltHub platform. It also lists the entities the run acted on, taken from its [entity-typed inputs and outputs](job-configuration.md#inputs-and-outputs).
- Outside a job run, `run.result()` returns the value and records nothing.

An [agent job](../agents/index.md) delivers its job result itself, with the agent output and the agent trace in it.

### The deployment module

`__deployment__.py` is a Python module that declares everything deployable in the workspace. The dltHub platform discovers jobs by inspecting it. It is the default deployment module: an environment can name another module, see [Choose the deployment module of an environment](profiles.md#choose-the-deployment-module-of-an-environment).

```py
"""GitHub ingest workspace -- loads and monitors GitHub API data"""

from github_pipeline import load_commits
from github_dq_pipeline import run_dq_checks

import github_transformations_notebook
import github_dq_notebook
import github_report_notebook

__all__ = [
    "load_commits",
    "run_dq_checks",
    "github_transformations_notebook",
    "github_dq_notebook",
    "github_report_notebook",
]
```

Rules:

- **Function imports** (`from github_pipeline import load_commits`) produce one job per function. The function must be decorated with `@run.pipeline`, `@run.job`, or `@run.interactive`.
- **Module imports** (`import github_report_notebook`) produce one job per module. The framework is auto-detected — marimo notebooks become interactive notebook jobs, FastMCP modules become MCP servers, Streamlit modules become dashboards. Set the options of such a job with `__require__` and `__access__` in the module, see [Options of module jobs](job-configuration.md#options-of-module-jobs).
- **`__all__`** lists exactly the names to deploy. Without it, the manifest generator scans `__dict__` and warns.
- **`__doc__`** (the module docstring) becomes the workspace description in the dltHub platform dashboard.

You can also define decorated jobs **inline** in `__deployment__.py` — useful for small MCP servers or one-off batch jobs.

### Deploying with `dlthub deploy`

This is the central command for manifest-based deployment. It reads the deployment module of the environment, `__deployment__.py` by default, generates a manifest, and syncs it to the dltHub platform:

```cli
dlthub deploy
```

A deployment is made to the [environment](profiles.md#how-environments-work) of the active profile, else to the default environment, `prod` in a new workspace. `dlthub deploy` runs with the default write profile of that environment. Name another environment with `--environment`:

```cli
dlthub deploy --environment staging
```

The deploy command:

1. Imports the deployment module and collects every job
2. Generates a deployment manifest (a JSON document describing every job's triggers, entry point, and metadata)
3. Syncs your code and configuration to the dltHub platform
4. Sends the manifest for **reconciliation**

#### Reconciliation

The dltHub platform compares the new manifest against the currently deployed jobs:

| Status        | Meaning                                                                                     |
| ------------- | ------------------------------------------------------------------------------------------- |
| **added**     | New job — will be created                                                                   |
| **updated**   | Job definition changed — will be updated                                                    |
| **unchanged** | No changes — left as-is                                                                     |
| **archived**  | Job was in the previous manifest but not in this one — triggers disabled, history preserved |

Removing a job from `__deployment__.py` does not delete it — it archives it, preserving run history and logs.

#### Preview before deploying

```cli
# see what would change without applying
dlthub deploy --dry-run

# dump the full expanded manifest as YAML
dlthub deploy --show-manifest
```

### Running and monitoring deployed jobs

Once deployed, scheduled jobs run automatically. You can also run them by hand — and run the local counterpart first whenever you want to debug locally:

```cli
# run a specific job by name (ad-hoc, syncs code first)
dlthub local run load_commits         # locally
dlthub run load_commits -f            # in the cloud

# trigger jobs without re-syncing code (uses currently deployed code)
dlthub job trigger "tag:ingest"
dlthub job trigger "schedule:*"
dlthub job trigger "tag:ingest" --dry-run    # preview only

# trigger by pipeline name
dlthub local pipeline run github_pipeline    # locally
dlthub pipeline run github_pipeline          # in the cloud

# serve an interactive job
dlthub local serve github_report_notebook    # locally
dlthub serve github_report_notebook          # in the cloud
```

:::note
`dlthub pipeline run` (and its local sibling) can only trigger jobs decorated with `@run.pipeline` — they are matched by `deliver.pipeline_name`. Jobs declared with `@run.job` or `@run.interactive` are not addressable this way; use `dlthub run <job_name>` or `dlthub job trigger <selector>` instead.
:::

For diagnosing failed runs, viewing logs, and dashboards, see [Monitoring and debugging](monitoring.md).

## Deployments and configurations are versioned separately

A [workspace deployment](what-is-a-workspace.md#the-remote-workspace-and-its-deployments) holds two things that you upload:

- **Deployment version** — your code files (`.py` scripts, notebooks)
- **Configuration version** — your `.dlt/*.toml` files (settings and secrets)

You can update code without changing secrets and vice versa. Use these commands to sync them independently:

```cli
# Sync code and configuration without reconciling the manifest
dlthub workspace deployment sync       # sync only code
dlthub workspace configuration sync    # sync only configuration

# List and inspect previous versions
dlthub workspace deployment list
dlthub workspace deployment [<deployment_version_no>] info
dlthub workspace configuration list
dlthub workspace configuration [<configuration_version_no>] info
```

See the [CLI reference](../command-line-interface.md) for the full set of deployment and job commands.

## Deploy with the dltHub AI Harness

The [`dlthub-platform`](../ai-harness/toolkits.md#dlthub-platform) toolkit is how the [dltHub AI Harness](../ai-harness/introduction.md) answers "I've got a pipeline running locally, now how do I run it on dltHub?" It guides your coding agent through preparing `__deployment__.py`, running `dlthub deploy`, wiring up schedules, and debugging failures.

Install the toolkit when you have a pipeline that runs locally with `dlthub local run` and you want to:

- Run it on the platform on demand (one-off) or on a cron schedule.
- Serve a notebook or dashboard as an interactive job.
- Add freshness checks or chain jobs off other job outcomes.
- Debug a job that failed after deploy.

For a one-off remote execution without scheduling you don't strictly need this toolkit. `dlthub run <script>` uploads and runs the script as a batch job. Reach for `dlthub-platform` when you want persistent, scheduled deployment.

### Install

Either let the router pick it when you tell your agent "let's deploy," or install explicitly:

```cli
uv run dlthub ai toolkit install dlthub-platform
```

### The skills

| Skill                        | When it runs                                  | What it does                                                                                                                                                                                         |
| ---------------------------- | --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `prepare-deployment`         | Every time you add or change a deployable job | Splits dev and prod credentials into profile-scoped files, sets up a production destination, and helps you edit `__deployment__.py` so pipelines and notebooks are exported and triggered correctly. |
| `setup-remote-workspace`     | Once, before your first deploy                | Checks that the workspace can deploy (`pyproject.toml`, `.dlt/.workspace`, a deployment module with jobs) and that the dltHub client is installed, logs you in and connects a remote workspace.      |
| `deploy-workspace`           | After the two skills above finish cleanly     | Previews the deployment, deploys new jobs without a running schedule, runs each of them once and switches its schedule on.                                                                           |
| `maintain-dlthub-jobs`       | Day to day                                    | Lists jobs and job runs, pauses, resumes, starts and cancels jobs, sets variables and secrets.                                                                                                       |
| `debug-workspace-deployment` | After a deploy or a scheduled run fails       | Reads platform logs, inspects the manifest, checks credentials, and proposes a fix.                                                                                                                  |

The skills chain naturally, so you usually don't invoke them by name. The workflow rule shipped with the toolkit tells the agent which one to run next. `prepare-deployment` comes with the `local-workspace` toolkit, which `dlthub-platform` installs.

### Schedule a pipeline every 10 mins

Assume you have a `fruitshop_pipeline.py` in the workspace that already runs locally. You tell your agent:

> Deploy `fruitshop_pipeline` to the platform on a 10-minute schedule.

Here's the sequence the toolkit drives, roughly what you'll see in the agent's turns:

**1. `prepare-deployment`**: the agent splits dev and prod credentials into `.dlt/dev.secrets.toml` and `.dlt/prod.secrets.toml`, sets up a production destination (for example, Motherduck if you're on DuckDB locally), then opens `__deployment__.py`, imports `load_fruitshop` from your pipeline module, wraps it with `run.pipeline` and a schedule trigger, and exports it in `__all__`:

**`fruitshop_pipeline.py`**:

```py
import dlt
from fruitshop_source import fruitshop

def load_fruitshop():
    pipeline = dlt.pipeline(
        pipeline_name="fruitshop_pipeline",
        destination="fruitshop_destination",
        dataset_name="fruitshop_data",
    )
    pipeline.run(fruitshop())
```

**`__deployment__.py`**:

```py
"""Fruitshop workspace — ingests fruitshop data every 10 minutes."""
from dlt.hub import run
from dlt.hub.run import trigger
from fruitshop_pipeline import load_fruitshop

load_fruitshop = run.pipeline(
    "fruitshop_pipeline",
    trigger=trigger.schedule("*/10 * * * *"),
)(load_fruitshop)

__all__ = ["load_fruitshop"]
```

**2. `setup-remote-workspace` (only on the first deploy)**: the agent checks `pyproject.toml`, `.dlt/.workspace` and the jobs of the deployment module, verifies that the dltHub client is installed, then walks you through `dlthub login` and `dlthub workspace connect`. If anything is missing, it asks you to fix it before continuing.

**3. `deploy-workspace`**: the agent first runs `uv run dlthub deploy --dry-run` to preview the manifest changes and tells you the environment that it deploys to. The job is new, so the agent takes the schedule trigger out for its first deployment. Then, after you approve:

```cli
uv run dlthub deploy
```

It runs the job once so you see its logs. After you agree, it puts the schedule trigger back and deploys again. It confirms the job registered with the schedule you asked for, and links to the platform UI where you can watch the next run.

**4. Later, if a scheduled run fails**: you tell the agent "the 10-minute job is failing." It invokes `debug-workspace-deployment`, fetches the failed job's logs, checks the manifest and credentials, and either fixes the issue in code or explains why the platform is rejecting the deploy.
