client.swarm.run

Factory functions for running workflow runs.

This module provides the primary entry points for executing workflows: - run_workflow(): Execute a workflow from an in-memory Workflow object - resume_workflow_run(): Resume a workflow from database state

These are the main public API for the swarm package.

Attributes

logger

Functions

run_workflow(...)

Execute a workflow run.

resume_workflow_run(...)

Resume a workflow run from database state.

Module Contents

client.swarm.run.logger
client.swarm.run.run_workflow(workflow: jobmon.client.workflow.Workflow, workflow_run_id: int, distributor_alive: Callable[Ellipsis, bool], status: str = WorkflowRunStatus.BOUND, config: jobmon.client.swarm.orchestrator.WorkflowRunConfig | None = None, timeout: int = 36000, requester: jobmon.core.requester.Requester | None = None) jobmon.client.swarm.orchestrator.OrchestratorResult

Execute a workflow run.

This is the primary entry point for running workflows. It: 1. Builds the swarm state from the workflow 2. Runs the orchestrator to completion 3. Returns complete execution results

This function handles being called from both synchronous code and from within an already-running event loop (e.g., Jupyter notebooks, IPython).

Parameters:
  • workflow – The Workflow object to execute.

  • workflow_run_id – The workflow run ID (from WorkflowRunFactory).

  • distributor_alive – Callable that returns True while distributor is alive.

  • status – Initial workflow run status (default: BOUND).

  • config – Optional WorkflowRunConfig. Uses defaults if not provided.

  • timeout – Maximum execution time in seconds.

  • requester – Optional requester for server communication.

Returns:

OrchestratorResult with complete execution results.

Raises:
client.swarm.run.resume_workflow_run(workflow_id: int, workflow_run_id: int, distributor_alive: Callable[Ellipsis, bool], status: str = WorkflowRunStatus.BOUND, config: jobmon.client.swarm.orchestrator.WorkflowRunConfig | None = None, timeout: int = 36000, requester: jobmon.core.requester.Requester | None = None) jobmon.client.swarm.orchestrator.OrchestratorResult

Resume a workflow run from database state.

Used for resume scenarios where we need to reconstruct the workflow state from the database and continue execution.

This function handles being called from both synchronous code and from within an already-running event loop (e.g., Jupyter notebooks, IPython).

Parameters:
  • workflow_id – The workflow to resume.

  • workflow_run_id – The new workflow run ID.

  • distributor_alive – Callable that returns True while distributor is alive.

  • status – Initial workflow run status (default: BOUND).

  • config – Optional WorkflowRunConfig. Uses defaults if not provided.

  • timeout – Maximum execution time in seconds.

  • requester – Optional requester for server communication.

Returns:

OrchestratorResult with complete execution results.

Raises: