api.scripts.base

What every script implements, and what a run returns.

Attributes

Exceptions

RequeueLater

The resource is busy (another run holds its lock): the worker queues the run again.

Classes

ScriptResult

The outcome of a run: details is shown in the app, metrics are numbers (/metrics).

ApiScript

A script. schedule None means on demand only.

Module Contents

api.scripts.base.StageReporter
exception api.scripts.base.RequeueLater(reason: str, countdown_seconds: float = 5.0)

Bases: Exception

The resource is busy (another run holds its lock): the worker queues the run again.

reason
countdown_seconds = 5.0
class api.scripts.base.ScriptResult

The outcome of a run: details is shown in the app, metrics are numbers (/metrics).

status: str
details: dict[str, Any]
metrics: dict[str, float]
duration_seconds: float = 0.0
finished_at: str
as_dict() → dict[str, Any]
class api.scripts.base.ApiScript

Bases: Protocol

A script. schedule None means on demand only.

run receives the snapshot its previous run returned (None the first time) and returns its result and the snapshot to keep (None keeps the previous one).

name: str
schedule: celery.schedules.BaseSchedule | None
is_configured() → bool

False skips the run (missing settings).

run(previous_snapshot: dict[str, Any] | None = None, report_stage: StageReporter = lambda stage: ..., **kwargs: Any) → tuple[ScriptResult, dict[str, Any] | None]