CommandComponent Class

Command component version, used to define a Command Component or Job.

Inheritance
azure.ai.ml.entities._component.component.Component
CommandComponent
azure.ai.ml.entities._job.parameterized_command.ParameterizedCommand
CommandComponent
azure.ai.ml.entities._component._additional_includes.AdditionalIncludesMixin
CommandComponent

Constructor

CommandComponent(*, name: str | None = None, version: str | None = None, description: str | None = None, tags: Dict | None = None, display_name: str | None = None, command: str | None = None, code: PathLike | str | None = None, environment: Environment | str | None = None, distribution: Dict | MpiDistribution | TensorFlowDistribution | PyTorchDistribution | RayDistribution | DistributionConfiguration | None = None, resources: JobResourceConfiguration | None = None, inputs: Dict | None = None, outputs: Dict | None = None, instance_count: int | None = None, is_deterministic: bool = True, additional_includes: List | None = None, properties: Dict | None = None, **kwargs: Any)

Keyword-Only Parameters

Name Description
name

The name of the Command job or component.

version

The version of the Command job or component.

description

The description of the component. Defaults to None.

tags

Tag dictionary. Tags can be added, removed, and updated. Defaults to None.

display_name

The display name of the component.

command

The command to be executed.

code

The source code to run the job. Can be a local path or "http:", "https:", or "azureml:" url pointing to a remote location.

environment

The environment that the job will run in.

distribution

The configuration for distributed jobs. Defaults to None.

resources

The compute resource configuration for the command.

inputs
Optional[dict[str, Union[ Input, str, bool, int, float, <xref:Enum>, ]]]

A mapping of input names to input data sources used in the job. Defaults to None.

outputs

A mapping of output names to output data sources used in the job. Defaults to None.

instance_count

The number of instances or nodes to be used by the compute target. Defaults to 1.

is_deterministic

Specifies whether the Command will return the same output given the same input. Defaults to True. When True, if a Command (component) is deterministic and has been run before in the current workspace with the same input and settings, it will reuse results from a previous submitted job when used as a node or step in a pipeline. In that scenario, no compute resources will be used.

default value: True
additional_includes

A list of shared additional files to be included in the component. Defaults to None.

properties

The job property dictionary. Defaults to None.

Examples

Creating a CommandComponent.


   from azure.ai.ml.entities import CommandComponent

   component = CommandComponent(
       name="sample_command_component_basic",
       display_name="CommandComponentBasic",
       description="This is the basic command component",
       tags={"tag": "tagvalue", "owner": "sdkteam"},
       version="1",
       outputs={"component_out_path": {"type": "uri_folder"}},
       command="echo Hello World",
       code="./src",
       environment="AzureML-sklearn-1.0-ubuntu20.04-py38-cpu:33",
   )

Methods

dump

Dump the component content into a file in yaml format.

dump

Dump the component content into a file in yaml format.

dump(dest: str | PathLike | IO, **kwargs: Any) -> None

Parameters

Name Description
dest
Required
Union[<xref:PathLike>, str, IO[AnyStr]]

The destination to receive this component's content. Must be either a path to a local file, or an already-open file stream. If dest is a file path, a new file will be created, and an exception is raised if the file exists. If dest is an open file, the file will be written to directly, and an exception will be raised if the file is not writable.

Attributes

base_path

The base path of the resource.

Returns

Type Description
str

The base path of the resource.

creation_context

The creation context of the resource.

Returns

Type Description

The creation metadata for the resource.

display_name

Display name of the component.

Returns

Type Description
str

Display name of the component.

distribution

The configuration for the distributed command component or job.

Returns

Type Description

The distribution configuration.

id

The resource ID.

Returns

Type Description

The global ID of the resource, an Azure Resource Manager (ARM) ID.

inputs

Inputs of the component.

Returns

Type Description

Inputs of the component.

instance_count

The number of instances or nodes to be used by the compute target.

Returns

Type Description
int

The number of instances or nodes.

is_deterministic

Whether the component is deterministic.

Returns

Type Description

Whether the component is deterministic

outputs

Outputs of the component.

Returns

Type Description

Outputs of the component.

resources

The compute resource configuration for the command component or job.

Returns

Type Description

The compute resource configuration for the command component or job.

type

Type of the component, default is 'command'.

Returns

Type Description
str

Type of the component.

version

Version of the component.

Returns

Type Description
str

Version of the component.