Hi <@ULVA73B9P> I have a repo in gitlab, I want de...
# ask-marvin
j
Hi @Marvin I have a repo in gitlab, I want deploy the workflow to my Prefect cloud account. It works well when I use the function 'serve'. However, it does not work when I use function 'deploy'. My serve code is: 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", )
m
To deploy a workflow from your GitLab repository to Prefect Cloud, you will need to use the Prefect CLI and the deployment functionality rather than the
.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:
Copy 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.