api.scripts.base ================ .. py:module:: api.scripts.base .. autoapi-nested-parse:: What every script implements, and what a run returns. Attributes ---------- .. autoapisummary:: api.scripts.base.StageReporter Exceptions ---------- .. autoapisummary:: api.scripts.base.RequeueLater Classes ------- .. autoapisummary:: api.scripts.base.ScriptResult api.scripts.base.ApiScript Module Contents --------------- .. py:data:: StageReporter .. py:exception:: RequeueLater(reason: str, countdown_seconds: float = 5.0) Bases: :py:obj:`Exception` The resource is busy (another run holds its lock): the worker queues the run again. .. py:attribute:: reason .. py:attribute:: countdown_seconds :value: 5.0 .. py:class:: ScriptResult The outcome of a run: `details` is shown in the app, `metrics` are numbers (/metrics). .. py:attribute:: status :type: str .. py:attribute:: details :type: dict[str, Any] .. py:attribute:: metrics :type: dict[str, float] .. py:attribute:: duration_seconds :type: float :value: 0.0 .. py:attribute:: finished_at :type: str .. py:method:: as_dict() -> dict[str, Any] .. py:class:: ApiScript Bases: :py:obj:`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). .. py:attribute:: name :type: str .. py:attribute:: schedule :type: celery.schedules.BaseSchedule | None .. py:method:: is_configured() -> bool False skips the run (missing settings). .. py:method:: run(previous_snapshot: dict[str, Any] | None = None, report_stage: StageReporter = lambda stage: None, **kwargs: Any) -> tuple[ScriptResult, dict[str, Any] | None]