client.swarm.services.scheduler

Scheduler: Task batching and queueing for workflow runs.

This service manages the scheduling of tasks, including batching tasks with compatible resources and queueing them to the server.

Attributes

logger

Classes

BatchResult

Result of queueing a batch of tasks.

Scheduler

Generates and executes task queue commands.

Module Contents

client.swarm.services.scheduler.logger
class client.swarm.services.scheduler.BatchResult

Result of queueing a batch of tasks.

task_statuses: dict[int, str]
batch_size: int = 0
array_id: int = 0
class client.swarm.services.scheduler.Scheduler(gateway: jobmon.client.swarm.gateway.ServerGateway, state: jobmon.client.swarm.state.SwarmState)

Generates and executes task queue commands.

The Scheduler is responsible for: - Batching tasks with compatible resources - Respecting workflow and array concurrency limits - Queueing batches to the server - Returning state updates from queue responses

Usage:

scheduler = Scheduler(gateway=gateway, state=state)

# Single scheduling tick update = await scheduler.tick(timeout=30.0) state.apply_update(update)

Initialize the scheduler.

Parameters:
  • gateway – ServerGateway for server communication.

  • state – SwarmState containing all task/array state (single source of truth).

MAX_BATCH_SIZE: int = 500
property max_concurrently_running: int

Workflow-level concurrency limit (delegated to state).

async tick(timeout: float = -1) jobmon.client.swarm.state.StateUpdate

One scheduling iteration: batch tasks, queue them, return state changes.

Parameters:

timeout – Maximum time to spend scheduling (-1 for unlimited).

Returns:

StateUpdate containing task status changes from queued batches.

has_work() bool

Check if there are tasks ready to run with available capacity.