0

I'm trying to delete an AzureML model using the python SDK v2,
but I couldn't find such functionality.
its a bit surprising, cause there's such functionality in the web UI.

Was looking at both azure.ai.ml.entities.Model and azure.ai.ml.operations.ModelOperations (the class under which all ml_client.models.<operation> operations are defined) - cant find support for delete operation under them.

Edit 1:
The v2 CLI doesn't support deletion as well (archiving is not deletion) enter image description here

Edit 2:
As partial solution, this can be achieved using SDK v1:

from azureml.core import Workspace, Model
workspace = ...
model = Model(workspace=workspace, name=name, version=version)
model.delete()
asafal
  • 43
  • 4

1 Answers1

1

using Azure cli and python sdk I Deleted Azure ML model using python SDK 1.49.0

  • Using Azure cli I got the same command

enter image description here

  • Adding az extension i was able to find delete command
  az extension add -n azure-cli-ml

enter image description here

   az ml model delete --model-id <model_id> --workspace-name <workspace_name> --resource-group <resource_group> --subscription <subscription_id>

enter image description here

  • using python sdk

from azureml.core import Workspace, Model

# Replace with your AzureML workspace details
subscription_id = "your-subscription-id"
resource_group = "your-resource-group"
workspace_name = "your-workspace-name"

# Replace with your model name and version
model_name = "your-model-name"
model_version = 2

workspace = Workspace(subscription_id, resource_group, workspace_name)

# Get the model using the Model class
model = Model(workspace=workspace, name=model_name, version=model_version)

model = Model(workspace, name=model_name)

model_id = model.id

  

print("Model ID:", model_id)

# Delete the model
model.delete()

print("Model deleted successfully.")

enter image description here

enter image description here

Sampath
  • 810
  • 2
  • 2
  • 13