PN
08/21/2024, 11:31 AMMarvin
08/21/2024, 11:31 AMpython
class MyWorkerConfiguration(BaseJobConfiguration):
memory: str = Field(
default="1024Mi",
description="Memory allocation for the execution environment.",
template="{{ memory_request }}Mi"
)
cpu: str = Field(
default="500m",
description="CPU allocation for the execution environment.",
template="{{ cpu_request }}m"
)
2. Using Prefect Blocks and Variables
- Prefect deploy files (.yaml) use various references:
- Blocks: {{ prefect.blocks.block_type.block_slug }}
- Variables: {{ prefect.variables.variable_name }}
- Environment Variables: {{ $MY_ENV_VAR }}
- Example prefect.yaml
file:
yaml
build:
- prefect_docker.deployments.steps.build_docker_image:
id: build-image
requires: prefect-docker>=0.3.0
image_name: my-repo/my-image
tag: my-tag
dockerfile: auto
push: true
deployments:
- name: null
version: "{{ build-image.tag }}"
tags:
- "{{ $my_deployment_tag }}"
- "{{ prefect.variables.some_common_tag }}"
### Helpful Links
- Developing a new worker type guide
- Prefect work pools concepts
- Prefect deployment guide
- Prefect migration guide
Adding conditional logic might involve clever use of variable interpolation and potentially helper functions within those templates. For precise implementation, check the examples provided in Prefect documentation or experiment within your configuration fields using Templating logic.
Hopefully, that points you in the right direction!