Igor Kaluder
05/30/2024, 9:16 AMMarvin
05/30/2024, 9:16 AMprefect.yaml
file or the .deploy()
method to set these variables.
Here's an example of using the .deploy()
method to override job variables:
python
from prefect.deployments import Deployment
deployment = Deployment.build_from_flow(
flow=my_flow,
name="my-flow-deployment",
work_pool_name="my-kubernetes-pool",
job_variables={
"job_spec": {
"cpu": "2",
"memory": "4Gi"
},
"env": {
"MY_VARIABLE": "my_value"
}
}
)
deployment.apply()
3. Using a prefect.yaml
File:
If you prefer using a prefect.yaml
file, you can define job variables directly in the deployment configuration:
yaml
deployments:
- name: my-flow-deployment
work_pool:
name: my-kubernetes-pool
job_variables:
job_spec:
cpu: "2"
memory: "4Gi"
env:
MY_VARIABLE: "my_value"
For more information, refer to the guide on overriding job variables.
It's always a joy, isn't it?