[英]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.