Skip to main content

Overview

PyWorkflow includes a powerful CLI for managing workflows and monitoring runs directly from your terminal. The CLI provides commands to list, inspect, and execute workflows, as well as monitor their execution status and event logs.

Quickstart

Create a new project with sample workflows in seconds.

Workflow Management

List, inspect, and run workflows from the command line.

Run Monitoring

Check run status, view event logs, and debug executions.

Schedule Management

Create, manage, and monitor automated workflow schedules.

Scheduler

Run the local scheduler for triggering due schedules.

Worker Management

Start and manage Celery workers for distributed execution.

Installation

The CLI is included with PyWorkflow and available as the pyworkflow command:

Global Options

These options apply to all commands:

Configuration

Configuration File

Create a pyworkflow.config.yaml file in your project directory:
The YAML config file is the recommended approach. Place it in your working directory and both the CLI and your Python code will automatically use it.

Alternative Config Formats

PyWorkflow also supports TOML configuration files (searched in order, walking up the directory tree):
  1. pyworkflow.toml
  2. .pyworkflow.toml
  3. pyproject.toml (under [tool.pyworkflow] section)

Priority Resolution

Configuration values are resolved in this order (highest to lowest priority):

Workflow Discovery

When you run pyworkflow worker run or other CLI commands, PyWorkflow needs to discover and import your workflow modules. This happens in the following priority order:

Discovery Priority

How Discovery Works

  1. Module Import: PyWorkflow imports the specified Python module(s)
  2. Decorator Registration: When the module loads, @workflow and @step decorators automatically register functions in the global registry
  3. Project Root Detection: PyWorkflow automatically finds your project root (by looking for pyproject.toml, setup.py, or .git) and adds it to the Python path

Multiple Modules

You can discover workflows from multiple modules:

Commands

Workflow Commands

Manage and execute registered workflows.

workflows list

List all registered workflows:
Output Formats:
  • table (default): Shows Name, Max Duration, and Metadata columns
  • json: Array of workflow objects
  • plain: Simple list of workflow names

workflows info

Show detailed information about a specific workflow:
Arguments: Output includes: Name, max duration, function details, module path, and docstring.

workflows run

Execute a workflow with optional arguments:
Arguments: Options:
Use --no-durable for quick, transient executions that don’t need persistence. Use --idempotency-key to prevent duplicate executions.

Run Commands

Monitor and debug workflow runs.

runs list

List workflow runs with optional filtering:
Options: Output Formats:
  • table (default): Shows Run ID, Workflow, Status (color-coded), Started time, and Duration
  • json: Array of run objects with full details
  • plain: Simple list of Run IDs

runs status

Show detailed status of a specific run:
Arguments: Output includes:
  • Run ID, Workflow name, Status
  • Created, Started, Completed timestamps
  • Duration
  • Input arguments
  • Result (if completed)
  • Error message (if failed)

runs logs

View the execution event log for a run:
Arguments: Options: Event Types:
  • workflow_started, workflow_completed, workflow_failed, workflow_cancelled
  • step_started, step_completed, step_failed
  • sleep_started, sleep_resumed
  • hook_created, hook_received
  • cancellation_requested

runs cancel

Cancel a running or suspended workflow:
Arguments: Options: Examples:
Cancellation is graceful - the workflow will stop at the next checkpoint (before a step, sleep, or hook), not immediately. See Cancellation for details.

Worker Commands

Manage Celery workers for distributed workflow execution.

worker run

Start a Celery worker to process workflow tasks:
Options:
For production, run separate workers for each queue type. Scale step workers horizontally for computation-heavy workloads.

worker status

Show status of active Celery workers:
Displays worker names, status, concurrency, active tasks, and processed task counts.

worker queues

Show available task queues and their configuration:

Scheduler Commands

Run the schedule executor for local runtime.

scheduler run

Start the local scheduler that polls for due schedules:
Options:
Use scheduler run for local runtime. For Celery runtime, use worker run --beat or start Celery Beat separately.

Schedule Commands

Manage workflow schedules for automated execution.

schedules list

List all schedules with optional filtering:
Options: Output includes: Schedule ID, Workflow, Status, Schedule description, Next Run time, Success rate

schedules create

Create a new schedule for a workflow:
Arguments: Options:

schedules show

Show detailed information about a schedule:
Output includes:
  • Schedule ID, Workflow name, Status
  • Schedule specification (cron/interval)
  • Overlap policy, Timezone
  • Next run time, Last run time
  • Statistics: Total runs, Successful, Failed, Skipped

schedules pause

Pause a schedule (stops triggering new runs):

schedules resume

Resume a paused schedule:
Output includes: New next run time after resumption

schedules delete

Delete a schedule (soft delete):
Options:

schedules trigger

Manually trigger a schedule immediately:
This executes the workflow immediately without affecting the regular schedule timing.

schedules update

Update an existing schedule:
Options:

schedules backfill

Backfill missed runs for a schedule:
Options:
Backfill creates runs for all scheduled times in the range. For high-frequency schedules, this could create many runs.

Quickstart Command

Create a new PyWorkflow project with sample workflows.

quickstart

Scaffold a complete project structure with working examples:
Options: Examples:
Created Files:
Use pyworkflow quickstart to bootstrap a new project, then modify the sample workflows or add your own in the workflows/ directory.

Setup Command

Configure the PyWorkflow environment for an existing project.

setup

Interactive setup that generates configuration and Docker files:
Options: Examples:

Output Formats

Control output format with the --output flag:
Use --output json for scripting and automation. Use --output plain for simple lists suitable for piping to other commands.

Examples

Complete Workflow Lifecycle

Debugging Failed Runs

Scripting with JSON Output

Using Config File

With a pyworkflow.toml in your project:
Commands become simpler:

Distributed Workflow Execution

Complete example of running workflows on Celery workers:
Use --runtime local to run workflows in-process without Celery for testing or simple scripts.

Next Steps

Quick Start

Get started with PyWorkflow basics.

Workflows

Learn about workflow concepts and patterns.

Events

Understand event sourcing and replay.

Deployment

Deploy workflows to production.