Skip to main content

Installation

Install PyWorkflow using pip:

Create a New Project

The fastest way to get started is with the quickstart command:
This interactive command will:
  1. Create a workflows/ directory with sample workflows
  2. Generate pyworkflow.config.yaml configuration
  3. Optionally start Docker services (Redis + Dashboard)

Non-Interactive Mode

For CI/CD or scripting, use non-interactive mode:

Manual Setup

If you prefer to set up manually or need more control:

Your First Workflow

Create a simple onboarding workflow that sends emails with delays:

What Happens Under the Hood

1

Workflow Starts

Your workflow is dispatched to an available Celery worker.
2

Welcome Email Sent

The send_welcome_email step executes and the result is recorded.
3

Workflow Suspends

When sleep("1d") is called, the workflow suspends and the worker is freed. Zero resources are consumed during the sleep period.
4

Automatic Resumption

After 1 day, Celery Beat automatically schedules the workflow to resume.
5

Tips Email Sent

The workflow picks up where it left off, sending the tips email.
6

Workflow Completes

The final result is recorded and the workflow is marked as complete.

Key Concepts

Workflows

Top-level orchestration functions that coordinate steps and handle business logic.

Steps

Isolated, retryable units of work that run on Celery workers.

Sleep

Pause workflows for any duration without consuming resources.

Events

Event sourcing provides durability and deterministic replay.

Adding Error Handling

Make your workflows fault-tolerant with automatic retries:
Use RetryableError for transient failures (network issues, timeouts) and FatalError for permanent failures (invalid input, business rule violations).

Running in Parallel

Execute multiple steps concurrently using asyncio.gather():

Next Steps

Core Concepts

Learn about workflows, steps, and event sourcing in depth.

Error Handling

Build fault-tolerant workflows with retry strategies.

Testing

Write unit and integration tests for your workflows.

Deployment

Deploy to production with Docker and Kubernetes.