Lutz Ostkamp
07/30/2025, 12:15 PMMarvin
07/30/2025, 12:15 PMMarvin
07/30/2025, 12:16 PM{{ flow_run.name }}
- The name of the flow run
- {{ flow_run.id }}
- The unique identifier of the flow run
- {{ flow_run.flow_name }}
- The name of the flow
- {{ flow_run.parameters }}
- The parameters passed to the flow
- {{ deployment.name }}
- The name of the deployment
- {{ deployment.version }}
- The version of the deployment
These variables are automatically injected into the context when the job template is rendered. You can use them in your job template like this:
yaml
job_template:
apiVersion: batch/v1
kind: Job
metadata:
name: prefect-job-{{ flow_run.id }}
labels:
<http://prefect.io/flow-run-id|prefect.io/flow-run-id>: {{ flow_run.id }}
<http://prefect.io/flow-run-name|prefect.io/flow-run-name>: {{ flow_run.name }}
# ... rest of your job template
This is particularly useful for:
- Creating unique job names
- Adding labels or annotations for tracking/filtering
- Setting environment variables based on flow run details
- Configuring resource requests/limits dynamically
Note that while these variables are available, it's still a good practice to:
1. Test your templates thoroughly, as some variables might be None in certain contexts
2. Consider using the variables
section for values that you want to make easily configurable by users
3. Be cautious with special characters in variable values when using them in certain fields (like labels) that have strict naming requirements
You can find more details about customizing job variables in the Prefect documentation.Lutz Ostkamp
07/30/2025, 12:17 PMLutz Ostkamp
07/30/2025, 12:22 PMMarvin
07/30/2025, 12:22 PMMarvin
07/30/2025, 12:23 PMvariables
section are accessed using {{ variables.variable_name }}
2. Flow run details are available through {{ flow_run.* }}
(as shown in the runtime module)
3. Deployment details are available through {{ deployment.* }}
If you need to see exactly what variables are available in your specific context, you could:
1. Use the UI's Advanced tab in the work pool configuration to see the default template
2. Add a debug environment variable to your job template that prints out available variables
3. Check the runtime module reference for available attributes
Would you like me to file a documentation issue requesting a comprehensive list of available template variables? This would be helpful for the community.