다음을 통해 공유


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 구문

형식 설명 허용된 값 기본값
$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 개체 작업에 대한 태그 사전입니다.
command string 실행할 명령입니다.
code string 업로드하여 작업에 사용할 소스 코드 디렉터리의 로컬 경로입니다.
environment 문자열 또는 개체 작업에 사용할 환경입니다. 작업 영역의 기존 버전이 지정된 환경에 대한 참조이거나 인라인 환경 사양일 수 있습니다.

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

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

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

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

배포 구성

MpiConfiguration

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

PyTorchConfiguration

형식 설명 허용된 값 Default value
type const 필수입니다. 배포 형식입니다. pytorch
process_count_per_instance 정수 작업에 대해 시작할 노드당 프로세스의 수입니다. 1

TensorFlowConfiguration

형식 설명 허용된 값 Default value
type const 필수입니다. 배포 형식입니다. tensorflow
worker_count 정수 작업에 대해 시작할 작업자 수입니다. 기본값은 resources.instance_count입니다.
parameter_server_count 정수 작업에 대해 시작할 매개 변수 서버의 수입니다. 0

작업 입력

형식 설명 허용된 값 기본값
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입니다. 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 string 컴퓨팅 대상에 데이터를 제공하는 방법의 모드입니다.

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

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

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

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

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

작업 출력

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

ID 구성

UserIdentityConfiguration

형식 설명 허용된 값
type const 필수입니다. ID 유형입니다. user_identity

ManagedIdentityConfiguration

형식 설명 허용된 값
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.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: 용지 제분소를 통한 노트북

$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: >
  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.2-cuda12.1@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.12-cuda11@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.12-cuda11@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.

다음 단계