Skip to content

kairos.commands.run

kairos.commands.run

kairos run weekly and kairos run validation: pipeline orchestrators.

The pipeline runs six stages in a fixed order::

refresh -> fit -> dials -> governor -> ledger -> export

Each stage lives in another package (data, models, dials, governor, ledger, dashboard). The orchestrator does not import them at module load time. Instead every stage lists one or more entry points (module:function) that are tried in order. The first one that imports wins. If none can be imported the stage is reported as unavailable and the pipeline carries on, so the command works on a partial checkout and picks stages up as they land.

A stage entry point has the signature (ctx: RunContext) -> Mapping | None. What it returns is stored in ctx.artifacts[stage_name] so later stages can read it.

StageStatus

Bases: StrEnum

Outcome of a single stage.

Stage dataclass

One pipeline stage and the entry points that may implement it.

RunContext dataclass

State shared by every stage of one run.

device property

device: str

Device hint for stages: cpu when the run is CPU-only.

StageResult dataclass

What happened to one stage.

to_dict

to_dict() -> dict[str, Any]

Return a JSON-serialisable view.

RunReport dataclass

Summary of a whole run, written as JSON for CI and the ledger.

failed property

failed: bool

Whether any stage failed.

unavailable property

unavailable: tuple[str, ...]

Names of stages with no importable entry point.

to_dict

to_dict() -> dict[str, Any]

Return a JSON-serialisable view.

pipelines

pipelines() -> dict[str, tuple[Stage, ...]]

Return the named pipelines, looked up at call time.

resolve_entry_point

resolve_entry_point(spec: str) -> StageFn | None

Import module:attr and return it, or None if it is missing.

Only a missing module or attribute counts as "unavailable". An import that fails for another reason (a bug in the stage) is re-raised so it is reported as a failure rather than hidden.

run_pipeline

run_pipeline(
    ctx: RunContext,
    stages: Sequence[Stage] = WEEKLY_STAGES,
    *,
    only: Sequence[str] = (),
    skip: Sequence[str] = (),
    keep_going: bool = False,
) -> RunReport

Run stages in order and return a report.

A failed stage stops the run (later stages are skipped) unless keep_going is set. Unavailable stages never stop the run.

build_parser

build_parser() -> argparse.ArgumentParser

Build the kairos run argument parser.

main

main(argv: Sequence[str] | None = None) -> int

Entry point. Exit codes: 0 ok, 1 a stage failed, 2 strict and a stage unavailable.

register

register(root: Typer) -> None

Attach kairos run (arguments are forwarded to :func:main).