Ben Zehavi
02/05/2024, 12:18 PMMarvin
02/05/2024, 12:18 PM.gitlab-ci.yml
file that shows how you might run a Prefect workflow:
yaml
stages:
- build
- deploy
build_job:
stage: build
image: python:3.9
script:
- pip install -r requirements.txt
- pip install prefect
- prefect block set ...
- prefect deploy-build -n my-deployment --apply
deploy_job:
stage: deploy
image: python:3.9
script:
- pip install prefect
- prefect auth login --key $PREFECT_API_KEY
- prefect deployment run 'my-deployment'
only:
- main
In this configuration:
- The build_job
job installs your Python dependencies including Prefect, and then performs a build of your Prefect deployment (prefect deploy-build
).
- The deploy_job
job logs into Prefect Cloud (assuming you're using it) and then runs a flow that is part of a deployment. The only
directive specifies that this job should only run on the main branch.
Remember to replace placeholder values (like $PREFECT_API_KEY
, my-deployment
, etc.) with your actual information. You'll also need to define and configure your deployment.
Please consult the Prefect documentation and GitLab CI/CD documentation for exact details and best practices for your setup.Ben Zehavi
02/05/2024, 12:22 PMAndy Irvine
02/05/2024, 12:29 PMprefect deploy-build --help
Usage: prefect [OPTIONS] COMMAND [ARGS]...
Try 'prefect --help' for help.
╭─ Error ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ No such command 'deploy-build'
prefect --version
2.14.18
Should be prefect deployment build
?Marvin
02/05/2024, 12:30 PMprefect deployment build
. The sample .gitlab-ci.yml
file should reflect Prefect 2.x CLI usage like below:
yaml
stages:
- build
- deploy
build_job:
stage: build
image: python:3.9
script:
- pip install -r requirements.txt
- pip install prefect
- prefect deployment build . -n my-deployment -t my-tag --apply
deploy_job:
stage: deploy
image: python:3.9
script:
- pip install prefect
- prefect auth login --key $PREFECT_API_KEY
- prefect deployment run my-deployment/my-tag
only:
- main
In this corrected configuration:
- prefect deployment build
is the correct command to build the deployment from a flow in Prefect 2.x.
- The -n
flag specifies the name of the deployment.
- The -t
flag specifies the tag for the deployment.
- The --apply
flag applies the deployment.
- prefect deployment run
is now used to run a deployment by specifying the name and tag of the deployment.
Make sure that your .gitlab-ci.yml
CI/CD pipeline configuration corresponds to the correct version of Prefect you are using.