Your first steps with Prefect – learn how to create a basic flow and understand core concepts.
Welcome to your first Prefect flow. In under a minute you will:
Pro tip: change anything in this file and re-run it. Prefect hot-loads your new logic in seconds, no image builds, ever.
We start by importing the essential flow
decorator from Prefect.
Prefect takes your Python functions and transforms them into flows with enhanced capabilities.
Let’s write a simple function that takes a name parameter and prints a greeting.
To make this function work with Prefect, we just wrap it in the @flow
decorator.
Now let’s see different ways we can call that flow:
When we decorated our function with @flow
, the function was transformed into a Prefect flow. Each time we called it:
In short, we took a regular function and enhanced it with observability and tracking capabilities.
This simple example demonstrates Prefect’s core value proposition: taking regular Python code and enhancing it with production-grade orchestration capabilities. Let’s explore why this matters for real-world data workflows.
For instance, change the greeting message in the hello
function to a different message and run the flow again.
You’ll see your changes immediately reflected in the logs.
Add more names to the crew
list or create a larger data set to process. Prefect will handle each execution and track every input and output.
The hello
function is a simple example, but in its place imagine something that matters to you, like:
Prefect lets you orchestrate these operations effortlessly with automatic observability, error handling, and retries.
Remember that Prefect makes it easy to:
The @flow
decorator is your gateway to enterprise-grade orchestration - no complex configuration needed!
For more information about the orchestration concepts demonstrated in this example, see the Prefect documentation.