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 thepyworkflow command:
Global Options
These options apply to all commands:Configuration
Configuration File
Create apyworkflow.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):pyworkflow.toml.pyworkflow.tomlpyproject.toml(under[tool.pyworkflow]section)
TOML Configuration Examples
TOML Configuration Examples
- pyworkflow.toml
- pyproject.toml
Priority Resolution
Configuration values are resolved in this order (highest to lowest priority):Workflow Discovery
When you runpyworkflow 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
- Module Import: PyWorkflow imports the specified Python module(s)
- Decorator Registration: When the module loads,
@workflowand@stepdecorators automatically register functions in the global registry - 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
- Using Config File (Recommended)
- Using --module Flag
- Using Environment Variable
Multiple Modules
You can discover workflows from multiple modules:- Config File
- Environment Variable
Commands
Workflow Commands
Manage and execute registered workflows.workflows list
List all registered workflows:
table(default): Shows Name, Max Duration, and Metadata columnsjson: Array of workflow objectsplain: Simple list of workflow names
workflows info
Show detailed information about a specific workflow:
Output includes: Name, max duration, function details, module path, and docstring.
workflows run
Execute a workflow with optional arguments:
Options:
- Key-Value Arguments
- JSON Arguments
Run Commands
Monitor and debug workflow runs.runs list
List workflow runs with optional filtering:
Output Formats:
table(default): Shows Run ID, Workflow, Status (color-coded), Started time, and Durationjson: Array of run objects with full detailsplain: Simple list of Run IDs
runs status
Show detailed status of a specific run:
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:
Options:
Event Types:
workflow_started,workflow_completed,workflow_failed,workflow_cancelledstep_started,step_completed,step_failedsleep_started,sleep_resumedhook_created,hook_receivedcancellation_requested
runs cancel
Cancel a running or suspended workflow:
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:
- All Queues (Default)
- Specialized Workers
- Advanced Celery Options
worker status
Show status of active Celery workers:
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:
- Basic Usage
- With Module
- Testing
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:
Output includes: Schedule ID, Workflow, Status, Schedule description, Next Run time, Success rate
schedules create
Create a new schedule for a workflow:
Options:
- Cron Schedule
- Interval Schedule
- With Options
schedules show
Show detailed information about a schedule:
- 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:
schedules delete
Delete a schedule (soft delete):
schedules trigger
Manually trigger a schedule immediately:
schedules update
Update an existing schedule:
schedules backfill
Backfill missed runs for a schedule:
Quickstart Command
Create a new PyWorkflow project with sample workflows.quickstart
Scaffold a complete project structure with working examples:
Examples:
Setup Command
Configure the PyWorkflow environment for an existing project.setup
Interactive setup that generates configuration and Docker files:
Examples:
Output Formats
Control output format with the--output flag:
- Table (Default)
- JSON
- Plain
Examples
Complete Workflow Lifecycle
Debugging Failed Runs
Scripting with JSON Output
Using Config File
With apyworkflow.toml in your project:
Distributed Workflow Execution
Complete example of running workflows on Celery workers: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.