CLI(v2) 명령 작업 YAML 스키마

적용 대상:Azure CLI ml 확장 v2(현재)

원본 JSON 스키마는 .에서 https://azuremlschemas.azureedge.net/latest/commandJob.schema.json찾을 수 있습니다.

Note

이 문서에 자세히 설명된 YAML 구문은 최신 버전의 ML CLI v2 확장에 대한 JSON 스키마를 기반으로 합니다. 이 구문은 최신 버전의 ML CLI v2 확장에서만 작동하도록 보장됩니다. https://azuremlschemasprod.azureedge.net/에서 이전 확장 버전에 대한 스키마를 찾을 수 있습니다.

YAML syntax

Key Type Description Allowed values Default value
$schema string YAML 스키마입니다. Azure Machine Learning VS Code 확장을 사용하여 YAML 파일을 제작하는 경우 파일 맨 위에 $schema를 포함하여 스키마 및 리소스 완성을 호출할 수 있습니다.
type const 작업의 유형입니다. command command
name string 작업의 이름입니다. 작업 영역의 모든 작업에서 고유해야 합니다. 생략하면 Azure Machine Learning이 이름에 대한 GUID를 자동 생성합니다.
display_name string 스튜디오 UI에서 작업의 표시 이름입니다. 작업 영역 내에서 고유하지 않을 수 있습니다. 생략하면 Azure Machine Learning이 표시 이름에 대한 인간이 읽을 수 있는 형용사-명사 식별자를 자동으로 생성합니다.
experiment_name string 작업을 구성할 실험 이름입니다. 각 작업의 실행 레코드는 스튜디오의 "실험" 탭에 있는 해당 실험으로 구성됩니다. 생략하면 Azure Machine Learning은 기본적으로 작업이 만들어진 작업 디렉터리의 이름으로 설정됩니다.
description string 작업에 대한 설명입니다.
tags object 작업에 대한 태그 사전입니다.
command string 실행할 명령입니다.
code string 업로드하여 작업에 사용할 소스 코드 디렉터리의 로컬 경로입니다.
environment 문자열 또는 개체 작업에 사용할 환경입니다. 작업 영역의 기존 버전이 지정된 환경에 대한 참조이거나 인라인 환경 사양일 수 있습니다.

기존 환경을 참조하려면 azureml:<environment_name>:<environment_version> 구문 또는 azureml:<environment_name>@latest(최신 버전의 환경 참조)를 사용합니다.

환경을 인라인으로 정의하려면 환경 스키마를 따릅니다. 인라인 환경에서 지원되지 않으므로 nameversion 속성을 제외합니다.

CLI 또는 SDK에서 큐레이팅된 환경으로 작업하는 경우 큐레이팅된 환경 이름은 .로 AzureML-시작합니다. Azure Machine Learning 스튜디오를 사용하는 경우 큐레이팅된 환경 이름에는 이 접두사가 없습니다. 이러한 차이가 발생하는 이유는 스튜디오 UI가 큐레이팅된 환경과 사용자 지정 환경을 별도의 탭에 표시하므로 접두사가 필요하지 않기 때문입니다. CLI와 SDK는 이러한 구분이 없으므로, 접두사를 사용하여 큐레이션된 환경과 맞춤 환경을 구분합니다.
environment_variables object 명령이 실행되는 프로세스에 설정할 환경 변수 키-값 쌍의 사전입니다.
distribution object 분산된 학습 시나리오에 대한 배포 구성입니다. MpiConfiguration, PyTorchConfiguration, TensorFlowConfiguration 또는 RayConfiguration 중 하나입니다.
compute string 작업을 실행할 컴퓨팅 대상의 이름입니다. 작업 영역의 기존 컴퓨팅에 대한 참조(구문 사용 azureml:<compute_name> ) 또는 local 로컬 실행을 지정할 수 있습니다. 참고: 파이프라인의 작업은 로 지원 local 되지 않습니다. compute local
resources.instance_count integer 작업에 사용할 노드 수입니다. 1
resources.instance_type string 작업에 사용할 인스턴스 유형입니다. Azure Arc 지원 Kubernetes 컴퓨팅에서 실행되는 작업에 적용됩니다(필드에 compute지정된 type: kubernetes 컴퓨팅 대상이 있는 경우). 생략하면 기본적으로 Kubernetes 클러스터의 기본 인스턴스 유형으로 설정됩니다. 자세한 내용은 인스턴스 유형 만들기 및 관리를 참조하세요.
resources.shm_size string Docker 컨테이너의 공유 메모리 블록 크기입니다. 숫자가 0보다 커야 하는 형식 <number><unit> 이어야 하며 단위는 (바이트), (킬로바이트), b (메가바이트) k 또는 m (기가바이트) 중 하나 g 일 수 있습니다. 2g
resources.docker_args string Docker run 명령에 전달할 추가 인수입니다.
resources.locations array 작업을 실행할 수 있는 지역 위치 목록입니다.
resources.max_instance_count integer 작업에 사용할 최대 노드 수입니다(탄력적으로 분산된 학습의 경우).
limits.timeout integer 작업을 실행할 수 있는 최대 시간(초)입니다. 이 제한에 도달하면 시스템에서 작업을 취소합니다.
inputs object 작업에 대한 입력의 사전입니다. 키는 작업의 컨텍스트 내에서 입력에 대한 이름이고 값은 입력 값입니다.

command 식을 사용하여 ${{ inputs.<input_name> }}에서 입력을 참조할 수 있습니다.
inputs.<input_name> 숫자, 정수, 부울, 문자열, 개체 리터럴 값(형식 번호, 정수, 부울 또는 문자열) 또는 작업 입력 데이터 사양이 포함된 개체 중 하나입니다.
outputs object 작업의 출력 구성 사전입니다. 키는 작업의 컨텍스트 내에서 출력에 대한 이름이고 값은 출력 구성입니다.

command 식을 사용하여 ${{ outputs.<output_name> }}에서 출력을 참조할 수 있습니다.
outputs.<output_name> object 개체를 비워 둘 수 있습니다. 이 경우 기본적으로 출력은 형식 uri_folder 이며 Azure Machine Learning은 출력에 대한 출력 위치를 생성합니다. 출력 디렉터리에 대한 파일은 읽기/쓰기 탑재를 통해 작성됩니다. 출력에 대해 다른 모드를 지정하려면 작업 출력 사양이 포함된 개체를 제공합니다.
queue_settings object 작업에 대한 큐 설정입니다. 작업 계층 및 일정 우선 순위를 구성합니다. 큐 설정을 참조하세요.
services object 대화형 작업 서비스(엔드포인트)의 사전입니다. 지원되는 서비스 유형: ssh, tensor_board, vs_codejupyter_lab.
identity object ID는 데이터 액세스에 사용됩니다. UserIdentityConfiguration, ManagedIdentityConfiguration, AMLTokenIdentityConfiguration 또는 None일 수 있습니다. UserIdentityConfiguration인 경우 작업 제출자의 ID를 사용하여 입력 데이터에 액세스하고 결과를 출력 폴더에 씁니다. 그렇지 않으면 컴퓨팅 대상의 관리 ID가 사용됩니다.

Distribution configurations

MpiConfiguration

Key Type Description Allowed values
type const Required. Distribution type. mpi
process_count_per_instance integer Required. 작업에 대해 시작할 노드당 프로세스의 수입니다.

PyTorchConfiguration

Key Type Description Allowed values Default value
type const Required. Distribution type. pytorch
process_count_per_instance integer 작업에 대해 시작할 노드당 프로세스의 수입니다. 1

TensorFlowConfiguration

Key Type Description Allowed values Default value
type const Required. Distribution type. tensorflow
worker_count integer 작업에 대해 시작할 작업자 수입니다. 기본값은 resources.instance_count입니다.
parameter_server_count integer 작업에 대해 시작할 매개 변수 서버의 수입니다. 0

RayConfiguration

Key Type Description Allowed values Default value
type const Required. Distribution type. ray
address string 연결할 기존 Ray 클러스터의 주소입니다. 생략하면 Azure Machine Learning에서 새 Ray 클러스터를 시작합니다.
port integer 헤드 레이 프로세스의 포트입니다.
dashboard_port integer Ray 대시보드 프로세스의 포트입니다.
include_dashboard boolean Ray 대시보드를 시작할지 여부입니다.
head_node_additional_args string 헤드 노드에 ray start 전달된 추가 인수입니다.
worker_node_additional_args string 작업자 노드에 ray start 전달된 추가 인수입니다.

Job inputs

Key Type Description Allowed values Default value
type string 작업 입력의 형식입니다. 단일 파일 원본을 가리키는 입력 데이터의 경우 uri_file을 지정하거나 폴더 원본을 가리키는 입력 데이터의 경우 uri_folder를 지정합니다. uri_file, uri_folder, mlflow_modelcustom_model uri_folder
path string 입력으로 사용할 데이터의 경로입니다. 다음과 같은 몇 가지 방법으로 지정할 수 있습니다.

- 데이터 원본 파일 또는 폴더에 대한 로컬 경로(예: path: ./iris.csv). 데이터는 작업 제출 중에 업로드됩니다.

- 입력으로 사용할 파일 또는 폴더에 대한 클라우드 경로의 URI입니다. 지원되는 URI 형식은 azureml, https, wasbs, abfss, adl입니다. URI 형식을 사용하는 방법에 대한 자세한 내용은 azureml:// 참조하세요.

- 입력으로 사용할 기존 등록된 Azure Machine Learning 데이터 자산입니다. 등록된 데이터 자산을 참조하려면 azureml:<data_name>:<data_version> 구문 또는 azureml:<data_name>@latest(해당 데이터 자산의 최신 버전 참조)를 사용합니다(예: path: azureml:cifar10-data:1 또는 path: azureml:cifar10-data@latest).
mode string 컴퓨팅 대상에 데이터를 제공하는 방법의 모드입니다.

읽기 전용 탑재(ro_mount)의 경우 데이터는 탑재 경로로 사용됩니다. 폴더가 폴더로 탑재되고 파일이 파일로 탑재됩니다. Azure Machine Learning은 탑재 경로에 대한 입력을 확인합니다.

모드의 경우 download 데이터는 컴퓨팅 대상으로 다운로드됩니다. Azure Machine Learning은 다운로드한 경로에 대한 입력을 확인합니다.

데이터 자체를 탑재하거나 다운로드하는 대신 데이터 아티팩트 스토리지 위치의 URL만 원하는 경우 모드를 direct 사용할 수 있습니다. 이 모드는 스토리지 위치의 URL을 작업 입력으로 전달합니다. 이 경우 스토리지에 액세스하기 위한 자격 증명을 처리하는 것은 사용자의 책임입니다.

eval_mount 모드는 eval_download MLTable에 고유하며 데이터를 경로로 탑재하거나 컴퓨팅 대상에 데이터를 다운로드합니다.

모드에 대한 자세한 내용은 작업의 Access 데이터를 참조하세요.
ro_mount, download, direct, eval_downloadeval_mount ro_mount

Job outputs

Key Type Description Allowed values Default value
type string 작업 출력의 형식입니다. 기본 uri_folder 형식의 경우 출력은 폴더에 해당합니다. uri_folder, , mlflow_modelcustom_model uri_folder
mode string 출력 파일이 대상 스토리지에 배달되는 방법의 모드입니다. 읽기/쓰기 탑재 모드(rw_mount)의 경우 출력 디렉터리가 탑재된 디렉터리입니다. 업로드 모드의 경우 작성된 파일은 작업이 끝날 때 업로드됩니다. rw_mount, upload rw_mount

Identity configurations

UserIdentityConfiguration

Key Type Description Allowed values
type const Required. Identity type. user_identity

ManagedIdentityConfiguration

Key Type Description Allowed values
type const Required. Identity type. managed 또는 managed_identity

AMLTokenIdentityConfiguration

Key Type Description Allowed values
type const Required. Identity type. 이 작업은 데이터 액세스를 위해 작업 영역의 Azure Machine Learning 토큰을 사용합니다. aml_token

Queue settings

Key Type Description Allowed values Default value
job_tier string 작업 계층입니다. spot 는 낮은 비용으로 선점 가능한 컴퓨팅을 사용합니다. spot, basic, standardpremium
priority string 선택한 계층 내의 예약 우선 순위입니다. low, , mediumhigh

Remarks

az ml job 명령은 Azure Machine Learning 작업을 관리하는 데 사용할 수 있습니다.

Examples

예제는 예제 GitHub 리포지토리에서 사용할 수 있습니다. 다음 섹션에서는 몇 가지 예제를 보여 줍니다.

YAML: 안녕하세요, 세상

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: echo "hello world"
environment:
  image: library/python:latest

YAML: 표시 이름, 실험 이름, 설명 및 태그

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: echo "hello world"
environment:
  image: library/python:latest
tags:
  hello: world
display_name: hello-world-example
experiment_name: hello-world-example
description: |
  # Azure Machine Learning "hello world" job

  This is a "hello world" job running in the cloud via Azure Machine Learning!

  ## Description

  Markdown is supported in the studio for job descriptions! You can edit the description there or via CLI.

YAML: 환경 변수

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: echo $hello_env_var
environment:
  image: library/python:latest
environment_variables:
  hello_env_var: "hello world"

YAML: 소스 코드

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: ls
code: src
environment:
  image: library/python:latest

YAML: 리터럴 입력

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: |
  echo ${{inputs.hello_string}}
  echo ${{inputs.hello_number}}
environment:
  image: library/python:latest
inputs:
  hello_string: "hello world"
  hello_number: 42

YAML: 기본 출력에 쓰기

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: echo "hello world" > ./outputs/helloworld.txt
environment:
  image: library/python:latest

YAML: 명명된 데이터 출력에 쓰기

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: echo "hello world" > ${{outputs.hello_output}}/helloworld.txt
outputs:
  hello_output:
environment:
  image: python

YAML: 데이터 저장소 URI 파일 입력

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: |
  echo "--iris-csv: ${{inputs.iris_csv}}"
  python hello-iris.py --iris-csv ${{inputs.iris_csv}}
code: src
inputs:
  iris_csv:
    type: uri_file 
    path: azureml://datastores/workspaceblobstore/paths/example-data/iris.csv
environment: azureml://registries/azureml/environments/sklearn-1.5/labels/latest

YAML: 데이터 저장소 URI 폴더 입력

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: |
  ls ${{inputs.data_dir}}
  echo "--iris-csv: ${{inputs.data_dir}}/iris.csv"
  python hello-iris.py --iris-csv ${{inputs.data_dir}}/iris.csv
code: src
inputs:
  data_dir:
    type: uri_folder 
    path: azureml://datastores/workspaceblobstore/paths/example-data/
environment: azureml://registries/azureml/environments/sklearn-1.5/labels/latest

YAML: URI 파일 입력

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: |
  echo "--iris-csv: ${{inputs.iris_csv}}"
  python hello-iris.py --iris-csv ${{inputs.iris_csv}}
code: src
inputs:
  iris_csv:
    type: uri_file 
    path: https://azuremlexamples.blob.core.windows.net/datasets/iris.csv
environment: azureml://registries/azureml/environments/sklearn-1.5/labels/latest

YAML: URI 폴더 입력

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: |
  ls ${{inputs.data_dir}}
  echo "--iris-csv: ${{inputs.data_dir}}/iris.csv"
  python hello-iris.py --iris-csv ${{inputs.data_dir}}/iris.csv
code: src
inputs:
  data_dir:
    type: uri_folder 
    path: wasbs://datasets@azuremlexamples.blob.core.windows.net/
environment: azureml://registries/azureml/environments/sklearn-1.5/labels/latest

YAML: 종이 머신을 통한 Notebook

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: |
  pip install ipykernel papermill
  papermill hello-notebook.ipynb outputs/out.ipynb -k python
code: src
environment:
  image: library/python:3.11.6

YAML: 기본 Python 모델 학습

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
code: src
command: >-
  python main.py 
  --iris-csv ${{inputs.iris_csv}}
  --C ${{inputs.C}}
  --kernel ${{inputs.kernel}}
  --coef0 ${{inputs.coef0}}
inputs:
  iris_csv: 
    type: uri_file
    path: wasbs://datasets@azuremlexamples.blob.core.windows.net/iris.csv
  C: 0.8
  kernel: "rbf"
  coef0: 0.1
environment: azureml://registries/azureml/environments/sklearn-1.5/labels/latest
compute: azureml:cpu-cluster
display_name: sklearn-iris-example
experiment_name: sklearn-iris-example
description: Train a scikit-learn SVM on the Iris dataset.

YAML: 로컬 Docker 빌드 컨텍스트를 사용하여 기본 R 모델 학습

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
command: >
  source /usr/venv/bin/activate
  Rscript train.R 
  --data_folder ${{inputs.iris}}
code: src
inputs:
  iris: 
    type: uri_file
    path: https://azuremlexamples.blob.core.windows.net/datasets/iris.csv
environment:
  build:
    path: docker-context
compute: azureml:cpu-cluster
display_name: r-iris-example
experiment_name: r-iris-example
description: Train an R model on the Iris dataset.

YAML: 분산 PyTorch

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
code: src
command: >-
  python train.py
  --epochs ${{inputs.epochs}}
  --learning-rate ${{inputs.learning_rate}}
  --data-dir ${{inputs.cifar}}
inputs:
  epochs: 1
  learning_rate: 0.2
  cifar:
     type: uri_folder
     path: azureml:cifar-10-example@latest
environment: azureml:AzureML-acpt-pytorch-2.8-cuda12.6@latest
compute: azureml:gpu-cluster
distribution:
  type: pytorch
  process_count_per_instance: 1
resources:
  instance_count: 2
display_name: pytorch-cifar-distributed-example
experiment_name: pytorch-cifar-distributed-example
description: Train a basic convolutional neural network (CNN) with PyTorch on the CIFAR-10 dataset, distributed via PyTorch.

YAML: 분산 TensorFlow

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
code: src
command: >-
  python train.py
  --epochs ${{inputs.epochs}}
  --model-dir ${{inputs.model_dir}}
inputs:
  epochs: 1
  model_dir: outputs/keras-model
environment: azureml:AzureML-tensorflow-2.16-cuda12@latest
compute: azureml:gpu-cluster
resources:
  instance_count: 2
distribution:
  type: tensorflow
  worker_count: 2
display_name: tensorflow-mnist-distributed-example
experiment_name: tensorflow-mnist-distributed-example
description: Train a basic neural network with TensorFlow on the MNIST dataset, distributed via TensorFlow.

Next steps