Command Component

Overview

A CommandComponent is a Component that executes a command in a docker container.

Scenarios

A CommandComponent could be used to execute any kinds of command, it covers the following typical scenarios:

  • Run a python script for data processing, machine learning, and other tasks;

  • Run an R script for data analytics, statistics, and other tasks;

  • Run a Linux executable or a shell script in a Linux container;

  • Run windows executable or a PowerShell script in a windows container; (Internal only as windows compute feature is internal only)

Limitation

  • The command should follow the command line constraint on the corresponding OS, in a Linux compute, it should follow Shell Command Language, in windows compute, it should follow Command-Line Reference;

  • Even a command does not use python, the image or the conda must contain the dependency “azureml-defaults” to run the command;

How to write CommandComponent yaml spec

Please refer to CommandComponent spec doc.

Please refer to CommandComponent Schema.

Example yaml:

$schema: https://componentsdk.azureedge.net/jsonschema/CommandComponent.json
name: microsoft.com.azureml.samples.train
version: 0.0.4
display_name: Train
type: CommandComponent
description: A dummy training module
tags: {category: Component Tutorial, contact: amldesigner@microsoft.com}
inputs:
  training_data:
    type: path
    description: Training data organized in the torchvision format/structure
    optional: false
  max_epochs:
    type: integer
    description: Maximum number of epochs for the training
    optional: false
  learning_rate:
    type: float
    description: Learning rate, default is 0.01
    default: 0.01
    optional: false
outputs:
  model_output:
    type: path
    description: The output model
command: >-
  python train.py --training_data {inputs.training_data} --max_epochs {inputs.max_epochs}
  --learning_rate {inputs.learning_rate} --model_output {outputs.model_output}
environment:
  conda:
    conda_dependencies:
      name: project_environment
      channels:
      - defaults
      dependencies:
      - python=3.6.8
      - pip=20.0
      - pip:
        - azureml-defaults
        - azureml-dataprep>=1.6
  os: Linux

Component command, which start with python interpreter path or python script, is considered commands to pass component commands. If you want to directly execute the python script by runpy, you can use CommandComponent@1-legacy as component type to force the use as python script style command.

In some scenarios, a component of CommandComponent will fail to execute because of passing incorrectly parameter. You can change component type to CommandComponent@1-legacy to handle this situation.

See more examples in github samples repo.

Samples

Follow how to access instructions if you meet 404 error when accessing the samples.

Appendix

In legacy module concept, this maps to basic jobType Module.