# Prefect

> A Python tool to run pipelines. Plain functions become flows that are tracked and retried.

**Field:** Data Engineering  
**Category:** Orchestration  
**Also known as:** Prefect Flow, Prefect Cloud

## Think of it like

It is like putting stickers on your homework. Each sticker makes a page a step that gets checked.

## Definition

Prefect is an open source orchestrator for Python. You add a flow decorator to a normal function, and a task decorator to its steps. Prefect then tracks each run, retries failed steps and logs what happened. Flows can branch and loop like any Python code, so they need no fixed graph. You can run them on a schedule or by an event. A paid cloud version runs the control side for you.

## Example

Emma already has a Python script that pulls prices. She adds two decorators, and it now runs every hour with retries and a log page.

## Example code

```python
from prefect import flow, task

@task(retries=3, retry_delay_seconds=60)
def fetch_orders():
    ...

@flow
def nightly_load():
    orders = fetch_orders()
```

Two lines turn plain Python into a Prefect flow. Its task gets three more tries.

## Why it matters

It asks for few changes to code you already have. That makes it a quick way to add retries and tracking to scripts.

## Common mistake

Expecting it to work like Airflow. Prefect has no fixed DAG file, so the graph only shows up after a run.

## Three principles

- **Plain Python.** Decorators on normal functions.
- **Dynamic flows.** Branches and loops are allowed.
- **Tracked runs.** Logs, retries and state for each step.

## Related terms

- [Workflow Orchestration](https://learn.benibix.com/term/data/workflow-orchestration)
- [Apache Airflow](https://learn.benibix.com/term/data/apache-airflow)
- [Dagster](https://learn.benibix.com/term/data/dagster)
- [Task Retry](https://learn.benibix.com/term/data/task-retry)
- [Python](https://learn.benibix.com/term/development/python)
- [Workflow as Code](https://learn.benibix.com/term/data/workflow-as-code)

## Told apart from

- [Dagster vs Prefect](https://learn.benibix.com/compare/dagster-vs-prefect): People think Dagster and Prefect are two names for one idea, but they start from different places and suit different teams. Dagster plans around the tables and files a pipeline builds. It shows which ones are fresh. Prefect plans around plain Python functions, and adds tracking and retries to them. Pick Dagster if you think in tables, and Prefect if you think in scripts.

![Five tasks joined by arrows: extract orders and extract payments both feed a join task, which feeds build report and then email team. The join task is highlighted as failed, with a loop arrow labelled retry 2 of 3.](https://learn.benibix.com/diagrams/orchestration-dag.svg)

---

Source: https://learn.benibix.com/term/data/prefect
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
