Hakim
10/24/2024, 4:40 PMSelect the infrastructure you want to use to execute your flow runs
prompt. Anyone can help with some insights or instruction for self hosted prefcet 3 server ?Nate
10/24/2024, 5:49 PMHakim
10/24/2024, 5:49 PMNate
10/24/2024, 5:50 PMHakim
10/24/2024, 5:50 PM2024.10.17192636'
Nate
10/24/2024, 5:51 PM3.0.x
how are you running the server?Hakim
10/24/2024, 5:51 PMNate
10/24/2024, 5:51 PMHakim
10/24/2024, 5:52 PM<http://app.kubernetes.io/name|app.kubernetes.io/name>: prefect-server
<http://app.kubernetes.io/version|app.kubernetes.io/version>: 2-latest
<http://helm.sh/chart|helm.sh/chart>: prefect-server-0.0.0
pod-template-hash: 89c95974
prefect-version: 2-latest
Nate
10/24/2024, 5:53 PM» docker run -p 4200:4200 -d --rm prefecthq/prefect:3-latest -- prefect server start --host 0.0.0.0
and navigating to localhost:4200
Nate
10/24/2024, 5:53 PMHakim
10/24/2024, 5:54 PMHakim
10/24/2024, 5:54 PMNate
10/24/2024, 6:09 PMmain
, and we will cut a release later today or tomorrow so 3-latest
should do the right thing after thats out
in the meantime though, 3.0.4
does not have this problem so in the values.yaml
for your server deployment, you can select the image tag and this one should work for you prefecthq/prefect:3.0.4-python3.12
Hakim
10/24/2024, 6:10 PMNate
10/24/2024, 6:10 PMHakim
10/24/2024, 8:56 PMNate
10/24/2024, 9:05 PMflow.from_source(source="<https://mygitlaburletc>", entrypoint=...).deploy()
) or in a `prefect.yaml`
◦ using either from_source
(python) or a pull
step (yaml) you give the deployment the info about where the code lives (gitlab)
◦ using .deploy()
or the work_pool
section of the yaml, you say which work pool the deployment should get its infra config from (your new k8s work pool)
• deploy flows when you push code to gitlab
◦ set PREFECT_API_URL
in the env of your gitlab CI
◦ run prefect --no-prompt deploy --all
or python deploy.py
depending on whether you define deployments in yaml or pythonHakim
10/24/2024, 11:54 PMprefect.yaml
file through that command giben they are in the same root level directory right ?Nate
10/24/2024, 11:58 PMprefect.yaml
is at your repo root, but you can pass --prefect-file some/path/prefect.yaml
if you end up wanting to break things out
» prefect deploy --help
Usage: prefect deploy [OPTIONS] [ENTRYPOINT]
Create a deployment to deploy a flow from this project.
Should be run from a project root directory.
...
--prefect-file PATH Specify a custom path to a prefect.yaml file [default: prefect.yaml]
here is an example prefect.yaml
with some valid deployment definitions, and the CI (granted for GHA, not gitlab, but the bash should be the same)Hakim
10/25/2024, 12:03 AMNate
10/25/2024, 12:08 AMdocker build
/ docker push
etc yourself elsewhere and then hardcode or template the resulting image tag so your deployment knows to use it
the "{{ build-image.image }}"
syntax is just a special case of templating where you opt to build your image as a part of prefect deploy
and the `build-image` step produces an image that you can use to define the image
on your deployment's job_variables
Hakim
10/25/2024, 12:12 AMNate
10/25/2024, 12:13 AMNate
10/25/2024, 12:13 AMHakim
10/28/2024, 1:57 PMprefect.yaml
to get ran during CI deploy job
# Generic metadata about this project
name: flows
prefect-version: 3.0.0
# build section allows you to manage and build docker images
build:
- prefect_docker.deployments.steps.build_docker_image:
id: build-image
requires: prefect-docker>=0.6.1
image_name: "lab-prefect-3"
tag: latest
dockerfile: Dockerfile
platform: "linux/amd64"
## push section allows you to manage if and how this project is uploaded to remote locations
push:
- prefect_docker.deployments.steps.push_docker_image:
requires: prefect-docker>=0.6.1
image_name: "{{ build-image.image_name }}"
tag: "{{ build-image.tag }}"
# the definitions section allows you to define reusable components for your deployments
definitions:
tags: &common_tags
- "eks"
work_pool: &common_work_pool
name: "my-pool"
job_variables:
image: "{{ build-image.image }}"
# the deployments section allows you to provide configuration for deploying flows
deployments:
- name: "lab-prefect-3-deployment"
tags: *common_tags
schedule: null
entrypoint: "src/flows/flow.py:hello"
parameters:
name: "Hakim"
work_pool: *common_work_pool
But I think during the build phase it is failing with this error
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/pydantic/json_schema.py", line 337, in build_schema_type_to_method
mapping[key] = getattr(self, method_name)
AttributeError: 'GenerateEmptySchemaForUserClasses' object has no attribute 'invalid_schema'
Hakim
10/29/2024, 8:24 PMNate
10/29/2024, 8:30 PMcredentials
one useful insight is that all those steps are just fully qualified function names
prefect_docker.deployments.steps.push_docker_image
etc
https://github.com/PrefectHQ/prefect/blob/ca9e7bdcc947c6cb9ed42e0a0c9ed45c503c816c[…]integrations/prefect-docker/prefect_docker/deployments/steps.pyNate
10/29/2024, 8:32 PMHakim
10/29/2024, 8:32 PMprefect.blocks.docker-registry-credentials.dev-registry
Nate
10/29/2024, 8:35 PMdev-registry
but you dont need to create a block, you can just auth with docker or your registry otherwise before calling prefect deploy
as shown in the docsHakim
10/29/2024, 8:36 PMNate
10/29/2024, 8:37 PMimage
which contains the ref to the registry repo etcHakim
10/29/2024, 8:37 PMNate
10/29/2024, 8:38 PMHakim
10/29/2024, 8:39 PM