How Prefect Works
Transform Python functions into orchestrated workflows with a single decorator. Your code and data stay in your infrastructure—Prefect manages scheduling, observability, and state.
Step 1
Transform Python functions into flows
Add the @flow decorator to any Python function. No YAML, no complex DSLs—just Python. Your code remains readable and testable while gaining orchestration capabilities.
View quickstart guide1@flow2def say_hello():3 for name in ["Marvin", "Arthur", "Ford"]:4 hello(name)56# Your code stays exactly where it is7# No special runtime or proprietary formats
Step 2
Deploy from your terminal
Deploy workflows from your own infrastructure using the Prefect CLI. You control where code lives and how it runs. Workers execute in your environment with full access to your resources.
Your workers poll our API—no inbound connections to your network
Prefect Cloud's hybrid architecture means your code and data never leave your infrastructure. Workers poll Prefect for scheduled runs, then execute workflows locally with direct access to your databases and services.
- No inbound connectionsYour firewall rules stay locked down
- Data stays localDirect access to your databases
- Metadata onlyLogs and state, never your data
Step 3
Workers execute flows in your environment
When it's time to run, workers in your infrastructure gather code, prepare resources, and execute flows. All execution happens locally—Prefect receives only logs and state updates for observability.
Step 4
Break flows into observable tasks
Decompose complex workflows into independently tracked tasks using the @task decorator. Get granular observability and retry logic for each step without exposing your data—only execution metadata reaches Prefect.
Try Prefect Cloud free1@task(retries=3)2def hello(name: str):3 print(f"Hello, {name}")45@flow6def say_hello():7 # Each task is independently:8 # - Tracked9 # - Retried on failure10 # - Observable in the UI11 for name in ["Marvin", "Arthur", "Ford"]:12 hello(name) # Automatic retry if this fails
Step 5
Automatic state tracking and retries
Prefect manages flow run states and directs automatic retries on failure. Your workflows become resilient without custom error handling. State transitions and logs flow to Prefect—your actual data remains in your infrastructure.
Python-native workflows. Your infrastructure. Managed orchestration.
Start with Prefect Cloud's free tier or install self-hosted—both give you the same Python-first experience with your code and data staying exactly where you need them.