client.swarm.services.scheduler =============================== .. py:module:: client.swarm.services.scheduler .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: client.swarm.services.scheduler.logger Classes ------- .. autoapisummary:: client.swarm.services.scheduler.BatchResult client.swarm.services.scheduler.Scheduler Module Contents --------------- .. py:data:: logger .. py:class:: BatchResult Result of queueing a batch of tasks. .. py:attribute:: task_statuses :type: dict[int, str] .. py:attribute:: batch_size :type: int :value: 0 .. py:attribute:: array_id :type: int :value: 0 .. py:class:: 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. :param gateway: ServerGateway for server communication. :param state: SwarmState containing all task/array state (single source of truth). .. py:attribute:: MAX_BATCH_SIZE :type: int :value: 500 .. py:property:: max_concurrently_running :type: int Workflow-level concurrency limit (delegated to state). .. py:method:: tick(timeout: float = -1) -> jobmon.client.swarm.state.StateUpdate :async: One scheduling iteration: batch tasks, queue them, return state changes. :param timeout: Maximum time to spend scheduling (-1 for unlimited). :returns: StateUpdate containing task status changes from queued batches. .. py:method:: has_work() -> bool Check if there are tasks ready to run with available capacity.