mixle.pool.core module¶
Pool jobs, results, and backend protocol.
A PoolJob describes a runnable unit of work, its input manifest, the
placement reason, estimated cost, and budget. A Backend executes the
job and returns a PoolResult whose artifact can be used by the
submitter locally.
The included LocalBackend runs jobs in-process and is useful for tests
or systems without a remote pool. Billable backends must require explicit
confirmation, and jobs whose estimated cost exceeds their budget are rejected
before execution.
- 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).