Skip to main content
Version: devel View Markdown

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

NameTypeDescription
refsSequence[str] | NoneJob refs to run. Each resolves to exactly one job.
selectorsSequence[str] | NoneTrigger patterns to match, fnmatch-style, for example "tag:backfill", "schedule:*", "manual:jobs.mod.*".
profilestr | None | KeepDeprecated. 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.
refreshboolWhether 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_runboolWhether 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

ExceptionWhen
ConflictThe current state does not allow the call, for example an archived workspace. code and message say why.
NotAuthorizedThe caller lacks the access that this call needs. message says why.
NotFoundA ref names no job in this workspace, or only an archived one.
ScopeMissingNo workspace in scope.
ValueErrorNeither 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

NameTypeDescription
manifestDeployManifestThe deployment manifest to deploy, as dlt built it. Its jobs and engine version go together, so the two always match.
manifest_hashstrContent hash of that deployment manifest, from dlt's generate_manifest_hash.
deployment_modulestr | NoneThe 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.
descriptionstr | None | KeepWorkspace description, applied only when deployment_module is "__deployment__". None and the default leave it as it is.
dry_runboolWhether 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

ExceptionWhen
BadRequestThe runtime rejected the request as invalid. message, code and fields say why.
ConflictThe current state does not allow the call, for example an archived workspace. code and message say why.
NotAuthorizedThe caller lacks the access that this call needs. message says why.
ScopeMissingNo workspace in scope.
ValueErrorThe deployment manifest lists no jobs.

Jobs.get()​

get(*, id: str) -> Job

Return one job by ID.

Arguments

NameTypeDescription
idstrThe UUID of the job. get_by_ref() finds a job by its ref.

Returns: Job — The job. Async mode returns an awaitable.

Raises

ExceptionWhen
BadRequestThe runtime rejected the request as invalid. message, code and fields say why.
NotFoundThe job does not exist in this workspace.
ScopeMissingNo workspace in scope.

Jobs.get_by_ref()​

get_by_ref(ref: str) -> Job

Return one job by its ref, archived or not.

Arguments

NameTypeDescription
refstrThe job ref, for example jobs.load.

Returns: Job — The job. Async mode returns an awaitable.

Raises

ExceptionWhen
NotFoundNo job in this workspace has that ref.
ScopeMissingNo workspace in scope.

Jobs.count()​

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

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

Arguments

NameTypeDescription
archivedbool | KeepAs 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

ExceptionWhen
ScopeMissingNo 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

NameTypeDescription
archivedbool | KeepTrue lists only archived jobs, and False only live jobs. KEEP, the default, lists both.
limitint | NoneThe most jobs to return. None returns every job up to item 10,100, where the runtime stops paging.
offsetintThe number of jobs that the runtime skips first.

Returns: Iterable[Job] | AsyncIterable[Job] — An iterable of jobs. Async mode returns an async iterable.

Raises

ExceptionWhen
ScopeMissingNo workspace in scope.
ValueErrorA negative limit or offset.

Job​

A deployed job in a workspace.

Collections

NameTypeExampleDescription
job.runsJobRunsjob.runs.list()The job runs of this job.

Attributes

NameTypeDescription
job_refstrCanonical job reference, unique per workspace.
idstrUnique ID (a UUID).
namestr | NoneDisplay name for the job.
job_typeJobTypeThe type of the job: batch, interactive, or stream.
profilestrThe profile the job runs under.
is_pausedboolWhether 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_archivedboolWhether the job is archived. Archived jobs cannot be run and their public URL stops working.
versionintVersion 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_urlstr | NoneThe 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_urlstr | NoneThe URL of the job in the web app for an interactive job; None otherwise.
default_triggerstr | NoneThe trigger fired when a run is started without naming one, computed from the job definition.
triggerstuple[str, ...]Every trigger the job answers to, computed from its definition; selectors match against these.
next_scheduled_run_atdatetime | NoneWhen the job is next scheduled to run; None if it has no schedule.
job_definitionMapping[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_atdatetimeWhen 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

ExceptionWhen
BadRequestThe runtime rejected the request as invalid. message, code and fields say why.
ConflictThe current state does not allow the call, for example an archived workspace. code and message say why.
NotFoundThe 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

ExceptionWhen
ConflictThe current state does not allow the call, for example an archived workspace. code and message say why.
NotFoundThe 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

ExceptionWhen
ConflictThe current state does not allow the call, for example an archived workspace. code and message say why.
NotFoundThe 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

ExceptionWhen
ConflictThe current state does not allow the call, for example an archived workspace. code and message say why.
NotFoundThe 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

ExceptionWhen
ConflictThe current state does not allow the call, for example an archived workspace. code and message say why.
NotFoundThe 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

ExceptionWhen
ConflictThe current state does not allow the call, for example an archived workspace. code and message say why.
NotFoundThe 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

NameTypeDescription
triggerstrThe 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.
profilestr | None | KeepDeprecated. A job runs under its own profile. The runtime accepts only its name and refuses any other value with BadRequest.
refreshboolWhether 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_freshnessboolWhether 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

ExceptionWhen
BadRequestThe runtime rejected the request as invalid, for example for an archived job. message, code and fields say why.
ConflictThe 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.
NotAuthorizedThe 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.
NotFoundThe job does not exist in this workspace.
ScopeMissingNo workspace in scope.

DeployReport​

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

Attributes

NameTypeDescription
addedtuple[Job, ...]Jobs that the deployment manifest introduced.
updatedtuple[Job, ...]Jobs it changed, at their new version.
unchangedtuple[Job, ...]Jobs it did not change.
archivedtuple[Job, ...]Jobs it archived, which happens only for a module deploy.
warningstuple[str, ...]Always empty at present.
deployment_modulestr | NoneThe 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

NameTypeDescription
job_refstrThe job reference of the matched job.
job_idstrThe ID of the matched job.
statusTriggerStatusWhether a job run started, or why it did not.
reasonstuple[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.
triggerstrThe trigger the job fires with.
job_run_idstr | NoneThe ID of the created run; None in dry-run mode or when skipped.
job_run_numberint | NoneNumber of the run within its job, counting up from 1; numbers repeat across jobs.
matched_triggerstuple[str, ...]Every trigger that selected this job: its default trigger when refs names it, plus any selector matches.
startedboolWhether 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

NameTypeDescription
engine_versionintEngine version of the deployment manifest that the definitions come from.
jobsSequence[Mapping[str, Any]]Job definitions, exactly as the deployment manifest carries them.

JobType​

How a job runs.

Members

MemberValueDescription
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

MemberValueDescription
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.

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.