Jobs
New to the SDK? Getting started shows how to connect and use it.
Jobs
The jobs of one workspace.
Jobs.trigger()
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(), 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 | Sequence[str] | None | Job refs to run. Each resolves to exactly one job. |
selectors | Sequence[str] | None | Trigger patterns to match, fnmatch-style, for example "tag:backfill", "schedule:*", "manual:jobs.mod.*". |
profile | str | None | Keep | 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 | bool | Whether each started job run is a refresh, as for 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 | bool | Whether to only report the plan. A dry run starts no job run. |
Returns: tuple[TriggerResult, ...] — 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).
Raises
| Exception | When |
|---|---|
Conflict | The current state does not allow the call, for example an archived workspace. code and message say why. |
NotAuthorized | The caller lacks the access that this call needs. message says why. |
NotFound | A ref names no job in this workspace, or only an archived one. |
ScopeMissing | No workspace in scope. |
ValueError | Neither refs nor selectors was given. |
Jobs.deploy_manifest()
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().
Arguments
| Name | Type | Description |
|---|---|---|
manifest | DeployManifest | The deployment manifest to deploy, as dlt built it. Its jobs and engine version go together, so the two always match. |
manifest_hash | str | Content hash of that deployment manifest, from dlt's generate_manifest_hash. |
deployment_module | str | None | 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 | str | None | Keep | Workspace description, applied only when deployment_module is "__deployment__". None and the default leave it as it is. |
dry_run | bool | 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: DeployReport — What the deploy added, updated, did not change and archived. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
BadRequest | The runtime rejected the request as invalid. message, code and fields say why. |
Conflict | The current state does not allow the call, for example an archived workspace. code and message say why. |
NotAuthorized | The caller lacks the access that this call needs. message says why. |
ScopeMissing | No workspace in scope. |
ValueError | The deployment manifest lists no jobs. |
Jobs.get()
get(*, id: str) -> Job
Return one job by ID.
Arguments
| Name | Type | Description |
|---|---|---|
id | str | The UUID of the job. get_by_ref() finds a job by its ref. |
Returns: Job — The job. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
BadRequest | The runtime rejected the request as invalid. message, code and fields say why. |
NotFound | The job does not exist in this workspace. |
ScopeMissing | No workspace in scope. |
Jobs.get_by_ref()
get_by_ref(ref: str) -> Job
Return one job by its ref, archived or not.
Arguments
| Name | Type | Description |
|---|---|---|
ref | str | The job ref, for example jobs.load. |
Returns: Job — The job. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
NotFound | No job in this workspace has that ref. |
ScopeMissing | No workspace in scope. |
Jobs.count()
count(*, archived: bool | Keep = KEEP) -> int
Return how many jobs the workspace has, without reading them.
Arguments
| Name | Type | Description |
|---|---|---|
archived | bool | Keep | As for list(). |
Returns: int — 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 | No workspace in scope. |
Jobs.list()
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 | bool | Keep | True lists only archived jobs, and False only live jobs. KEEP, the default, lists both. |
limit | int | None | The most jobs to return. None returns every job up to item 10,100, where the runtime stops paging. |
offset | int | The number of jobs that the runtime skips first. |
Returns: Iterable[Job] | AsyncIterable[Job] — An iterable of jobs. Async mode returns an async iterable.
Raises
| Exception | When |
|---|---|
ScopeMissing | No workspace in scope. |
ValueError | A negative limit or offset. |
Job
A deployed job in a workspace.
| Name | Type | Example | Description |
|---|---|---|---|
job.runs | JobRuns | job.runs.list() | The job runs of this job. |
Attributes
| Name | Type | Description |
|---|---|---|
job_ref | str | Canonical job reference, unique per workspace. |
id | str | Unique ID (a UUID). |
name | str | None | Display name for the job. |
job_type | JobType | The type of the job: batch, interactive, or stream. |
profile | str | The profile the job runs under. |
is_paused | bool | 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 | bool | Whether the job is archived. Archived jobs cannot be run and their public URL stops working. |
version | int | 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 | str | None | 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 | str | None | The URL of the job in the web app for an interactive job; None otherwise. |
default_trigger | str | None | The trigger fired when a run is started without naming one, computed from the job definition. |
triggers | tuple[str, ...] | Every trigger the job answers to, computed from its definition; selectors match against these. |
next_scheduled_run_at | datetime | None | When the job is next scheduled to run; None if it has no schedule. |
job_definition | Mapping[str, Any] | 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 | datetime | When it was created. |
Job.pause()
pause() -> Job
Pause the schedule of the job.
The call changes nothing for a paused job.
Returns: Job — A fresh snapshot with is_paused set. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
BadRequest | The runtime rejected the request as invalid. message, code and fields say why. |
Conflict | The current state does not allow the call, for example an archived workspace. code and message say why. |
NotFound | The job no longer exists. |
Job.resume()
resume() -> Job
Resume the schedule of the job.
The call changes nothing for a job that is not paused.
Returns: Job — A fresh snapshot with is_paused cleared. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
Conflict | The current state does not allow the call, for example an archived workspace. code and message say why. |
NotFound | The job no longer exists. |
Job.publish()
publish() -> Job
Expose the job on a public link.
A second call issues a new public link and invalidates the previous one.
Returns: Job — A fresh snapshot with public_url set. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
Conflict | The current state does not allow the call, for example an archived workspace. code and message say why. |
NotFound | The job no longer exists. |
Job.unpublish()
unpublish() -> Job
Withdraw the public link of the job.
The call changes nothing for a job that is not published.
Returns: Job — A fresh snapshot with public_url cleared. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
Conflict | The current state does not allow the call, for example an archived workspace. code and message say why. |
NotFound | The job no longer exists. |
Job.archive()
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: Job — A fresh snapshot with is_archived set. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
Conflict | The current state does not allow the call, for example an archived workspace. code and message say why. |
NotFound | The job no longer exists. |
Job.unarchive()
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: Job — A fresh snapshot with is_archived cleared. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
Conflict | The current state does not allow the call, for example an archived workspace. code and message say why. |
NotFound | The job no longer exists. |
Job.start_run()
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 | str | 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 | str | None | Keep | Deprecated. A job runs under its own profile. The runtime accepts only its name and refuses any other value with BadRequest. |
refresh | bool | 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 | bool | Whether to start when an upstream job that the freshness constraints name is not fresh. |
Returns: JobRun — The job run that started. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
BadRequest | The runtime rejected the request as invalid, for example for an archived job. message, code and fields say why. |
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 | 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 | The job does not exist in this workspace. |
ScopeMissing | No workspace in scope. |
DeployReport
What a deploy of a deployment manifest did to the jobs of a workspace.
Attributes
| Name | Type | Description |
|---|---|---|
added | tuple[Job, ...] | Jobs that the deployment manifest introduced. |
updated | tuple[Job, ...] | Jobs it changed, at their new version. |
unchanged | tuple[Job, ...] | Jobs it did not change. |
archived | tuple[Job, ...] | Jobs it archived, which happens only for a module deploy. |
warnings | tuple[str, ...] | Always empty at present. |
deployment_module | str | None | The deployment module the deploy was scoped to. |
TriggerResult
The outcome of a request to run a job through 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 | str | The job reference of the matched job. |
job_id | str | The ID of the matched job. |
status | TriggerStatus | Whether a job run started, or why it did not. |
reasons | tuple[str, ...] | 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 | str | The trigger the job fires with. |
job_run_id | str | None | The ID of the created run; None in dry-run mode or when skipped. |
job_run_number | int | None | Number of the run within its job, counting up from 1; numbers repeat across jobs. |
matched_triggers | tuple[str, ...] | Every trigger that selected this job: its default trigger when refs names it, plus any selector matches. |
started | bool | Whether the runtime started a job run. In a dry run, whether it starts one. |
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 | int | Engine version of the deployment manifest that the definitions come from. |
jobs | Sequence[Mapping[str, Any]] | Job definitions, exactly as the deployment manifest carries them. |
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
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. |