12-21-2023 06:45 AM
I want to change instance type or number of max workers via a python script. Does anyone know how to do it/is it possible? I have a lot of background jobs when I want to scale down my workers, so autoscaling is not an option.
I was getting an error that node_type_id value must be Standard_DS3_v2 but that is my current one that I want to change:
Failed to update cluster size. Status code: 400, Response: {"error_code":"INVALID_PARAMETER_VALUE","message":"Validation failed for node_type_id, the value must be Standard_DS3_v2 (is \"Standard_DS4_v2\")","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","field_violations":[{"field":"node_type_id","description":"Validation failed for node_type_id, the value must be Standard_DS3_v2 (is \"Standard_DS4_v2\")"}]},{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"CM_API_ERROR_SOURCE_CALLER_ERROR","domain":""}]}
12-21-2023 11:31 AM
We can update cluster configuration prgramatically using databricks api.
Steps:
1) Fetch all the clusters info present in your workspace.
2) Loop through each cluster info
3) Use the parsed info like cluster id etc.. to update cluster config
Example Psuedo code:
import requests
import json
host = "https://<YOUR-WORKSPACE-URL>"
workspace_access_token = "<YOUR-ACCESS-TOKEN>"
cluster_id = "<YOUR-CLUSTER-ID>"
workers_min = 1
workers_max = 2
response = requests.post(
f"{host}/api/2.0/clusters/edit",
headers={
"Authorization": f"Bearer {workspace_access_token}",
"Content-Type": "application/json"
},
data={
"cluster_id": cluster_id,
"min_workers": workers_min,
"max_workers": workers_max
}
)
12-21-2023 03:12 PM
Hi ksenija, this is just my guess but maybe you are using Cluster Policy in your cluster that only allows you to use specific cluster size ? E.g. below cluster policy that limits to some cluster sizes only.
12-21-2023 03:32 PM
Yes, you can only use the node types specified in the policy.
12-22-2023 01:41 AM
You're right, I didn't even check policies. This means I can't even change min and max workers, right?
12-22-2023 02:14 AM
Correct, please look at my example:
- i have created policy with fixed min and max no. of workers
Even UI block me and won;t allow to change min and max no. of workers
So your script will fail as it is violating cluster ploticy
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.
If there isn’t a group near you, start one and help create a community that brings people together.
Request a New Group