Peleg Dvir
03/04/2025, 2:09 PM...
"job_configuration": {
...
"job_manifest": {
"kind": "Job",
"spec": {
"template": {
"spec": {
"containers": [
{
"env": "{{ env }}",
"args": "{{ command }}",
"name": "prefect-job",
"image": "{{ image }}",
"resources": {
"limits": {
"cpu": "1000m",
"memory": "6G",
"ephemeral-storage": "1Gi"
},
"requests": {
"cpu": "1000m",
"memory": "6G",
"ephemeral-storage": "1Gi"
}
...
I know that we can set "Job Variables" for deployment, but im not sure if thats the approach and how to set it for example to have "memory": 60G
I have this in my deployment config - but it's affects nothing
{
"resources": {
"limits": {
"cpu": "3000m",
"memory": "50G",
"ephemeral-storage": "1Gi"
},
"requests": {
"cpu": "3000m",
"memory": "50G",
"ephemeral-storage": "1Gi"
}
}
}
Marvin
03/04/2025, 2:10 PMjob_variables
argument in your deployment configuration. This allows you to pass a dictionary of variables that can override any values set on the work pool or deployment.
Here's a concise guide on how to do this:
1. Define Job Variables: You need to add the desired resource configurations, such as CPU and memory limits, in the job_variables
argument when deploying your flow.
2. Deployment Configuration: Ensure that your deployment script includes the job_variables
dictionary with the appropriate resource settings. This can be done in your deployment script or via the Prefect UI.
3. Example Usage: In your deployment configuration, you might include something like:
python
deployment = Deployment(
flow=my_flow,
name="my_deployment",
work_pool_name="my_k8s_work_pool",
job_variables={
"resources": {
"limits": {
"cpu": "3000m",
"memory": "60G",
"ephemeral-storage": "1Gi"
},
"requests": {
"cpu": "3000m",
"memory": "60G",
"ephemeral-storage": "1Gi"
}
}
}
)
4. UI and CLI: You can also use the Prefect UI or CLI to pass these job variables during a custom run, allowing you to override the default settings for specific runs.
For more detailed guidance, you may refer to the following resources:
- Kubernetes Infrastructure Examples
- Customize Infrastructure
Remember that Prefect 3.x has introduced changes such as replacing agents with workers and infrastructure blocks with work pools, so ensure your configurations align with these updates.