1
Create and login to your Prefect Cloud account.
Prefect uses a database to store workflow metadata.
For the ease of getting started, we’ll use one hosted on Prefect Cloud. To create an account, we need to install
prefect-cloud
. We’ll leverage uv
, a modern Python package manager, to do this. Run the following commands in your terminal, after which you’ll be prompted in your browser to create or login to your free Prefect Cloud account.2
What code should run?
Let’s start with a boring Python script that fetches a list of customer ids and processes them all in parallel. You can find this code and other examples hosted in our quickstart repository.This looks like the ordinary Python you’d write, except there is:If all went well, you’ll see a link to see its execution graph in the Prefect UI followed by a flurry of state changes and logs as Prefect dynamically discovers and executes your workflow.
01_getting_started.py
- a
@flow
decorator on the script’s entrypoint. - a
@task
decorator on each function called within the flow.
flow
, Prefect dynamically creates a graph of each task
and the state of their upstream dependencies. This allows Prefect to execute each task
in the right order and, in the case of failure, to recover the state of your workflow and resume from its point of failure.Let’s run this code locally on your computer. To do that, run the following command in your terminal.3
Where should it run?
At this point, you’ve successfully run a Prefect If all went well, you’ve created your first deployed workflow.Since we now know what code to run and where to run it, this can now be invoked remotely.
To do that, run the following command and visit the returned link to see the run’s status in the Prefect UI:Congrats! You’ve just run your first Prefect workflow remotely.
flow
locally. Let’s get it running off of your machine! Again, for simplicity,
we’ll deploy this workflow to Prefect’s Serverless Compute (so we don’t have to wrangle any infrastructure). We’ll tell Prefect to clone
https://github.com/PrefectHQ/quickstart
and invoke 01_getting_started.py:main
.4
When should it run?
Now that you’ve deployed and run your workflow remotely, you might want to schedule it to run automatically at specific times. Prefect makes this easy with the After running the command, your workflow will automatically execute remotely according to the schedule you’ve set.You can view and manage all your scheduled runs in the Prefect UI.
prefect-cloud schedule
command.Let’s schedule our workflow to run every day at 8:00 AM with cron
syntax.Next steps
Now that you’ve created your first workflow, explore Prefect’s features to enable more sophisticated workflows.- Learn more about flows and tasks.
- Learn more about deployments.
- Learn more about work pools.
- Learn how to run work concurrently.