Install & Compatibility
Where this runs
tested against v0.9.18.post2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.940 runs
installs and imports cleanly · install 0.0s · import 10.379s · 305.9MB
glibcpy 3.10–3.940 runs
installs and imports cleanly · install 17.8s · import 9.594s · 377MB
359MB installed
● package 359MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
CommandComponent
✓ from azure.ml.component import CommandComponent
✗ from azure.ml.component import CommandComponent
This quickstart demonstrates defining a basic command component using the `azure.ai.ml` SDK, which is the recommended way to interact with Azure Machine Learning components. Although `azure-ml-component` provides underlying classes, direct usage is uncommon. This example defines a component that takes a string input and writes a processed string to an output file. To actually register and run this component, an `MLClient` connected to an Azure ML Workspace would be required (commented out for quickstart runnability).
import os
from azure.ai.ml import command, Input, Output
from azure.ai.ml.entities import CommandComponent
# Define a simple command component using the recommended azure.ai.ml SDK
# This component takes an input string and produces an output string.
# For this example, we'll define a simple Python script as the command source
component_script_content = """
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--input_data", type=str)
parser.add_argument("--output_data", type=str)
args = parser.parse_args()
print(f"Received input: {args.input_data}")
with open(args.output_data, "w") as f:
f.write(f"Processed: {args.input_data.upper()}")
print(f"Wrote output to {args.output_data}")
"""
# Create a temporary directory and save the script
import tempfile
import shutil
with tempfile.TemporaryDirectory() as temp_dir:
script_path = os.path.join(temp_dir, "process.py")
with open(script_path, "w") as f:
f.write(component_script_content)
# Define the command component
hello_world_component = command(
name="hello_world_component",
display_name="Hello World Component Example",
description="A simple component that processes input text.",
inputs={
"input_data": Input(type="string", description="Input string for processing")
},
outputs={
"output_data": Output(type="uri_file", description="Processed output string")
},
command=f"python {{inputs.script_path}}/process.py --input_data {{inputs.input_data}} --output_data {{outputs.output_data}}",
environment=dict(
conda_file=os.path.join(temp_dir, "conda_env.yml"),
image="mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04:latest"
),
code=temp_dir
)
print("\n--- Component Definition ---")
print(hello_world_component.as_dict())
# To actually run this, you would need an MLClient connected to an Azure ML workspace.
# from azure.ai.ml import MLClient
# from azure.identity import DefaultAzureCredential
# ml_client = MLClient(
# DefaultAzureCredential(),
# subscription_id=os.environ.get("AZURE_SUBSCRIPTION_ID", ""),
# resource_group_name=os.environ.get("AZURE_RESOURCE_GROUP", ""),
# workspace_name=os.environ.get("AZURE_WORKSPACE_NAME", "")
# )
# registered_component = ml_client.components.create_or_update(hello_world_component)
# print(f"Component registered with name: {registered_component.name}, version: {registered_component.version}")
Upgrade
Version history
0.9.18.post2latest on PyPI · released May 12, 2023
Audit
Dependencies
azure-corerequiredCore Azure SDK functionalities
azure-storage-blobrequiredBlob storage interactions for component assets
pyyamlrequiredYAML parsing for component definitions