Quickstart
Get started with Prefect, the easiest way to orchestrate and observe your data pipelines
Prefect is an orchestration and observability platform that empowers developers to build and scale workflows quickly. In this quickstart, you will use Prefect to convert the following Python script to a deployable workflow.
Install Prefect
To install Prefect with pip, run:
See Install Prefect for more details on installation.
Connect to a Prefect API
Connect to a Prefect API:
-
Start a local API server:
-
Open the Prefect dashboard in your browser at http://localhost:4200.
Convert your script to a Prefect workflow
Decorators are the easiest way to convert a Python script into a workflow.
- Add a
@flow
decorator to the script’s entrypoint. - Add
@task
decorators to any methods called by the flow.
This will create a flow and corresponding tasks. Tasks receive metadata about upstream dependencies and the state of those dependencies before they run. Prefect records these dependencies and states as it orchestrates these tasks.
The log_prints=True
argument provided to the @flow
decorator automatically converts any print
statements within the function to INFO
level logs.
Run your flow
You can run your Prefect flow just as you would a Python script:
The output in your terminal should look similar to this:
Prefect automatically tracks the state of the flow run and logs the output, which can be viewed directly in the terminal or in the UI.
Next steps
In this tutorial, you successfully converted a Python script to a deployable workflow tracked by Prefect.
Next, get this workflow off of your laptop and run it automatically on a schedule.
Need help? Book a meeting with a Prefect Product Advocate to get your questions answered.
Was this page helpful?