boxmot.attributes.spool
PostgreSQL crop scheduling and persistent results for attribute extraction.
AttributeSpool
AttributeSpool(
config: AttributeConfig,
run_id: str,
*,
ownership: CameraLease | None = None,
max_pending_jobs: int = 1000,
max_crop_bytes: int = 256 * 1024 * 1024,
)
Serialize PostgreSQL transactions across one run's caller and worker.
Runs share a schema, but every operation is scoped to this run. Only the active request and requested result pages enter memory. Completed outcomes and latest values remain in PostgreSQL after closing the connection; this does not resume abandoned jobs or attach additional workers to a run.
queue_metrics
property
Return aggregate backlog size and age without loading crop payloads.
stats
property
Return this run's outcome counts and distinct observed/analyzed tracks.
append
append(
generation: int,
track_id: int,
step: int,
sample: AttributeSample,
image: bytes,
) -> None
Persist a sample, coalescing the pending batch without changing its rank.
complete
Atomically retain an outcome and release the completed job's crops.
flush
Release partial batches, recording tracks that never supplied a crop.
latest
latest(
generation: int, track_ids: list[int]
) -> dict[int, AttributeResult]
Read detached snapshots for only this run's current track rows.
observe
observe(
generation: int,
sequence_id: str | None,
track_id: int,
class_id: int,
step: int,
sample: AttributeSample,
) -> int | None
Record a visible identity and return its most recent sampling step.
poll
poll(limit: int) -> list[AttributeResult]
Mark a bounded event page delivered while retaining its history.
retry
Schedule a retry using the database clock without releasing samples.