External job runs
New to the SDK? Getting started shows how to connect and use it.
ExternalJobRuns
The runs external runners report in one workspace.
ExternalJobRuns.start()
start(
*,
job_ref: str,
external_id: str,
started_at: datetime,
trigger: str,
dlt_version: str,
refresh: bool = False,
previous_job_run_id: str | None = None,
details: ExternalRunDetails | None = None,
runner_bootstrap_version: int | None = None,
) -> ExternalJobRun
Report that an external runner is about to run an externally controlled job.
Repeating a start with the same external_id answers the run it
recorded, so a retried start is safe.
Arguments
| Name | Type | Description |
|---|---|---|
job_ref | str | The job to run, by its ref. |
external_id | str | The run's id on the external runner, unique per workspace. |
started_at | datetime | When the external runner started the run. |
trigger | str | What fired the run, e.g. manual:<job_ref>. |
dlt_version | str | The dlt version installed where the job runs. |
refresh | bool | Whether to start the run as a refresh. |
previous_job_run_id | str | None | For a follow-up, the run it follows. |
details | ExternalRunDetails | None | What the external runner reports about the run. |
runner_bootstrap_version | int | None | The newest bootstrap version the runner reads, from dlt_runtime.external.runner_bootstrap_version(). |
Returns: ExternalJobRun — The run and its bootstrap; awaitable in async mode. A repeated start for a run that has ended carries no bootstrap.
Raises
| Exception | When |
|---|---|
BadRequest | The job is archived or not externally controlled, the details pass 16 KB, or the runner is too old for dltHub (code is runner_too_old). |
Conflict | The job would not take the run, e.g. it is paused or at its concurrency limit; code says why, and no run is recorded. |
NotAuthorized | Only the owner of the workspace's organization reports external runs. |
NotFound | No job with that ref. |
ServerError | The run could not be started on its data plane. |
ScopeMissing | Reached without a workspace in scope. |
ExternalJobRuns.get()
get(*, id: str) -> ExternalJobRun
Return one external run by id; it never carries a bootstrap.
Arguments
| Name | Type | Description |
|---|---|---|
id | str | The run's uuid. |
Returns: ExternalJobRun — The run; awaitable in async mode.
Raises
| Exception | When |
|---|---|
BadRequest | The id is not a uuid. |
NotFound | No external run with that id in this workspace. |
ScopeMissing | Reached without a workspace in scope. |
ExternalJobRuns.finish()
finish(
*,
id: str,
status: ExternalRunEnd,
finished_at: datetime,
details: ExternalRunDetails | None = None,
) -> ExternalJobRun
Report how an external run ended.
A run that already ended is answered as recorded.
Arguments
| Name | Type | Description |
|---|---|---|
id | str | The run's uuid, as its start answered it. |
status | ExternalRunEnd | How the run ended. |
finished_at | datetime | When the external runner ended the run. |
details | ExternalRunDetails | None | Merged into the start's details; error says why a failed run failed. |
Returns: ExternalJobRun — The ended run; awaitable in async mode.
Raises
| Exception | When |
|---|---|
BadRequest | The run is not external, or the details together pass 16 KB. |
NotAuthorized | Only the owner of the workspace's organization reports external runs. |
NotFound | No such run in this workspace. |
ServerError | The run's end could not be applied. |
ScopeMissing | Reached without a workspace in scope. |
ExternalJobRun
Subclass of JobRun[M].
A run of an externally controlled job, as its external runner reported it.
Only its external runner ends it, with ExternalJobRuns.finish(): dltHub
refuses cancel() for it.
Attributes
| Name | Type | Description |
|---|---|---|
bootstrap | Mapping[str, Any] | None | The document the external runner hands our runner as bootstrap.json, written as is; answered only by ExternalJobRuns.start(), and None once the run has ended. It carries the run's credentials: keep it secret. |
ExternalRunEnd
ExternalRunEnd = Literal[JobRunStatus.COMPLETED, JobRunStatus.FAILED, JobRunStatus.CANCELLED]