Skip to content

capturegraph.scheduling.organize #

Organize - Multi-User Slot Assignment#

Manages per-user notification scheduling to prevent conflicts when multiple users are capturing data for the same target.

The key problem: if multiple users receive the same notification schedule, they'll all capture at the same times, creating redundant data. The AssignmentStore solves this by:

  1. Tracking assignments: Each user gets a unique slot from the candidate pool.
  2. Automatic expiry: Stale assignments are cleaned up after a configurable time.
  3. Capture-aware cleanup: When a new capture arrives, old assignments are discarded.
  4. Drift reconciliation: Rounds stored assignments to nearest candidate slots.
Example
import capturegraph.scheduling as cgsh

# Initialize store with 30-minute expiry
store = cgsh.organize.AssignmentStore(
    persistence=persistence,
    expire_after=timedelta(minutes=30),
    last_capture=sessions[-1].date,
)

# Assign next available slot to a user
next_slot = store.assign_next(user_id, candidate_slots)

# Check existing assignment
existing = store[user_id]

Modules:

Name Description
assignment_store

Assignment Store - Per-User Session Management

batched_distance_store

Batched Distance Store - Distribution-Aware Assignment Management