Skip to content

runlog

etl_craft.engine.runlog

Read run identities, task summaries, dependency state and SLA results.

Lifecycle writes belong to engine.transitions. Tasks receive a selected pipeline run; execution attempts keep separate immutable outcomes under each task summary.

RunSelector dataclass

An explicit run id or pipeline-scoped key, or the single non-terminal run.

__post_init__

__post_init__() -> None

Refuse conflicting or empty identities before looking at any run.

RunIdentity dataclass

A run's identity and logical date, independent of when it started.

RunKind dataclass

The date a run runs as of, and whether it is part of a backfill.

TaskRunBinding dataclass

A task's row under a run: its id, its status, and whether this call created it.

TaskRunResult dataclass

A task run's status, error message and attempt count, read back after it ran.

SlaResult dataclass

How a finished run measured against its pipeline's SLA_IN_HOURS.

describe

describe() -> str

Return one line for an outcome message or an alert.

RunEnding dataclass

Whether finalize_pipeline_run ended the run, and its SLA as recorded.

RunSla dataclass

When a run started, and the SLA status recorded for it so far.

fetch_active_pipeline_run_id

fetch_active_pipeline_run_id(conn: Connection, pipeline_id: int) -> int | None

Return the IN-PROGRESS run of pipeline_id, or None.

today

today(zone: str = 'UTC') -> date

Return today in the supplied project timezone; audit timestamps remain UTC.

run_candidates

run_candidates(conn: Connection, pipeline_id: int) -> list[RunIdentity]

List runs of this pipeline by id, for selection and actionable refusals.

select_run

select_run(conn: Connection, pipeline_id: int, selector: RunSelector = ACTIVE_RUN) -> RunIdentity

Select exactly one run; never select an ended run without an explicit identity.

fetch_run_kind

fetch_run_kind(conn: Connection, pipeline_run_id: int) -> RunKind

Return the run date and backfill flag of pipeline_run_id, which must exist.

as_date

as_date(value: object) -> date

Read a DATE column: a date from PostgreSQL, YYYY-MM-DD text from SQLite.

fetch_task_run_result

fetch_task_run_result(conn: Connection, task_run_id: int) -> TaskRunResult

Return the current status of task_run_id; a crashed task is still IN-PROGRESS.

fetch_task_run_status

fetch_task_run_status(conn: Connection, task_id: int, pipeline_run_id: int) -> str | None

Return the status of task_id under pipeline_run_id, or None if it has no row.

fetch_pipeline_run_status

fetch_pipeline_run_status(conn: Connection, pipeline_run_id: int) -> str

Return the status of pipeline_run_id, which must exist.

fetch_run_state

fetch_run_state(conn: Connection, pipeline_run_id: int, task_ids: Sequence[int]) -> dict[int, TaskRunState]

Return the state of each of task_ids under the run, as the dependency graph reads it.

A task with no row is left out: it has not run.

elapsed_hours

elapsed_hours(start: datetime, now: datetime) -> float

Return the hours from start to now, reading a naive start as UTC.

fetch_run_sla

fetch_run_sla(conn: Connection, pipeline_run_id: int) -> RunSla

Return when pipeline_run_id started and its SLA status so far.