简体   繁体   English

如何使用 az ml cli 获取在 Azure 机器学习服务 Model 注册表中注册的最新版本的 Model ID?

[英]How to get Model ID of the Latest Version registered in Azure Machine Learning Service Model Registry using az ml cli?

Using Azure Machine Learning CLI extension, how do we get the Model ID for the latest version of a Model (with known model name)?使用 Azure 机器学习 CLI 扩展,我们如何获取最新版本 Model(已知名称 model)的 Model ID?

To get the entire list of Model Details with a given name the command is要获取具有给定名称的 Model 详细信息的完整列表,命令是

az ml model list --model-name [Model_Name] --resource-group [RGP_NAME] --subscription-id [SUB_ID] --workspace-name [WS_NAME]

Running this will give a list of all the models:运行它会给出所有模型的列表:

[
  {
    "createdTime": "2021-03-19T07:02:03.814172+00:00",
    "framework": "Custom",
    "frameworkVersion": null,
    "id": "model:2"
    "name": "model",
    "version": 3
  },
  {
    "createdTime": "2021-03-19T06:46:34.301054+00:00",
    "framework": "Custom",
    "frameworkVersion": null,
    "id": "model:2",
    "name": "model",
    "version": 2
  },
  {
    "createdTime": "2021-03-19T06:38:56.558385+00:00",
    "framework": "Custom",
    "frameworkVersion": null,
    "id": "model:1",
    "name": "model",
    "version": 1
  }
]

The Microsoft Documentation mentions, we can use a -l parameter to get the latest version details: Microsoft 文档提到,我们可以使用-l参数来获取最新版本的详细信息:

az ml model list --model-name [Model_Name] --resource-group [RGP_NAME] --subscription-id [SUB_ID] --workspace-name [WS_NAME] -l

However, running this gives the following error:但是,运行它会出现以下错误:

ERROR: UnrecognizedArgumentError: unrecognized arguments: -l

What is the syntax to use this -l flag?使用此-l标志的语法是什么?

I've just spent a fun few hours wrestling with this.我刚刚花了几个小时来解决这个问题。 Running something like运行类似

az ml model list -w your_workspace_name -g your_resource_group_name -l -n name_of_your_registered_model

will get you back some JSON that looks like this:会让你找回一些 JSON,看起来像这样:

[
  {
    "createdTime": "2022-03-04T16:05:47.103407+00:00",
    "framework": "Custom",
    "frameworkVersion": null,
    "id": "name_of_your_registered_model:3",
    "name": "name_of_your_registered_model",
    "version": 3
  }
]

This is well and good for a human, but not much use to a machine.这对人类来说很好,但对机器来说用处不大。 The azure cli supports something called JMESPath , which allows you to write a query against the result of a CLI command. azure cli 支持称为JMESPath的东西,它允许您针对 CLI 命令的结果编写查询。 Running跑步

az ml model list -w your_workspace_name -g your_resource_group_name -l -n name_of_your_registered_model --query "[0].{id:id}" -o tsv

should get you back应该让你回来

"name_of_your_registered_model:3"

Which you can then use in an env var or whatever other use case you have.然后您可以在环境变量或您拥有的任何其他用例中使用它。

If we wish to obtain the model-id for the latest model, instead of using az ml model list with -l flag, using az model show will return the details for the latest model. If we wish to obtain the model-id for the latest model, instead of using az ml model list with -l flag, using az model show will return the details for the latest model. The syntax to get a string for model-id will be:获取模型 ID 字符串的语法将是:

az ml model show --model-id $(TRN_MODEL_ID) --resource-group $(AML_TRN_RG) --subscription-id $(AML_TRN_SUB_ID) --workspace-name $(AML_TRN_WS) --query name -o tsv

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Azure ML 服务中注册本地训练的机器学习模型? - How can I register in Azure ML Service a machine learning model trained locally? 如何使用 az CLI 获取 Azure Log Analytics 的工作区 ID? - How to get workspace ID of Azure Log Analytics using az CLI? 问题:使用 Azure 机器学习服务部署模型 - Issue: Deploying a Model using Azure Machine Learning Service 将 R(本地)中保存的 ML 模型上传到 Azure 机器学习工作室 - Upload Saved ML Model in R (local) to Azure Machine Learning Studio 如何将现有机器学习模型与 Azure 机器学习结合使用? - How to use an existing machine learning model with Azure Machine Learning? 从另一个 Azure ML 工作区访问 Azure ML Model 注册表 - Accessing an Azure ML Model Registry from another Azure ML Workspace 无法在Azure机器学习服务工作区中注册ONNX模型 - Unable to register an ONNX model in azure machine learning service workspace 使用Azure机器学习服务训练大型模型时如何克服TrainingException? - How to overcome TrainingException when training a large model with Azure Machine Learning service? 使用Azure Functions部署python机器学习模型 - Deploying python machine learning model using Azure Functions 如何将 ONNX 机器学习 Model 存储为 Azure Synapse 的十六进制字符串? - How to store ONNX Machine learning Model as a Hexadecimal string for Azure Synapse?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM