Prefect is a modern Python workflow orchestration framework designed to turn any Python function into a reliable, observable data pipeline. Unlike legacy orchestrators that require complex YAML DAG specifications, Prefect uses native Python decorators (@flow, @task) to add orchestration capabilities while keeping code testable and intuitive. The framework embraces dynamic, event-driven workflows where tasks map over runtime data, flows pause for human approval, and automations trigger on custom events — all without forcing your logic into rigid graph structures. Prefect's hybrid execution model (client-side task orchestration with server-side tracking) means flows run anywhere — a laptop, Docker container, Kubernetes pod, or cloud function — with full observability into every state transition, retry, and cache hit.
What This Cheat Sheet Covers
This topic spans 16 focused tables and 110 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Core Decorators and Flow Definition
| Decorator | Example | Description |
|---|---|---|
@flow(name="etl_pipeline")def etl(): ... | Wraps a Python function as an orchestrated workflow; creates a flow run when called with full state tracking and observability. | |
@task(retries=3)def extract(): ... | Wraps a function as a discrete unit of work within a flow; task runs are client-side, can be retried and cached individually. | |
@flowdef my_flow(param: int): ... | Defines typed inputs to a flow; validated at runtime, visible in the UI, and can be overridden per deployment. | |
@taskdef process(data: list): ... | Standard function arguments passed to tasks; serialized for caching and logging, used in cache key computation. |