Skip to content

Commit

Permalink
fix k8s compute update bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu authored and Ubuntu committed Dec 6, 2023
1 parent 9965308 commit f5c1c71
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,25 @@
"source": [
"from azure.ai.ml import load_compute\n",
"\n",
"\n",
"compute_name = \"<COMPUTE_NAME>\"\n",
"\n",
"# for arc connected cluster, the resource_id should be something like '/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.ContainerService/connectedClusters/<CLUSTER_NAME>''\n",
"compute_params = [\n",
" {\"name\": \"<COMPUTE_NAME>\"},\n",
" {\"name\": compute_name},\n",
" {\"type\": \"kubernetes\"},\n",
" {\n",
" \"resource_id\": \"/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.ContainerService/managedClusters/<CLUSTER_NAME>\"\n",
" },\n",
"]\n",
"k8s_compute = load_compute(source=None, params_override=compute_params)\n",
"\n",
"ml_client.begin_create_or_update(k8s_compute).result()"
"compute_list = {c.name:c.type for c in ml_client.compute.list()}\n",
"\n",
"if compute_name not in compute_list or compute_list[compute_name] != \"kubernetes\":\n",
" ml_client.begin_create_or_update(k8s_compute).result()\n",
"else:\n",
" print(\"Compute already exists\")"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,11 @@
"source": [
"from azure.ai.ml import load_compute\n",
"\n",
"compute_name = \"<COMPUTE_NAME>\"\n",
"\n",
"# for arc connected cluster, the resource_id should be something like '/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.ContainerService/connectedClusters/<CLUSTER_NAME>''\n",
"compute_params = [\n",
" {\"name\": \"<COMPUTE_NAME>\"},\n",
" {\"name\": compute_name},\n",
" {\"type\": \"kubernetes\"},\n",
" {\n",
" \"resource_id\": \"/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.ContainerService/managedClusters/<CLUSTER_NAME>\"\n",
Expand All @@ -332,7 +334,12 @@
"k8s_compute = load_compute(source=None, params_override=compute_params)\n",
"\n",
"# !!!bug https://msdata.visualstudio.com/Vienna/_workitems/edit/1740311\n",
"ml_client.begin_create_or_update(k8s_compute).result()"
"compute_list = {c.name:c.type for c in ml_client.compute.list()}\n",
"\n",
"if compute_name not in compute_list or compute_list[compute_name] != \"kubernetes\":\n",
" ml_client.begin_create_or_update(k8s_compute).result()\n",
"else:\n",
" print(\"Compute already exists\")"
]
},
{
Expand Down

0 comments on commit f5c1c71

Please sign in to comment.