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

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

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

참고

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

YAML 구문

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

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

환경을 인라인으로 정의하려면 환경 스키마를 따릅니다. 인라인 환경에서 지원되지 않으므로 nameversion 속성을 제외합니다.
environment_variables object 명령이 실행되는 프로세스에 설정할 환경 변수 키-값 쌍의 사전입니다.
distribution object 분산된 학습 시나리오에 대한 배포 구성입니다. MpiConfiguration, PyTorchConfiguration, TensorFlowConfiguration 중 하나입니다.
compute 문자열 작업을 실행할 컴퓨팅 대상의 이름입니다. 이는 azureml:<compute_name> 구문을 사용하는 작업 영역의 기존 컴퓨팅에 대한 참조이거나 로컬 실행을 지정하는 local일 수 있습니다. 참고: 파이프라인의 작업은 localcompute로 지원하지 않았습니다. local
resources.instance_count 정수 작업에 사용할 노드 수입니다. 1
resources.instance_type 문자열 작업에 사용할 인스턴스 유형입니다. Azure Arc 지원 Kubernetes 컴퓨팅(compute 필드에 지정된 컴퓨팅 대상이 type: kubernentes임)에서 실행되는 작업에 적용됩니다. 생략하면 Kubernetes 클러스터의 기본 인스턴스 유형이 기본값이 됩니다. 자세한 내용은 Kubernetes 인스턴스 유형 만들기 및 선택을 참조하세요.
resources.shm_size 문자열 Docker 컨테이너의 공유 메모리 블록 크기입니다. 이는 숫자가 0보다 커야 하고 단위는 b(바이트), k(킬로바이트), m(메가바이트) 또는 g(기가바이트) 중 하나일 수 있는 <number><unit> 형식이어야 합니다. 2g
limits.timeout 정수 작업을 실행할 수 있는 최대 시간(초)입니다. 이 한도에 도달하면 시스템은 작업을 취소합니다.
inputs object 작업에 대한 입력의 사전입니다. 키는 작업의 컨텍스트 내에서 입력에 대한 이름이고 값은 입력 값입니다.

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

${{ outputs.<output_name> }} 식을 사용하여 command에서 출력을 참조할 수 있습니다.
outputs.<output_name> object 개체를 비워 둘 수 있습니다. 이 경우 기본적으로 출력은 uri_folder 형식이 되고 Azure Machine Learning은 출력에 대한 출력 위치를 시스템에서 생성합니다. 출력 디렉터리에 대한 파일은 읽기-쓰기 탑재를 통해 작성됩니다. 출력에 대해 다른 모드를 지정하려면 작업 출력 사양이 포함된 개체를 제공합니다.
identity object ID는 데이터 액세스에 사용됩니다. UserIdentityConfiguration, ManagedIdentityConfiguration 또는 None일 수 있습니다. UserIdentityConfiguration인 경우 작업 제출자의 ID가 입력 데이터에 액세스하고 결과를 출력 폴더에 쓰는 데 사용됩니다. 그렇지 않으면 컴퓨팅 대상의 관리 ID가 사용됩니다.

배포 구성

MpiConfiguration

형식 Description 허용되는 값
type const 필수 요소. 배포 형식입니다. mpi
process_count_per_instance 정수 필수 요소. 작업에 대해 시작할 노드당 프로세스의 수입니다.

PyTorchConfiguration

형식 Description 허용되는 값 기본값
type const 필수 요소. 배포 형식입니다. pytorch
process_count_per_instance 정수 작업에 대해 시작할 노드당 프로세스의 수입니다. 1

TensorFlowConfiguration

형식 Description 허용되는 값 기본값
type const 필수 요소. 배포 형식입니다. tensorflow
worker_count 정수 작업에 대해 시작할 작업자 수입니다. 기본값은 resources.instance_count입니다.
parameter_server_count 정수 작업에 대해 시작할 매개 변수 서버의 수입니다. 0

작업 입력

형식 Description 허용되는 값 기본값
type 문자열 작업 입력의 형식입니다. 단일 파일 원본을 가리키는 입력 데이터의 경우 uri_file을 지정하거나 폴더 원본을 가리키는 입력 데이터의 경우 uri_folder를 지정합니다. uri_file, uri_folder, mlflow_model, custom_model uri_folder
path 문자열 입력으로 사용할 데이터의 경로입니다. 이는 다음과 같은 몇 가지 방법으로 지정할 수 있습니다.

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

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

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

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

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

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

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

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

작업 출력

형식 Description 허용되는 값 기본값
type 문자열 작업 출력의 형식입니다. 기본 uri_folder 형식의 경우 출력은 폴더에 해당합니다. uri_folder , mlflow_model, custom_model uri_folder
mode 문자열 출력 파일을 대상 스토리지에 제공하는 방법의 모드입니다. 읽기-쓰기 탑재 모드(rw_mount)의 경우 출력 디렉터리는 탑재된 디렉터리가 됩니다. 업로드 모드의 경우 작성된 파일은 작업 종료 시 업로드됩니다. rw_mount, upload rw_mount

ID 구성

UserIdentityConfiguration

형식 Description 허용되는 값
type const 필수 요소. ID 형식입니다. user_identity

ManagedIdentityConfiguration

형식 Description 허용되는 값
type const 필수 요소. ID 형식입니다. managed 또는 managed_identity

설명

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

예제는 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.0/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.0/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.0/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.0/labels/latest

YAML: 용지 제분소를 통한 노트북

$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.0/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: >
  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-pytorch-1.9-ubuntu18.04-py37-cuda11-gpu@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.4-ubuntu18.04-py37-cuda11-gpu@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.

YAML: 배포된 MPI

$schema: https://azuremlschemas.azureedge.net/latest/commandJob.schema.json
code: src
command: >-
  python train.py
  --epochs ${{inputs.epochs}}
inputs:
  epochs: 1
environment: azureml:AzureML-tensorflow-2.7-ubuntu20.04-py38-cuda11-gpu@latest
compute: azureml:gpu-cluster
resources:
  instance_count: 2
distribution:
  type: mpi
  process_count_per_instance: 1
display_name: tensorflow-mnist-distributed-horovod-example
experiment_name: tensorflow-mnist-distributed-horovod-example
description: Train a basic neural network with TensorFlow on the MNIST dataset, distributed via Horovod.

다음 단계