CLI (v2) 环境 YAML 架构

适用范围:Azure CLI ml 扩展 v2(最新版)

源 JSON 架构可在 https://azuremlschemas.azureedge.net/latest/environment.schema.json 中找到。

注意

本文档中详细介绍的 YAML 语法基于最新版本的 ML CLI v2 扩展的 JSON 架构。 此语法必定仅适用于最新版本的 ML CLI v2 扩展。 可以在 https://azuremlschemasprod.azureedge.net/ 上查找早期扩展版本的架构。

YAML 语法

密钥 类型 说明 允许的值 默认值
$schema 字符串 YAML 架构。 如果使用 Azure 机器学习 VS Code 扩展来创作 YAML 文件,则可通过在文件顶部包含 $schema 来调用架构和资源完成操作。
name 字符串 必需。 环境的名称。
version 字符串 环境的版本。 如果省略此项,Azure ML 将自动生成一个版本。
description 字符串 环境的说明。
tags object 环境的标记字典。
image 字符串 要用于环境的 Docker 映像。 必须指定 imagebuild
conda_file 字符串或对象 conda 环境依赖项的标准 conda YAML 配置文件。 请参阅 https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-file-manually

如果已指定,则必须同时指定 image。 Azure ML 将在提供的 Docker 映像之上生成 conda 环境。
build object 要用于环境的 Docker 生成上下文配置。 必须指定 imagebuild
build.path 字符串 要用作生成上下文的目录本地路径。
build.dockerfile_path 字符串 生成上下文中 Dockerfile 的相对路径。 Dockerfile
os_type 字符串 操作系统的类型。 linuxwindows linux
inference_config object 推理容器配置。 仅在环境用于为联机部署生成服务容器时适用。 请参阅 inference_config 键的属性

inference_config 键的属性

类型 说明
liveness_route object 服务容器的运行情况路由。
liveness_route.path 字符串 将活动性请求路由至此的路径。
liveness_route.port 整型 将活动性请求路由至此的端口。
readiness_route object 服务容器的就绪情况路由。
readiness_route.path 字符串 将就绪性请求路由至此的路径。
readiness_route.port 整型 将就绪性请求路由至此的端口。
scoring_route object 服务容器的评分路由。
scoring_route.path 字符串 将评分请求路由至此的路径。
scoring_route.port 整型 将评分请求路由至此的端口。

备注

az ml environment 命令可用于管理 Azure 机器学习环境。

示例

示例 GitHub 存储库中提供了示例。 下面显示了几个示例。

YAML:本地 Docker 生成上下文

$schema: https://azuremlschemas.azureedge.net/latest/environment.schema.json
name: docker-context-example
build:
  path: docker-contexts/python-and-pip

YAML:Docker 映像

$schema: https://azuremlschemas.azureedge.net/latest/environment.schema.json
name: docker-image-example
image: pytorch/pytorch:latest
description: Environment created from a Docker image.

YAML:Docker 映像和 conda 文件

$schema: https://azuremlschemas.azureedge.net/latest/environment.schema.json
name: docker-image-plus-conda-example
image: mcr.microsoft.com/azureml/openmpi3.1.2-ubuntu18.04
conda_file: conda-yamls/pydata.yml
description: Environment created from a Docker image plus Conda environment.

后续步骤