mixle.pool package¶
Pool execution primitives for offloading selected units of work.
The pool API keeps local execution as the default. A job is sent to a backend
only when a planner or caller provides a reason, an estimated cost, and a
budget. The default LocalBackend executes the same protocol in-process,
so workflows can use the pool abstraction before a remote GPU backend exists.
- class PoolJob(run, kind='block', reason='', est_cost=0.0, budget=inf, inputs=<factory>, id=<factory>)[source]
Bases:
objectA runnable unit of work destined for local-or-pool execution, with its reason and budget.
runis any callable returning an artifact (a fitted model, an index, a dataset).est_costis the estimated dollar cost the economics assigned;budgetis the ceiling the submitter set.reasonis the placement justification the planner produced (“8.2 TFLOP gradient residual”).- Parameters:
- kind: str = 'block'
- reason: str = ''
- est_cost: float = 0.0
- budget: float = inf
- id: str
- class PoolResult(job_id, status, artifact=None, cost=0.0, duration_s=0.0, reason='')[source]
Bases:
objectThe outcome of a pool job: the artifact that round-trips home, plus realized cost/timing.
- job_id: str
- status: str
- artifact: Any = None
- cost: float = 0.0
- duration_s: float = 0.0
- reason: str = ''
- property ok: bool
- class Backend(*args, **kwargs)[source]
Bases:
ProtocolExecutes a
PoolJob. Real backends setbillable=Trueand honor the confirm gate.- billable: bool
- submit(job)[source]
- Parameters:
job (PoolJob)
- Return type:
PoolResult
- class LocalBackend(clock=None)[source]
Bases:
objectThe pool degraded to this machine: runs the job in-process, free, no confirm needed.
This is what a user with no remote pool configured gets: the abstraction works end-to-end and every result is a real local artifact.
clockis injectable for deterministic timing in tests.- Parameters:
clock (Callable[[], float] | None)
- billable = False
- submit(job)[source]
- Parameters:
job (PoolJob)
- Return type:
PoolResult
- submit(job, backend=None, *, confirm=False, telemetry=None)[source]
Submit
jobtobackend(defaultLocalBackend), enforcing budget + confirm rails.A job whose
est_costexceeds itsbudgetis REJECTED before running. A BILLABLE backend (a real GPU pool) additionally requiresconfirm=True– spend is never incurred implicitly. Every submission emits apool_jobtelemetry event (features + realized outcome).