MODULE REFERENCE
runs
anomx.execution.runsContext-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.
| Parameter | Type | Default |
|---|---|---|
projectkeyword only | str | required |
namekeyword only | str | '' |
configkeyword only | Mapping[str, Any] | None | None |
idkeyword only | str | None | None |
backendkeyword only | RunBackend | None | None |
directorykeyword only | str | Path | '.anomx/runs' |
managedkeyword only | bool | False |
Members
flushmethod
flush() -> NoneRetry the outstanding event, retaining its ID if delivery fails.
Returns None
startmethod
start() -> RunCreate 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) -> NoneLog 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.
| Parameter | Type | Default |
|---|---|---|
name | str | Mapping[str, Any] | required |
value | Any | None |
stepkeyword only | int | None | None |
commitkeyword only | bool | True |
Returns None
finishmethod
finish(*, status: str = 'succeeded', error: str = '') -> NoneFlush pending values and finish a standalone run exactly once.
| Parameter | Type | Default |
|---|---|---|
statuskeyword only | str | 'succeeded' |
errorkeyword only | str | '' |
Returns None
current_run
current_run() -> Run | NoneReturn the run bound to this context, or None.
Returns Run | None
finish
finish(*, status: str = 'succeeded', error: str = '') -> NoneFinish the current standalone execution; a worker owns hosted lifecycles.
| Parameter | Type | Default |
|---|---|---|
statuskeyword only | str | 'succeeded' |
errorkeyword only | str | '' |
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') -> RunStart 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.
| Parameter | Type | Default |
|---|---|---|
projectkeyword only | str | None | None |
namekeyword only | str | '' |
configkeyword only | Mapping[str, Any] | None | None |
idkeyword only | str | None | None |
backendkeyword only | RunBackend | None | None |
directorykeyword only | str | Path | '.anomx/runs' |
Returns Run
log
log(name: str | Mapping[str, Any], value: Any = None, *, step: int | None = None, commit: bool = True) -> NoneWrite values to the active run (see Run.log).
| Parameter | Type | Default |
|---|---|---|
name | str | Mapping[str, Any] | required |
value | Any | None |
stepkeyword only | int | None | None |
commitkeyword only | bool | True |
Returns None
use_run
use_run(run: Run) -> Iterator[Run]Temporarily bind an existing run without changing its lifecycle.
| Parameter | Type | Default |
|---|---|---|
run | Run | required |
Returns Iterator[Run]