python - 使用 python SDK v2 删除 AzureML 模型

标签 python azure azure-machine-learning-service azuremlsdk

我正在尝试使用 python SDK v2 删除 AzureML 模型,
但我找不到这样的功能。
这有点令人惊讶,因为 Web UI 中有这样的功能。

正在查看两者 azure.ai.ml.entities.Modelazure.ai.ml.operations.ModelOperations (定义所有 ml_client.models.<operation> 操作的类) - 找不到对它们下的删除操作的支持。

编辑1:
v2 CLI 也不支持删除(归档不是删除) enter image description here

编辑2:
作为部分解决方案,这可以使用 SDK v1 来实现:

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

最佳答案

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

  • 使用 Azure cli 我得到了相同的命令

enter image description here

  • 添加 az 扩展后我能够找到删除命令
  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

  • 使用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

关于python - 使用 python SDK v2 删除 AzureML 模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75712901/

相关文章:

python - 用条件列手段填充单元格

python - 用于读取 CSV 并加载到 PostgreSQL 的 Airflow Pipeline

azure - 无法在 AzureRM 上找到经典计算的 REST API 文档

python - Azure MachineforMachine Learning 的测试数据中缺少数据

Azure - 随着时间的推移预测

python - 单个 Flask 进程接收多少并发请求?

python - 基于匹配列值压缩数据帧

forms - 保存表单识别数据库表中的扫描数据

excel - 在 Excel VBA 宏中使用 Azure 翻译器

machine-learning - 是否可以从数据集中获得两种不同类型的结果