---
title: Jobs
description: Jobs in the dltHub Runtime Python SDK (dlthub_sdk)
keywords: [dlthub, runtime, python sdk, dlthub_sdk, api]
---
# Jobs

<!-- generated from dlthub-client 0.33.1, do not edit -->

New to the SDK? [Getting started](getting-started.md) shows how to connect and use it.

## `Jobs` {#jobs}

The jobs of one workspace.

### `Jobs.trigger()` {#jobs-trigger}

```python
trigger(
    *,
    refs: Sequence[str] | None = None,
    selectors: Sequence[str] | None = None,
    profile: str | None | Keep = KEEP,
    refresh: bool = False,
    dry_run: bool = False,
) -> tuple[TriggerResult, ...]
```

Ask several jobs to run, by ref or by selector.

Unlike [`Job.start_run()`](#job-start_run), this call does not take a trigger of its own.
A job named in `refs` fires its `default_trigger`, or a manual trigger
when it has none. A job matched by `selectors` fires the trigger that it
matched. When its `default_trigger` also matched, that trigger wins.

**Arguments**

| Name | Type | Description |
| --- | --- | --- |
| `refs` | <code>Sequence[str] &#124; None</code> | Job refs to run. Each resolves to exactly one job. |
| `selectors` | <code>Sequence[str] &#124; None</code> | Trigger patterns to match, `fnmatch`-style, for example `"tag:backfill"`, `"schedule:*"`, `"manual:jobs.mod.*"`. |
| `profile` | <code>str &#124; None &#124; <a href="client#keep">Keep</a></code> | Deprecated. Each job runs under its own profile. The runtime accepts only a name that every matched job runs under and refuses any other value with `BadRequest`. |
| `refresh` | <code>bool</code> | Whether each started job run is a refresh, as for [`Job.start_run()`](#job-start_run). The runtime also resets the progress of downstream jobs that depend on their freshness. The runtime ignores this argument for a job whose `refresh_propagation` is `"block"`. |
| `dry_run` | <code>bool</code> | Whether to only report the plan. A dry run starts no job run. |

**Returns:** <code>tuple[<a href="#triggerresult">TriggerResult</a>, ...]</code> — One result per matched job. Async mode returns an awaitable. Started jobs come first, then skipped ones, each in the dependency order of the runtime. A job that the runtime did not start is also present, with its reason (see [`TriggerResult`](#triggerresult)).

**Raises**

| Exception | When |
| --- | --- |
| [`Conflict`](errors.md#conflict) | The current state does not allow the call, for example an archived workspace. `code` and `message` say why. |
| [`NotAuthorized`](errors.md#notauthorized) | The caller lacks the access that this call needs. `message` says why. |
| [`NotFound`](errors.md#notfound) | A ref names no job in this workspace, or only an archived one. |
| [`ScopeMissing`](errors.md#scopemissing) | No workspace in scope. |
| `ValueError` | Neither `refs` nor `selectors` was given. |

### `Jobs.deploy_manifest()` {#jobs-deploy_manifest}

```python
deploy_manifest(
    manifest: DeployManifest,
    *,
    manifest_hash: str,
    deployment_module: str | None = None,
    description: str | None | Keep = KEEP,
    dry_run: bool = False,
) -> DeployReport
```

Reconcile the jobs of the workspace with a deployment manifest.

The job definitions go to the runtime as the deployment manifest carries
them. This call registers the jobs, not their code. The code comes from an
earlier [`Deployments.upload()`](deployments.md#deployments-upload).

**Arguments**

| Name | Type | Description |
| --- | --- | --- |
| `manifest` | <code><a href="#deploymanifest">DeployManifest</a></code> | The deployment manifest to deploy, as dlt built it. Its jobs and engine version go together, so the two always match. |
| `manifest_hash` | <code>str</code> | Content hash of that deployment manifest, from dlt's `generate_manifest_hash`. |
| `deployment_module` | <code>str &#124; None</code> | The deployment module that this deploy claims. `None`, the default, is an ad-hoc deploy: the runtime adds and updates jobs but never archives them. With a module, the runtime archives the jobs that the module owns and that the deployment manifest no longer lists. |
| `description` | <code>str &#124; None &#124; <a href="client#keep">Keep</a></code> | Workspace description, applied only when `deployment_module` is `"__deployment__"`. `None` and the default leave it as it is. |
| `dry_run` | <code>bool</code> | Whether to only report the plan, without saving it. Jobs in a dry-run report that are not yet deployed carry a placeholder `id` and cannot be used in other calls. |

**Returns:** <code><a href="#deployreport">DeployReport</a></code> — What the deploy added, updated, did not change and archived. Async mode returns an awaitable.

**Raises**

| Exception | When |
| --- | --- |
| [`BadRequest`](errors.md#badrequest) | The runtime rejected the request as invalid. `message`, `code` and `fields` say why. |
| [`Conflict`](errors.md#conflict) | The current state does not allow the call, for example an archived workspace. `code` and `message` say why. |
| [`NotAuthorized`](errors.md#notauthorized) | The caller lacks the access that this call needs. `message` says why. |
| [`ScopeMissing`](errors.md#scopemissing) | No workspace in scope. |
| `ValueError` | The deployment manifest lists no jobs. |

### `Jobs.get()` {#jobs-get}

```python
get(*, id: str) -> Job
```

Return one job by ID.

**Arguments**

| Name | Type | Description |
| --- | --- | --- |
| `id` | <code>str</code> | The UUID of the job. `get_by_ref()` finds a job by its ref. |

**Returns:** <code><a href="#job">Job</a></code> — The job. Async mode returns an awaitable.

**Raises**

| Exception | When |
| --- | --- |
| [`BadRequest`](errors.md#badrequest) | The runtime rejected the request as invalid. `message`, `code` and `fields` say why. |
| [`NotFound`](errors.md#notfound) | The job does not exist in this workspace. |
| [`ScopeMissing`](errors.md#scopemissing) | No workspace in scope. |

### `Jobs.get_by_ref()` {#jobs-get_by_ref}

```python
get_by_ref(ref: str) -> Job
```

Return one job by its ref, archived or not.

**Arguments**

| Name | Type | Description |
| --- | --- | --- |
| `ref` | <code>str</code> | The job ref, for example `jobs.load`. |

**Returns:** <code><a href="#job">Job</a></code> — The job. Async mode returns an awaitable.

**Raises**

| Exception | When |
| --- | --- |
| [`NotFound`](errors.md#notfound) | No job in this workspace has that ref. |
| [`ScopeMissing`](errors.md#scopemissing) | No workspace in scope. |

### `Jobs.count()` {#jobs-count}

```python
count(*, archived: bool | Keep = KEEP) -> int
```

Return how many jobs the workspace has, without reading them.

**Arguments**

| Name | Type | Description |
| --- | --- | --- |
| `archived` | <code>bool &#124; <a href="client#keep">Keep</a></code> | As for `list()`. |

**Returns:** <code>int</code> — The job count, which saturates at 10,001. A count of 10,001 means "at least this many". Async mode returns an awaitable.

**Raises**

| Exception | When |
| --- | --- |
| [`ScopeMissing`](errors.md#scopemissing) | No workspace in scope. |

### `Jobs.list()` {#jobs-list}

```python
list(
    *,
    archived: bool | Keep = KEEP,
    limit: int | None = None,
    offset: int = 0,
) -> Iterable[Job] | AsyncIterable[Job]
```

Yield the jobs in the workspace, page by page.

Errors from the runtime raise when the iteration starts, not in this call.

**Arguments**

| Name | Type | Description |
| --- | --- | --- |
| `archived` | <code>bool &#124; <a href="client#keep">Keep</a></code> | `True` lists only archived jobs, and `False` only live jobs. [`KEEP`](client.md#KEEP), the default, lists both. |
| `limit` | <code>int &#124; None</code> | The most jobs to return. `None` returns every job up to item 10,100, where the runtime stops paging. |
| `offset` | <code>int</code> | The number of jobs that the runtime skips first. |

**Returns:** <code>Iterable[<a href="#job">Job</a>] &#124; AsyncIterable[<a href="#job">Job</a>]</code> — An iterable of jobs. Async mode returns an async iterable.

**Raises**

| Exception | When |
| --- | --- |
| [`ScopeMissing`](errors.md#scopemissing) | No workspace in scope. |
| `ValueError` | A negative `limit` or `offset`. |

## `Job` {#job}

A deployed job in a workspace.

**[Collections](getting-started.md#collections-and-attributes)**

| Name | Type | Example | Description |
| --- | --- | --- | --- |
| `job.runs` | <code><a href="job-runs#jobruns">JobRuns</a></code> | `job.runs.list()` | The job runs of this job. |

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `job_ref` | <code>str</code> | Canonical job reference, unique per workspace. |
| `id` | <code>str</code> | Unique ID (a UUID). |
| `name` | <code>str &#124; None</code> | Display name for the job. |
| `job_type` | <code><a href="#jobtype">JobType</a></code> | The type of the job: batch, interactive, or stream. |
| `profile` | <code>str</code> | The profile the job runs under. |
| `is_paused` | <code>bool</code> | Whether the job's scheduled runs are paused. The scheduler does not start it, including a scheduled run that was waiting for its upstream jobs; manual runs, runs started by a trigger request, and runs started by another job's success or failure still run. Only a job with `next_scheduled_run_at` can be paused, and a deploy that removes the schedule clears the pause. |
| `is_archived` | <code>bool</code> | Whether the job is archived. Archived jobs cannot be run and their public URL stops working. |
| `version` | <code>int</code> | Version number, starting at 1 and incremented by each update to the job: a job's current version, or a job version's own number. |
| `public_url` | <code>str &#124; None</code> | The public URL where the job can be accessed without authentication; `None` when the job is not published. It does not work while the job is archived. |
| `job_url` | <code>str &#124; None</code> | The URL of the job in the web app for an interactive job; `None` otherwise. |
| `default_trigger` | <code>str &#124; None</code> | The trigger fired when a run is started without naming one, computed from the job definition. |
| `triggers` | <code>tuple[str, ...]</code> | Every trigger the job answers to, computed from its definition; selectors match against these. |
| `next_scheduled_run_at` | <code>datetime &#124; None</code> | When the job is next scheduled to run; `None` if it has no schedule. |
| `job_definition` | <code>Mapping[str, Any]</code> | The job definition from the deployment manifest, migrated to the current format of the runtime. The SDK leaves it opaque, because it is a nested structure of dlt. |
| `created_at` | <code>datetime</code> | When it was created. |

### `Job.pause()` {#job-pause}

```python
pause() -> Job
```

Pause the schedule of the job.

The call changes nothing for a paused job.

**Returns:** <code><a href="#job">Job</a></code> — A fresh snapshot with `is_paused` set. Async mode returns an awaitable.

**Raises**

| Exception | When |
| --- | --- |
| [`BadRequest`](errors.md#badrequest) | The runtime rejected the request as invalid. `message`, `code` and `fields` say why. |
| [`Conflict`](errors.md#conflict) | The current state does not allow the call, for example an archived workspace. `code` and `message` say why. |
| [`NotFound`](errors.md#notfound) | The job no longer exists. |

### `Job.resume()` {#job-resume}

```python
resume() -> Job
```

Resume the schedule of the job.

The call changes nothing for a job that is not paused.

**Returns:** <code><a href="#job">Job</a></code> — A fresh snapshot with `is_paused` cleared. Async mode returns an awaitable.

**Raises**

| Exception | When |
| --- | --- |
| [`Conflict`](errors.md#conflict) | The current state does not allow the call, for example an archived workspace. `code` and `message` say why. |
| [`NotFound`](errors.md#notfound) | The job no longer exists. |

### `Job.publish()` {#job-publish}

```python
publish() -> Job
```

Expose the job on a public link.

A second call issues a new public link and invalidates the previous one.

**Returns:** <code><a href="#job">Job</a></code> — A fresh snapshot with `public_url` set. Async mode returns an awaitable.

**Raises**

| Exception | When |
| --- | --- |
| [`Conflict`](errors.md#conflict) | The current state does not allow the call, for example an archived workspace. `code` and `message` say why. |
| [`NotFound`](errors.md#notfound) | The job no longer exists. |

### `Job.unpublish()` {#job-unpublish}

```python
unpublish() -> Job
```

Withdraw the public link of the job.

The call changes nothing for a job that is not published.

**Returns:** <code><a href="#job">Job</a></code> — A fresh snapshot with `public_url` cleared. Async mode returns an awaitable.

**Raises**

| Exception | When |
| --- | --- |
| [`Conflict`](errors.md#conflict) | The current state does not allow the call, for example an archived workspace. `code` and `message` say why. |
| [`NotFound`](errors.md#notfound) | The job no longer exists. |

### `Job.archive()` {#job-archive}

```python
archive() -> Job
```

Retire the job, so that it no longer runs, manually or on schedule.

The runtime clears its schedule, default trigger and pause.
`list(archived=True)` still lists it. The call changes nothing for an
archived job.

**Returns:** <code><a href="#job">Job</a></code> — A fresh snapshot with `is_archived` set. Async mode returns an awaitable.

**Raises**

| Exception | When |
| --- | --- |
| [`Conflict`](errors.md#conflict) | The current state does not allow the call, for example an archived workspace. `code` and `message` say why. |
| [`NotFound`](errors.md#notfound) | The job no longer exists. |

### `Job.unarchive()` {#job-unarchive}

```python
unarchive() -> Job
```

Let an archived job run again.

The runtime restores its schedule and default trigger from its definition,
but not a pause. The call changes nothing for a live job.

**Returns:** <code><a href="#job">Job</a></code> — A fresh snapshot with `is_archived` cleared. Async mode returns an awaitable.

**Raises**

| Exception | When |
| --- | --- |
| [`Conflict`](errors.md#conflict) | The current state does not allow the call, for example an archived workspace. `code` and `message` say why. |
| [`NotFound`](errors.md#notfound) | The job no longer exists. |

### `Job.start_run()` {#job-start_run}

```python
start_run(
    *,
    trigger: str = MANUAL_TRIGGER,
    profile: str | None | Keep = KEEP,
    refresh: bool = False,
    skip_freshness: bool = False,
) -> JobRun
```

Start a run of this job.

When the runtime does not start the job run, the call raises. The `code`
of the error names why, and `fields` carries the reasons of the runtime.

**Arguments**

| Name | Type | Description |
| --- | --- | --- |
| `trigger` | <code>str</code> | The trigger to fire, in canonical form. Defaults to `"manual:"`. The runtime checks only the form, so it still accepts a trigger that the job definition does not declare. |
| `profile` | <code>str &#124; None &#124; <a href="client#keep">Keep</a></code> | Deprecated. A job runs under its own profile. The runtime accepts only its name and refuses any other value with `BadRequest`. |
| `refresh` | <code>bool</code> | Whether the job run is a refresh. The progress of the job goes back to its interval start. The job run gets `refresh=True` in its run context. The job code decides what to reload. The runtime also resets the progress of downstream jobs that depend on its freshness. The runtime ignores this argument when the `refresh_propagation` of the job is `"block"`. |
| `skip_freshness` | <code>bool</code> | Whether to start when an upstream job that the freshness constraints name is not fresh. |

**Returns:** <code><a href="job-runs#jobrun">JobRun</a></code> — The job run that started. Async mode returns an awaitable.

**Raises**

| Exception | When |
| --- | --- |
| [`BadRequest`](errors.md#badrequest) | The runtime rejected the request as invalid, for example for an archived job. `message`, `code` and `fields` say why. |
| [`Conflict`](errors.md#conflict) | The runtime did not start the job run, for example because an upstream job is not fresh, the job is outside its interval, or a concurrency limit is reached. `code` says which. An archived workspace also raises it. |
| [`NotAuthorized`](errors.md#notauthorized) | The caller lacks the access that this call needs, or the trial has ended (`trial_expired`), or the plan has no credits left (`compute_minutes_exhausted`). `code` says which. |
| [`NotFound`](errors.md#notfound) | The job does not exist in this workspace. |
| [`ScopeMissing`](errors.md#scopemissing) | No workspace in scope. |

## `DeployReport` {#deployreport}

What a deploy of a deployment manifest did to the jobs of a workspace.

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `added` | <code>tuple[<a href="#job">Job</a>, ...]</code> | Jobs that the deployment manifest introduced. |
| `updated` | <code>tuple[<a href="#job">Job</a>, ...]</code> | Jobs it changed, at their new version. |
| `unchanged` | <code>tuple[<a href="#job">Job</a>, ...]</code> | Jobs it did not change. |
| `archived` | <code>tuple[<a href="#job">Job</a>, ...]</code> | Jobs it archived, which happens only for a module deploy. |
| `warnings` | <code>tuple[str, ...]</code> | Always empty at present. |
| `deployment_module` | <code>str &#124; None</code> | The deployment module the deploy was scoped to. |

## `TriggerResult` {#triggerresult}

The outcome of a request to run a job through [`Jobs.trigger()`](#jobs-trigger).

A request does not guarantee a job run. The runtime skips a trigger that it
cannot accept, and gives the reason. `started` tells if `job_run_id` is
set. A dry run creates no job run, so `job_run_id` is `None` there too.

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `job_ref` | <code>str</code> | The job reference of the matched job. |
| `job_id` | <code>str</code> | The ID of the matched job. |
| `status` | <code><a href="#triggerstatus">TriggerStatus</a></code> | Whether a job run started, or why it did not. |
| `reasons` | <code>tuple[str, ...]</code> | Human-readable reasons for a skip, e.g. which upstream jobs are not fresh; `None` when the job was triggered or no reasons were recorded. |
| `trigger` | <code>str</code> | The trigger the job fires with. |
| `job_run_id` | <code>str &#124; None</code> | The ID of the created run; `None` in dry-run mode or when skipped. |
| `job_run_number` | <code>int &#124; None</code> | Number of the run within its job, counting up from 1; numbers repeat across jobs. |
| `matched_triggers` | <code>tuple[str, ...]</code> | Every trigger that selected this job: its default trigger when `refs` names it, plus any selector matches. |
| `started` | <code>bool</code> | Whether the runtime started a job run. In a dry run, whether it starts one. |

## `DeployManifest` {#deploymanifest}

The part of a dlt deployment manifest that a deploy reads.

A read-only subset, so the deployment manifest type of dlt matches it.

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `engine_version` | <code>int</code> | Engine version of the deployment manifest that the definitions come from. |
| `jobs` | <code>Sequence[Mapping[str, Any]]</code> | Job definitions, exactly as the deployment manifest carries them. |

## `JobType` {#jobtype}

How a job runs.

**Members**

| Member | Value | Description |
| --- | --- | --- |
| `BATCH` | `'batch'` | Runs to completion and exits. |
| `INTERACTIVE` | `'interactive'` | Serves an interactive session. |
| `STREAM` | `'stream'` | Runs continuously. |
| `UNKNOWN` | `'unknown'` | A type that this SDK version does not know. |

## `TriggerStatus` {#triggerstatus}

What became of a request to run a job.

**Members**

| Member | Value | Description |
| --- | --- | --- |
| `TRIGGERED` | `'triggered'` | The runtime created a job run. |
| `SKIPPED_PAUSED` | `'skipped_paused'` | The job is paused. |
| `SKIPPED_FRESH` | `'skipped_fresh'` | A job that its freshness constraints depend on is not fresh yet. `reasons` names which. |
| `SKIPPED_ALREADY_COVERED` | `'skipped_already_covered'` | A succeeded job run already covers this interval. |
| `SKIPPED_OUT_OF_INTERVAL` | `'skipped_out_of_interval'` | The trigger is outside the interval of the job. |
| `SKIPPED_UPSTREAM_PENDING` | `'skipped_upstream_pending'` | The same request also starts a job that this job depends on. This job runs after that job finishes. |
| `SKIPPED_CONCURRENCY_LIMIT` | `'skipped_concurrency_limit'` | The job already has as many active job runs as its concurrency limit allows. |
| `SKIPPED_ORG_CONCURRENCY_LIMIT` | `'skipped_org_concurrency_limit'` | The organization is at its limit of active job runs. |
| `SKIPPED_MINUTES_LIMIT` | `'skipped_minutes_limit'` | The plan has no credits left. |
| `SKIPPED_TRIAL_EXPIRED` | `'skipped_trial_expired'` | The trial has ended. |
| `SKIPPED_WORKSPACE_ARCHIVED` | `'skipped_workspace_archived'` | The workspace is archived. |
| `UNKNOWN` | `'unknown'` | A status that this SDK version does not know. |
