Understanding Components
This lesson explains what a component packages, how its typed inputs and outputs form an interface, which component types exist, and how pipelines use components.
Learning outcomes
After completing this lesson, you will be able to:
- Describe what a component contains.
- Explain input and output placeholders in a component command.
- Identify the component types.
- Describe how pipelines reference components.
What a component is
A component is to a pipeline what a function is to a program: a named piece of work with declared inputs and outputs that can be called from many places. It packages the code to run, the command that runs it, the environment it needs, and an interface of typed inputs and outputs. A data preparation component, for example, might take a raw data folder and a date range and produce a cleaned dataset.
Because a component declares its interface, it can be developed, tested and versioned independently of the pipelines that use it. One team can publish a validated feature engineering component, and many pipelines can use version 3 of it while the team works on version 4. This is the main reason components exist: they turn copy-and-paste scripts into shared, versioned building blocks.
The interface: inputs and outputs
Inputs and outputs are typed. Data types such as uri_file, uri_folder, mltable, mlflow_model and custom_model describe what flows between steps. Primitive types such as integer, number, string and boolean describe parameters, with defaults, minimums, maximums and allowed values where useful.
The command uses the interface through placeholders. ${{inputs.learning_rate}} is replaced with the parameter's value, and ${{inputs.training_data}} and ${{outputs.model}} are replaced with paths where the data is mounted or downloaded and where outputs are written. The script reads its arguments as ordinary command-line arguments, so it can also be run and tested locally.
| Element | Example | Purpose |
|---|---|---|
| Data input | training_data: {type: uri_folder} | Data the step reads |
| Parameter | learning_rate: {type: number, default: 0.01} | A setting the step uses |
| Optional input | class_weights: {type: string, optional: true} | A value the caller may omit |
| Output | model: {type: mlflow_model} | Data or a model the step produces |
Component types
Most components are command components, which run a command in a container. Other types handle specific patterns.
- Command: runs a script or command, optionally distributed across nodes.
- Pipeline: a pipeline packaged as a component, so that a whole subgraph can be reused or deployed to a batch endpoint.
- Parallel: splits input data into mini-batches and processes them in parallel across nodes, used for large-scale scoring and processing.
- Spark: runs PySpark code on serverless Spark compute or an attached Synapse Spark pool.
Microsoft also publishes ready-made components in the azureml registry, such as the Responsible AI dashboard components and feature store retrieval components, which pipelines use in the same way as their own.
Components, jobs and pipelines
A component is a definition, not a run. Using it in a pipeline creates a step, a job that runs the component with specific input values and compute. The same component can appear in several pipelines, or twice in one pipeline with different parameters.
From duplicated scripts to components
Four teams each copied the same 300-line data validation script into their training pipelines. A bug fix to the script last month reached only two of the pipelines. The company wants one maintained implementation that every pipeline uses, with the ability to adopt fixes deliberately.
Package the validation script as a command component with typed inputs and outputs, register it, and preferably publish it to an Azure Machine Learning registry so that every team's workspace can use it. Each pipeline references the component by name and version. A fix is released as a new version, and teams move to it by changing the version in their pipeline definition after testing.
A shared Git submodule would share code but not the environment or interface, and pipelines would still need their own step definitions. Referencing the latest version automatically would spread fixes immediately but also any new bug, which removes the deliberate adoption the company wants.
How does a component's command receive the path of its input data?
Show answer
Through an input placeholder such as ${{inputs.training_data}} in the command. At run time, Azure Machine Learning replaces it with the mounted or downloaded path.
Exam Tips
Remember for the exam
- A component packages code, command, environment and a typed interface.
- The command uses ${{inputs.name}} and ${{outputs.name}} placeholders.
- Component types: command, pipeline, parallel and Spark.
- Pipelines reference components by name and version.