Skip to main content
Version: devel View Markdown

Job runs and logs

New to the SDK? Getting started shows how to connect and use it.

Job runs​

JobRuns​

The runs of one workspace, or of one job within it.

JobRuns.get()​

get(*, id: str) -> JobRun

Return one run by id.

Job runs are addressed by uuid; to find one by number, filter list() with number.

Arguments

NameTypeDescription
idstrThe run's uuid.

Returns: JobRun — The run; awaitable in async mode.

Raises

ExceptionWhen
BadRequestThe request was rejected as invalid; message, code and fields say why.
NotFoundNo such run in this workspace.
ScopeMissingReached without a workspace in scope.

JobRuns.result()​

result(*, id: str) -> JobResult

Read one run's declared result, without reading the run itself.

Arguments

NameTypeDescription
idstrThe run's uuid.

Returns: JobResult — The result; awaitable in async mode.

Raises

ExceptionWhen
BadRequestThe request was rejected as invalid; message, code and fields say why.
NotFoundNo such run, or it declared no result — the platform answers the same either way.
ScopeMissingReached without a workspace in scope.

JobRuns.trace()​

trace(*, id: str) -> JobResultTrace

Read one run's whole result, without reading the run itself.

Arguments

NameTypeDescription
idstrThe run's uuid.

Returns: JobResultTrace — The whole result; awaitable in async mode.

Raises

ExceptionWhen
ApiErrorThe result is too large to serve (code job_result_trace_too_large); result() still reads the summary fields.
BadRequestThe request was rejected as invalid; message, code and fields say why.
NotFoundNo such run, or it declared no result — the platform answers the same either way.
ScopeMissingReached without a workspace in scope.

JobRuns.latest()​

latest(*, job_id: str | None = None) -> JobRun

Return the most recent run.

Arguments

NameTypeDescription
job_idstr | NoneNarrow to one job's runs. Omit to use the job in scope, or the whole workspace when there is none, which leaves out system jobs such as the dashboard.

Returns: JobRun — The newest run; awaitable in async mode.

Raises

ExceptionWhen
BadRequestThe request was rejected as invalid; message, code and fields say why.
NotFoundNothing has run yet.
ScopeMissingReached without a workspace in scope.

JobRuns.count()​

count(*, job_id: str | None = None) -> int

Return how many runs there have been, without fetching them.

Arguments

NameTypeDescription
job_idstr | NoneNarrow to one job's runs. Omit to use the job in scope, or the whole workspace when there is none, which leaves out system jobs such as the dashboard.

Returns: int — The count; awaitable in async mode. Saturates at 10,001.

Raises

ExceptionWhen
BadRequestThe request was rejected as invalid; message, code and fields say why.
ScopeMissingReached without a workspace in scope.

JobRuns.list()​

list(
*,
job_id: str | None = None,
number: int | None = None,
limit: int | None = None,
offset: int = 0,
) -> Iterable[JobRun] | AsyncIterable[JobRun]

Yield runs newest first, paging lazily.

Platform errors are raised when iteration begins, not by this call.

Arguments

NameTypeDescription
job_idstr | NoneNarrow to one job's runs. Omit to use the job in scope, or the whole workspace when there is none, which leaves out system jobs such as the dashboard.
numberint | NoneKeep only the run with this per-job number. Numbers repeat across jobs, so pair it with a job.
limitint | NoneReturn at most this many. None walks to the end, or to row 10,100, past which the platform does not page.
offsetintSkip this many, server-side.

Returns: Iterable[JobRun] | AsyncIterable[JobRun] — An iterable of runs; async-iterable in async mode.

Raises

ExceptionWhen
BadRequestThe request was rejected as invalid; message, code and fields say why.
ScopeMissingReached without a workspace in scope.
ValueErrorA negative limit or offset.

JobRuns.cancel_all()​

cancel_all(*, job_refs: Sequence[str], dry_run: bool = False) -> CancelReport

Stop whatever is running for the named jobs.

Addressed by job, not by run: cancels every pending, starting or running run of the named jobs. A ref that names no job, or has nothing running, is reported in not_running.

Arguments

NameTypeDescription
job_refsSequence[str]The jobs whose runs to stop.
dry_runboolReport what would be cancelled without stopping anything.

Returns: CancelReport — What was cancelled and what was not running; awaitable in async mode.

Raises

ExceptionWhen
ValueErrorNo job refs were given.
ScopeMissingReached without a workspace in scope.

JobRun​

One execution of a job.

Attributes

NameTypeDescription
numberintNumber of the run within its job, counting up from 1; numbers repeat across jobs.
idstrUnique ID (a UUID).
job_refstrCanonical job reference, unique per workspace.
statusJobRunStatusThe status of the run.
triggerstrThe trigger the run fired with, e.g. schedule:0 8 * * *, manual:jobs.my_job, job.success:jobs.upstream.
profilestrThe name of the profile that was used for the run.
started_atdatetime | NoneWhen the run started; None until it has.
finished_atdatetime | NoneWhen the run finished; None until it has.
duration_secondsfloat | NoneDuration of the run in seconds, possibly fractional; None until it has finished.
max_run_time_secondsint | NoneMaximum allowed run duration in seconds for this job version.
interval_startdatetime | NoneStart of the interval the run processes; None for a job without intervals.
interval_enddatetime | NoneEnd of the interval the run processes; None for a job without intervals.
pipeline_run_summariestuple[PipelineRunSummary, ...]One entry per dlt pipeline name the run reported; a pipeline that ran more than once shows its latest report. In no particular order, and empty until telemetry has received the reports.
previous_job_run_idstr | NoneThe upstream run whose completion started this one, through a job.success: / job.fail: trigger or a freshness dependency; None for a run started manually, by its own schedule, or by a trigger request.
created_atdatetimeWhen it was created.
finishedboolWhether the status can still change.
failedboolWhether the run finished without succeeding.

JobRun.cancel()​

cancel() -> JobRun

Ask the platform to stop this run.

The run moves to CANCELLING first, and to CANCELLED once it has stopped.

Returns: JobRun — A fresh snapshot, usually CANCELLING rather than CANCELLED; awaitable in async mode.

Raises

ExceptionWhen
BadRequestThe request was rejected as invalid; message, code and fields say why.
ConflictThe current state does not allow the call, e.g. the workspace is archived; code and message say why.
NotFoundThe run no longer exists.

JobRun.logs()​

logs() -> Iterable[LogLine] | AsyncIterable[LogLine]

Read the run's stored log, oldest line first.

Lines arrive as the body does, so a long log is never held whole. The platform consolidates a run's log after it ends, so this raises until that has happened — stream_logs() is what follows a live run. Platform errors are raised when iteration begins, not by this call.

Returns: Iterable[LogLine] | AsyncIterable[LogLine] — An iterable of log lines; async-iterable in async mode.

Raises

ExceptionWhen
NotFoundThe run has no stored log, either because it does not exist or because it has not been consolidated yet.
ScopeMissingReached without a workspace in scope.

JobRun.stream_logs()​

stream_logs(*, follow: bool = True) -> Iterable[LogLine] | AsyncIterable[LogLine]

Follow the run's log live, until the run reaches a terminal status.

Read from the compute backend rather than from storage, so it works while a run is going and stops on its own when the run ends. The platform waits up to about a minute for a backend that has not started reporting yet. Platform errors are raised when iteration begins, not by this call.

Arguments

NameTypeDescription
followboolKeep reading until the run ends. False replays what the backend has already reported and stops, which the platform marks only by going quiet — so a slow producer can end it early.

Returns: Iterable[LogLine] | AsyncIterable[LogLine] — An iterable of log lines; async-iterable in async mode.

Raises

ExceptionWhen
ApiErrorThe platform could not follow this run — it is unknown or its backend never reported, the backend does not support live logs, or the stream failed part-way. It reports these on an otherwise successful response, so this can be raised after some lines have already been yielded.
ScopeMissingReached without a workspace in scope.

JobRun.wait()​

wait(*, timeout: float | None = None) -> JobRun

Poll until the run stops changing, and return what it ended as.

Settles on any terminal status, so a failed or cancelled run returns rather than raises — read status to find out which. Checks roughly every second at first and backs off to every ten, so a short run is noticed almost at once and a long one is not polled thousands of times.

Arguments

NameTypeDescription
timeoutfloat | NoneGive up after this many seconds. None, the default, waits as long as the run takes.

Returns: JobRun — A snapshot in a terminal status; awaitable in async mode.

Raises

ExceptionWhen
NotFoundThe run no longer exists.
ScopeMissingReached without a workspace in scope.
ValueErrorA negative timeout.
WaitTimeoutThe run was still going when the deadline passed. It is unaffected — nothing cancels it — so this can be retried.

JobRun.result()​

result() -> JobResult

Read the structured result this run declared.

Returns: JobResult — The result; awaitable in async mode.

Raises

ExceptionWhen
NotFoundThe run declared none, which is the normal case for a job that reports no result — not a sign the run is missing.
ScopeMissingReached without a workspace in scope.

JobRun.trace()​

trace() -> JobResultTrace

Read the whole result this run delivered, trace included.

Returns: JobResultTrace — The whole result; awaitable in async mode.

Raises

ExceptionWhen
ApiErrorThe result is too large to serve (code job_result_trace_too_large); result() still reads the summary fields.
NotFoundThe run declared no result, which is the normal case for a job that reports none — not a sign the run is missing.
ScopeMissingReached without a workspace in scope.

CancelledRun​

One run a bulk cancel stopped.

Attributes

NameTypeDescription
job_refstrJob reference of the cancelled run.
job_run_idstrID of the cancelled run.
job_run_numberintNumber of the run within its job; numbers repeat across jobs.
previous_statusJobRunStatusStatus of the run when the cancel request arrived.

CancelReport​

What a bulk cancel did.

Attributes

NameTypeDescription
cancelledtuple[CancelledRun, ...]The runs asked to stop (now cancelling), or that would be in a dry run.
not_runningtuple[str, ...]Job refs that had nothing to stop, which is not an error.

JobResult​

The structured result a run declared.

A run yields at most one, and most do not: a plain pipeline job declares none, where an agent job reports its own outcome here. The agent fields are None for any other kind of result.

Attributes

NameTypeDescription
job_run_idstrJob run that declared the result.
job_refstrThe job that declared the result.
result_typestrjob.{category}.{name}, for example job.background_agent.{name}.
engine_versionintResult format version; 1 when not declared.
resultAnyThe job's declared output. Shape is job-defined.
agent_statusstr | NoneThe agent's self-report, which may legitimately disagree with the run's own status: a failed agent inside a succeeded run is normal.
summarystr | NoneModel-authored markdown, unbounded. Untrusted — render as user content.
modelstr | NoneModel the agent ran with. None when the result carries no agent trace, as for non-agent jobs.
loop_typestr | NoneAgent loop that ran. None when the result carries no agent trace, as for non-agent jobs.
input_tokensint | NoneInput tokens the agent used. None when the result carries no agent trace, as for non-agent jobs.
output_tokensint | NoneOutput tokens the agent used. None when the result carries no agent trace, as for non-agent jobs.
total_tokensint | NoneTotal tokens the agent used. None when the result carries no agent trace, as for non-agent jobs.
cost_usdstr | NoneCost in USD the agent reported, as a decimal string. None when the result carries no agent trace, as for non-agent jobs.
turn_countint | NoneNumber of turns the agent took. None when the result carries no agent trace, as for non-agent jobs.
stop_reasonstr | NoneWhy the agent stopped. None when the result carries no agent trace, as for non-agent jobs.
created_atdatetimeWhen the result was first stored, UTC.
updated_atdatetimeWhen the result was last stored, UTC.

JobResultTrace​

The whole job result a run delivered, as the job sent it.

JobResult carries the summary fields; this carries the whole result as the job delivered it, which is where an agent's per-turn tool calls live.

Attributes

NameTypeDescription
job_run_idstrThe run that declared it.
resultMapping[str, Any]The result exactly as delivered — the declared output and, for an agent, its trace: turns and the tools each called, token counts, stop reason. Left opaque: the platform stores and returns it verbatim and declares no shape for it.

PipelineRunSummary​

One dlt pipeline a run executed, as telemetry reported it.

A run executes whatever pipelines its job calls, so a job that loads two sources reports two. A run carries one entry per dlt pipeline name it reported; a pipeline that ran more than once shows its latest report. Telemetry fills this in after the pipeline reports, so a run that has just started carries none, and a run whose job never reached a pipeline carries none for good.

Attributes

NameTypeDescription
pipeline_namestrName of the dlt pipeline.
pipeline_run_idstr | NoneTelemetry ID of the pipeline run.
transaction_idstr | NoneTransaction ID of the pipeline run.
destination_namestr | NoneName of the destination the pipeline wrote to.
dataset_namestr | NoneName of the dataset the pipeline wrote to.
statusstr | NoneWhat the pipeline run ended as. Free-form: it is dlt's own wording, not JobRunStatus.
total_rowsint | NoneTotal number of rows loaded by the pipeline.
duration_msint | NoneDuration of the pipeline run in milliseconds.
started_atdatetime | NoneWhen the pipeline run started.
finished_atdatetime | NoneWhen the pipeline run finished.

JobRunStatus​

Where a run has got to.

Members

MemberValueDescription
PENDING'pending'Accepted, not yet started.
STARTING'starting'Being placed on a compute backend.
RUNNING'running'Executing.
CANCELLING'cancelling'Cancellation asked for, not yet effective.
COMPLETED'completed'Finished successfully.
FAILED'failed'Finished unsuccessfully.
CANCELLED'cancelled'Stopped on request, or because it exceeded its maximum run time.
SKIPPED'skipped'Recorded without running. A start the platform declines is normally reported through TriggerStatus and creates no run.
UNKNOWN'unknown'A status this SDK version does not know.

Logs​

LogLine​

One line a run emitted.

Attributes

NameTypeDescription
contentstrContents of the log message.
line_numintPosition of the line in the run's log.
sourceLogSourceWho emitted the line.
stageLogStageStage of the run the line belongs to: build (installing dependencies before the job starts) or run (the job's execution).
io_streamLogIoStreamStream the line was written to: stdout, stderr, or other (a provider's info channel, or a line stored before streams were kept).
reported_atdatetimeTimestamp when the log was reported.

LogIoStream​

The stream a log line was written to.

Members

MemberValueDescription
STDOUT'stdout'Standard output.
STDERR'stderr'Standard error.
OTHER'other'Neither: an info channel of the compute backend, or a line stored before the stream was recorded.
UNKNOWN'unknown'A stream this SDK version does not know.

LogSource​

Who emitted a log line.

Members

MemberValueDescription
USER'user'The user's own code.
SETUP'setup'The install and build commands that prepare the run.
RUNNER'runner'The platform's bootstrap around the user's code.
UNKNOWN'unknown'A source this SDK version does not know.

LogStage​

Which stage of the run a log line belongs to.

Members

MemberValueDescription
BUILD'build'Preparing the environment the code runs in.
RUN'run'Executing the code.
UNKNOWN'unknown'A stage 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.