Microsoft Azure Machine Learning Client Library for Python providing comprehensive SDK for ML workflows including job execution, pipeline components, model deployment, and AutoML capabilities
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
The MLClient class is the main entry point for all Azure Machine Learning operations. It provides a unified interface to interact with Azure ML services and manages authentication, workspace connections, and operation groups.
Creates the main client for Azure Machine Learning operations with credential and workspace configuration.
class MLClient:
def __init__(
self,
credential,
subscription_id: str = None,
resource_group_name: str = None,
workspace_name: str = None,
registry_name: str = None,
**kwargs
):
"""
Initialize MLClient for Azure ML operations.
Parameters:
- credential: Azure credential (DefaultAzureCredential, ClientSecretCredential, etc.)
- subscription_id: Azure subscription ID
- resource_group_name: Resource group containing the workspace
- workspace_name: Azure ML workspace name
- registry_name: Registry name (for registry operations)
- cloud: Cloud environment ("AzureCloud", "AzureChinaCloud", etc.)
- **kwargs: Additional configuration options
"""from azure.ai.ml import MLClient
from azure.identity import DefaultAzureCredential, ClientSecretCredential
# Using default credential (recommended for development)
ml_client = MLClient(
credential=DefaultAzureCredential(),
subscription_id="your-subscription-id",
resource_group_name="your-resource-group",
workspace_name="your-workspace"
)
# Using service principal authentication
credential = ClientSecretCredential(
tenant_id="your-tenant-id",
client_id="your-client-id",
client_secret="your-client-secret"
)
ml_client = MLClient(
credential=credential,
subscription_id="your-subscription-id",
resource_group_name="your-resource-group",
workspace_name="your-workspace"
)
# For registry operations
registry_client = MLClient(
credential=DefaultAzureCredential(),
subscription_id="your-subscription-id",
resource_group_name="your-resource-group",
registry_name="your-registry"
)MLClient organizes functionality into operation groups for different resource types.
class MLClient:
@property
def jobs(self) -> JobOperations: ...
@property
def models(self) -> ModelOperations: ...
@property
def data(self) -> DataOperations: ...
@property
def environments(self) -> EnvironmentOperations: ...
@property
def components(self) -> ComponentOperations: ...
@property
def compute(self) -> ComputeOperations: ...
@property
def datastores(self) -> DatastoreOperations: ...
@property
def workspaces(self) -> WorkspaceOperations: ...
@property
def online_endpoints(self) -> OnlineEndpointOperations: ...
@property
def batch_endpoints(self) -> BatchEndpointOperations: ...
@property
def online_deployments(self) -> OnlineDeploymentOperations: ...
@property
def batch_deployments(self) -> BatchDeploymentOperations: ...
@property
def schedules(self) -> ScheduleOperations: ...
@property
def connections(self) -> WorkspaceConnectionsOperations: ...
@property
def registries(self) -> RegistryOperations: ...
@property
def feature_sets(self) -> FeatureSetOperations: ...
@property
def feature_stores(self) -> FeatureStoreOperations: ...
@property
def feature_store_entities(self) -> FeatureStoreEntityOperations: ...
@property
def indexes(self) -> IndexOperations: ...
@property
def serverless_endpoints(self) -> ServerlessEndpointOperations: ...
@property
def marketplace_subscriptions(self) -> MarketplaceSubscriptionOperations: ...from azure.ai.ml import MLClient
from azure.identity import DefaultAzureCredential
ml_client = MLClient(
credential=DefaultAzureCredential(),
subscription_id="your-subscription-id",
resource_group_name="your-resource-group",
workspace_name="your-workspace"
)
# Access different operation groups
jobs = ml_client.jobs.list()
models = ml_client.models.list()
compute_targets = ml_client.compute.list()
environments = ml_client.environments.list()Utility functions for loading Azure ML entities from YAML files.
def load_job(source: str) -> Job:
"""Load job from YAML file."""
def load_model(source: str) -> Model:
"""Load model from YAML file."""
def load_data(source: str) -> Data:
"""Load data asset from YAML file."""
def load_environment(source: str) -> Environment:
"""Load environment from YAML file."""
def load_component(source: str) -> Component:
"""Load component from YAML file."""
def load_compute(source: str) -> Compute:
"""Load compute target from YAML file."""
def load_datastore(source: str) -> Datastore:
"""Load datastore from YAML file."""
def load_workspace(source: str) -> Workspace:
"""Load workspace from YAML file."""
def load_online_endpoint(source: str) -> OnlineEndpoint:
"""Load online endpoint from YAML file."""
def load_batch_endpoint(source: str) -> BatchEndpoint:
"""Load batch endpoint from YAML file."""
def load_online_deployment(source: str) -> OnlineDeployment:
"""Load online deployment from YAML file."""
def load_batch_deployment(source: str) -> BatchDeployment:
"""Load batch deployment from YAML file."""
def load_connection(source: str) -> WorkspaceConnection:
"""Load workspace connection from YAML file."""
def load_registry(source: str) -> Registry:
"""Load registry from YAML file."""
def load_feature_set(source: str) -> FeatureSet:
"""Load feature set from YAML file."""
def load_feature_store(source: str) -> FeatureStore:
"""Load feature store from YAML file."""
def load_feature_store_entity(source: str) -> FeatureStoreEntity:
"""Load feature store entity from YAML file."""
def load_index(source: str) -> Index:
"""Load index from YAML file."""
def load_serverless_endpoint(source: str) -> ServerlessEndpoint:
"""Load serverless endpoint from YAML file."""
def load_marketplace_subscription(source: str) -> MarketplaceSubscription:
"""Load marketplace subscription from YAML file."""
def load_capability_host(source: str) -> CapabilityHost:
"""Load capability host from YAML file."""
def load_model_package(source: str) -> ModelPackage:
"""Load model package from YAML file."""
def load_workspace_connection(source: str) -> WorkspaceConnection:
"""Load workspace connection from YAML file."""from azure.ai.ml import load_job, load_model, load_environment
# Load entities from YAML files
job = load_job("./job.yml")
model = load_model("./model.yml")
environment = load_environment("./environment.yml")
# Submit the loaded job
submitted_job = ml_client.jobs.create_or_update(job)class ValidationException(Exception):
"""Exception raised for validation errors."""
class ErrorCategory:
USER_ERROR = "UserError"
SYSTEM_ERROR = "SystemError"
UNKNOWN = "Unknown"
class ErrorTarget:
"""Error target constants for exception handling."""
class ValidationErrorType:
INVALID_VALUE = "INVALID VALUE"
UNKNOWN_FIELD = "UNKNOWN FIELD"
MISSING_FIELD = "MISSING FIELD"
FILE_OR_FOLDER_NOT_FOUND = "FILE OR FOLDER NOT FOUND"
CANNOT_SERIALIZE = "CANNOT DUMP"
CANNOT_PARSE = "CANNOT PARSE"
RESOURCE_NOT_FOUND = "RESOURCE NOT FOUND"
GENERIC = "GENERIC"Install with Tessl CLI
npx tessl i tessl/pypi-azure-ai-ml