Cade Summers
07/31/2024, 3:29 PMMarvin
07/31/2024, 3:29 PMprefect deploy
instead of deployment build
, follow these steps:
1. Create a prefect.yaml
file: This file should describe the deployment and include sections for build, push, and pull steps.
2. Run the deployment: Use the prefect deploy
command in the directory containing the prefect.yaml
file. Here’s a brief overview of what happens:
- The prefect.yaml
file is loaded.
- The build steps are executed.
- The push steps are executed.
- The pull steps are templated with any step outputs but are not run. Block references are resolved at runtime for security.
- All variable and block references are resolved with the deployment declaration.
- Finally, the deployment specification is registered with the Prefect API.
For more details, you can refer to this guide on Prefect Deploy.
Here is an example of a simple prefect.yaml
and Python code to help you get started:
yaml
# prefect.yaml
version: 1
name: my_deployment
description: A sample deployment
work_pool:
- name: default
build:
- prefect build -o my_image
push:
- prefect push my_image my-registry/my-image:tag
pull:
- prefect pull my_image
entrypoint: flows/example.py:flow_name
Example Python code to define and deploy your flow:
python
from prefect import flow, deploy
@flow(log_prints=True)
def my_workflow():
print("I can call any python code here, including Prefect tasks or flows")
if __name__ == "__main__":
my_workflow()
deploy(
my_workflow.to_deployment(name="my-deployment"),
work_pool_name="default",
image="my-registry/my-image:tag",
push=False,
)
For more code examples, visit:
GitHub code example link