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 guide
1
@flow
2def say_hello():
3 for name in ["Marvin", "Arthur", "Ford"]:
4 hello(name)
5
6# Your code stays exactly where it is
7# 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.

Ready to deploy...

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.

Prefect Server
Your Network
Control Plane
Metadata
Workers
Data

No inbound connections

Your firewall rules stay locked down

Data stays local

Direct access to your databases

Metadata only

Logs 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.

Flow Execution Logs
Waiting for flow execution...

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 free
1@task(retries=3)
2def hello(name: str):
3 print(f"Hello, {name}")
4
5@flow
6def say_hello():
7 # Each task is independently:
8 # - Tracked
9 # - Retried on failure
10 # - Observable in the UI
11 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.

Flow Run State
Run 1
Pending
Running
Failed
Retry 1
Retrying
Running
Failed
Retry 2
Retrying
Running
Completed

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.

How Prefect Works | Python Workflow Orchestration