Python-native workflow orchestration · @flow / @task · deployments · work pools · verified against Prefect 3.x (2026)

Prefect cheat sheet

Prefect turns ordinary Python into observable, retriable, scheduled workflows — no DAG class. Decorate a function with @flow and helpers with @task, run it like normal code, and Prefect tracks every run, its state, logs, and results. Go from script to production with flow.serve() or a deployment on a work pool that provisions infra (Docker/Kubernetes/serverless) per run. A UI (self-hosted server or Prefect Cloud) gives observability, scheduling, retries, and alerting. Targets Prefect 3.x, Python 3.9+.

flows & tasks control & state deployments work pools & infra config & ecosystem gotcha most common

Verified 2026-08-31 against the official docs at docs.prefect.io (Prefect 3.x; Python 3.9+). Prefect 3 is a rewrite of Prefect 2 — flows/tasks are the same idea, but the runtime, transactions & results are new. A companion to Airflow 3 & Dagster in this collection.

Outline

Write a @flow calling @tasks; add retries/caching; then serve() or deploy it to a work pool for scheduled, remote runs with full observability.

Flows & tasks

  1. 1Install & first flow
  2. 2Tasks & futures
  3. 3Retries, caching & logging

Control & state

  1. 4States & results
  2. 5Concurrency & subflows

Deploying

  1. 6serve() & schedules
  2. 7Deployments
  3. 8Work pools & workers

Config & ecosystem

  1. 9Blocks & variables
  2. 10Automations & artifacts
  3. 11CLI & server
  4. 12Ecosystem

Flows & Tasks

Two decorators turn plain Python into tracked, retriable workflows.

1Install & first flow@flow
2Tasks & futures@task
3Retries, caching & loggingresilience

Control & State

Every run has a state; results persist; concurrency is built in.

4States & resultsobservability
5Concurrency & subflowsparallel & compose

Deploying

From a local script to scheduled, remote runs with infrastructure per run.

6serve() & schedulesthe easy path
7Deploymentsremote runs
8Work pools & workersinfra per run

Config & Ecosystem

Store connections/secrets, react to events, and see where Prefect fits.

9Blocks & variablesconfig & secrets
10Automations & artifactsreact & report
11CLI & serveroperate it
12Ecosystemwhere it fits

Worth memorizing

@flow / @taskplain Python, no DAG class
call flow() normallycreates a tracked flow run
task.submit() / .map()concurrent futures / fan-out
retries= / retry_delay_seconds=resilience for free
cache_policy=skip unchanged expensive tasks
return_state=Trueinspect success/failure + result
flow.serve(cron=)easiest scheduled production
flow.deploy(work_pool_name=)remote runs / prefect.yaml
work pool + workerinfra per run; no worker = stuck
Blocks / Variablessaved creds & config
Automationson-failure Slack/email, event-driven
get_run_logger()logs attached to the run in the UI