<@ULVA73B9P> having a template like this, how to a...
# ask-marvin
k
@Marvin having a template like this, how to actually deploy/apply it?
Copy code
name: prefect.fraio-trigger
prefect-version: 3.4.18

build:
- prefect_docker.deployments.steps.build_docker_image:
    id: build_image
    requires: prefect-docker>=0.4.5
    image_name: "harbor.mgmt.vintecc.cloud/vintecc-ags-hbm/fraio_algo"
    tag: "local"
    dockerfile: auto

push:
- prefect_docker.deployments.steps.push_docker_image:
    requires: prefect-docker>=0.4.5
    image_name: '{{ build_image.image_name }}'
    tag: '{{ build_image.tag }}'

pull:
- prefect.deployments.steps.set_working_directory:
    directory: "/opt/prefect/{{ $REPOSITORY_NAME }}"
    
deployments:
- name: "fraio-trigger"
  version: "local"
  tags: [] 
  description: null
  schedule: {}
  flow_name: "fraio-trigger"
  entrypoint: ./fraio_algorithms/fraio_trigger_flow.py:trigger-flow
  parameters:
  work_pool:
    name: fraio
    work_queue_name: null
    job_variables:
      image: '{{ build_image.image }}'
m
thought for 249.8 seconds
Short answer: run prefect deploy from your project root. Prefect will read your prefect.yaml, run the build/push steps locally, and register the deployment(s). Then make sure a worker is polling your work pool. Here’s a step-by-step checklist for your template in Prefect 3.x: 1) Prereqs - Ensure you’re on Prefect 3.x (your file pins 3.4.18). - Install the Docker extra so the build/push steps are available:
Copy code
pip install "prefect==3.4.18" "prefect-docker>=0.4.5"
Or run CLI commands with extras on demand:
Copy code
uv run --with 'prefect[docker]' prefect deploy
2) Create the work pool (if it doesn’t exist yet) - If you’re running this in Docker containers, create a Docker pool:
Copy code
prefect work-pool create fraio --type docker
- If you’re using Kubernetes instead, use --type kubernetes and make sure your job_variables match that template. 3) Start a worker for the pool
Copy code
prefect worker start --pool fraio
Add --work-queue if you’re using a specific queue. 4) Deploy from the prefect.yaml - From the directory containing prefect.yaml:
Copy code
uv run --with 'prefect[docker]' prefect deploy
Optionally target just one deployment in the file:
Copy code
uv run --with 'prefect[docker]' prefect deploy --name fraio-trigger
5) Kick off a run (optional)
Copy code
prefect deployment run fraio-trigger/local --watch
Important notes about your template - entrypoint must reference a valid Python function name. You have: ./fraio_algorithms/fraio_trigger_flow.py:trigger-flow That hyphen is not a valid Python identifier. It should be: ./fraio_algorithms/fraio_trigger_flow.py:trigger_flow - The image reference in job_variables looks right for Docker/Kubernetes pools: image: '{{ build_image.image }}' - Make sure you’re authenticated to your registry before deploying so the push step can succeed:
Copy code
docker login harbor.mgmt.vintecc.cloud
Docs and references - Prefect 3.x deployments via prefect.yaml: Prefect YAML guide - Work pools CLI: prefect work-pool CLI - Workers CLI: prefect worker CLI - Docker collection (build/push steps): Prefect Docker collection Want me to validate your entrypoint and pool type are aligned with your runtime? If you confirm whether the ‘fraio’ pool is Docker or Kubernetes, I’ll tailor the job_variables and next steps accordingly.
k
@Marvin I can't add the work pool generation inside the template?
m
thought for 85.5 seconds
Short answer: no. In Prefect 3.x the prefect.yaml cannot create a work pool; it only references an existing pool by name. You need to create the pool once via CLI, UI, or API before running prefect deploy. Typical ways to automate it before deploy: - CLI (Docker pool)
Copy code
prefect work-pool create fraio --type docker --overwrite
prefect worker start --pool fraio
prefect deploy --name fraio-trigger
- CLI (Kubernetes pool)
Copy code
uv run --with 'prefect[kubernetes]' prefect work-pool create fraio --type kubernetes --overwrite
prefect worker start --pool fraio
uv run --with 'prefect[docker]' prefect deploy --name fraio-trigger
You can put those commands in your CI/CD pipeline so the pool is created/updated before each deploy. Docs: - Work pools (CLI): prefect work-pool CLI - Deployments from prefect.yaml: Prefect YAML guide If you tell me whether your ‘fraio’ pool is Docker or Kubernetes, I’ll give you the exact create command and any job_variables you may want to set.
k
@Marvin what if the filename is not
prefect.yaml
?
m
thought for 63.6 seconds
Yes — point
prefect deploy
at your file with the
--prefect-file
flag. Examples:
Copy code
prefect deploy --prefect-file ./my_prefect.yml
prefect deploy --prefect-file ./deploy/prefect-deploy.yaml --name fraio-trigger
Tip: since your template uses Docker build/push steps, run with the Docker extra to ensure dependencies are present:
Copy code
uv run --with 'prefect[docker]' prefect deploy --prefect-file ./deploy/prefect-deploy.yaml
Docs: Prefect YAML guide