<@ULVA73B9P> How to use conditional logic in the B...
# marvin-in-the-wild
p
@Marvin How to use conditional logic in the Base Job Template?
m
It appears there isn't direct documentation or GitHub issues specifically about using conditional logic in the Base Job Template. However, I found some relevant information about working with templates in Prefect. ### Relevant Documentation 1. Template Variables in Job Configuration - When defining a job configuration model, template variables are interpolated into the job configuration. - Example: - Attributes & Template Variables:
Copy code
python
       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:
Copy code
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!