Jiaqiang Li
03/25/2024, 2:07 PMMarvin
03/25/2024, 2:08 PM.serve
method. The .serve
method allows for quickly scheduling and executing workflows, but for a more resilient and production-grade deployment, you'll want to build a deployment YAML file and send it to the server with prefect deployment apply
.
The .serve
method serves as a quick way to test and schedule your flows directly from your Python code:
python
if __name__ == "__main__":
everflow_clicks_conversions_api_to_gcp.serve(
name="everflow_deployment",
cron="0 10 * * *",
tags=["testing", "tutorial"],
description="Given a GitHub repository, logs repository statistics for that repo.",
version="tutorial/deployments",
)
However, for more robust deployments and for integration with Git-based version control systems like GitLab, you typically use Prefect's deployment infrastructure, which will package your project into a portable structure for execution on any compatible Python environment. The result is a YAML file describing your flow's deployment that you apply using prefect deployment apply
. This method is suitable for production.
Here is an article discussing the global coordination plane with Prefect which is pertinent to this topic: Prefect Global Coordination Plane.
You should consult the Prefect documentation or guides for the most recent and detailed instructions on creating deployments through GitLab and using the Prefect tooling for production systems:
- The Storage Guide in the Prefect docs discusses production deployment options, including Git-based storage like GitLab.
- A blog post on quick scheduling with .serve
can provide additional context: Schedule Your Code Quickly with Flow.serve.
Remember that the .serve
function automatically creates a deployment visible in the Prefect UI, but for deployments via GitLab or for more persistent and managed workflows, the YAML file creation and application via prefect deployment apply
is the preferred approach.