MODULE REFERENCE

runs

anomx.execution.runs

Context-local runs with monotonic steps and retryable event delivery.

Run

Run(*, project: str, name: str = '', config: Mapping[str, Any] | None = None, id: str | None = None, backend: RunBackend | None = None, directory: str | Path = '.anomx/runs', managed: bool = False)

One execution in a project, with a step-indexed history and summary.

Prefer init for user code. managed=True binds a run whose lifecycle belongs to a worker: entering/exiting does not start or finish it. step=None events let a shared backend allocate steps atomically, useful when several processes log to the same hosted execution.

A failed write remains pending with its original event ID. Call flush before retrying application work; logging another event first also retries the pending write. Never silently discard telemetry on transport failure.

Signature parameters
ParameterTypeDefault
projectkeyword onlystrrequired
namekeyword onlystr''
configkeyword onlyMapping[str, Any] | NoneNone
idkeyword onlystr | NoneNone
backendkeyword onlyRunBackend | NoneNone
directorykeyword onlystr | Path'.anomx/runs'
managedkeyword onlyboolFalse

Members

flushmethod
flush() -> None

Retry the outstanding event, retaining its ID if delivery fails.

Returns None

startmethod
start() -> Run

Create this run once, retrying an unacknowledged start if necessary.

Returns Run

logmethod
log(name: str | Mapping[str, Any], value: Any = None, *, step: int | None = None, commit: bool = True) -> None

Log JSON values at a monotonic step; numeric values become metrics.

Each committed call advances one step. commit=False combines values at the current step; pass an explicit step consistently while building it. Non-finite numbers, empty keys, and decreasing steps are rejected.

Signature parameters
ParameterTypeDefault
namestr | Mapping[str, Any]required
valueAnyNone
stepkeyword onlyint | NoneNone
commitkeyword onlyboolTrue

Returns None

finishmethod
finish(*, status: str = 'succeeded', error: str = '') -> None

Flush pending values and finish a standalone run exactly once.

Signature parameters
ParameterTypeDefault
statuskeyword onlystr'succeeded'
errorkeyword onlystr''

Returns None

current_run

current_run() -> Run | None

Return the run bound to this context, or None.

Returns Run | None

finish

finish(*, status: str = 'succeeded', error: str = '') -> None

Finish the current standalone execution; a worker owns hosted lifecycles.

Signature parameters
ParameterTypeDefault
statuskeyword onlystr'succeeded'
errorkeyword onlystr''

Returns None

init

init(*, project: str | None = None, name: str = '', config: Mapping[str, Any] | None = None, id: str | None = None, backend: RunBackend | None = None, directory: str | Path = '.anomx/runs') -> Run

Start and bind a standalone run, or reuse the active hosted execution.

A standalone call requires project. Inside a job, omit it to use the job's project; overriding the project of a managed execution is an error.

Signature parameters
ParameterTypeDefault
projectkeyword onlystr | NoneNone
namekeyword onlystr''
configkeyword onlyMapping[str, Any] | NoneNone
idkeyword onlystr | NoneNone
backendkeyword onlyRunBackend | NoneNone
directorykeyword onlystr | Path'.anomx/runs'

Returns Run

log

log(name: str | Mapping[str, Any], value: Any = None, *, step: int | None = None, commit: bool = True) -> None

Write values to the active run (see Run.log).

Signature parameters
ParameterTypeDefault
namestr | Mapping[str, Any]required
valueAnyNone
stepkeyword onlyint | NoneNone
commitkeyword onlyboolTrue

Returns None

use_run

use_run(run: Run) -> Iterator[Run]

Temporarily bind an existing run without changing its lifecycle.

Signature parameters
ParameterTypeDefault
runRunrequired

Returns Iterator[Run]