prefect
prefect copied to clipboard
Make all fields in the deployment schema templatable as `prefect.yaml` step outputs
Describe the current behavior
schedules
cannot be provided as deployment step outputs because prefect deploy
constructs and validates them before the running of steps and template resolution occurs.
1 validation error for CronSchedule
cron
Invalid cron string: "{{ get-schedule.schedule }}" (type=value_error)
Describe the proposed behavior
schedules
, as well as all other fields on the deployment schema, should be validated after all build and push steps have run and template resolution is completed.
Example Use
A build step where the current workspace is checked to decide which schedule to use.
name: dynamic-schedules
prefect-version: 2.19.7
build:
- schedules.get_schedule_for_workspace:
id: get-schedule
- prefect_docker.deployments.steps.build_docker_image:
requires: prefect-docker>=0.3.1
id: build-image
dockerfile: auto
image_name: docker.io/kevingrismoreprefect/dynamic-schedules
tag: '2'
push:
- prefect_docker.deployments.steps.push_docker_image:
requires: prefect-docker>=0.3.1
image_name: '{{ build-image.image_name }}'
tag: '{{ build-image.tag }}'
pull:
- prefect.deployments.steps.set_working_directory:
directory: /opt/prefect/
deployments:
- name: dynamic-schedules
version:
tags: []
description:
entrypoint: flow.py:my_flow
parameters: {}
work_pool:
name: k8s-demo
work_queue_name:
job_variables:
image: '{{ build-image.image }}'
schedules:
- cron: '{{ get-schedule.schedule }}'
Additional context
No response