ComputeOperations Class
ComputeOperations.
This class should not be instantiated directly. Instead, use the compute attribute of an MLClient object.
- Inheritance
-
azure.ai.ml._scope_dependent_operations._ScopeDependentOperationsComputeOperations
Constructor
ComputeOperations(operation_scope: OperationScope, operation_config: OperationConfig, service_client: AzureMachineLearningWorkspaces, service_client_2024: AzureMachineLearningWorkspaces, **kwargs: Dict)
Parameters
Name | Description |
---|---|
operation_scope
Required
|
<xref:azure.ai.ml._scope_dependent_operations.OperationScope>
Scope variables for the operations classes of an MLClient object. |
operation_config
Required
|
<xref:azure.ai.ml._scope_dependent_operations.OperationConfig>
Common configuration for operations classes of an MLClient object. |
service_client
Required
|
<xref:azure.ai.ml._restclient.v2023_02_01_preview.AzureMachineLearningWorkspaces>
Service client to allow end users to operate on Azure Machine Learning Workspace resources. |
service_client_2024
Required
|
|
Methods
begin_attach |
Attach a compute resource to the workspace. |
begin_create_or_update |
Create and register a compute resource. |
begin_delete |
Delete or detach a compute resource. |
begin_restart |
Restart a compute instance. |
begin_start |
Start a compute instance. |
begin_stop |
Stop a compute instance. |
begin_update |
Update a compute resource. Currently only valid for AmlCompute resource types. |
enable_sso |
Note This is an experimental method, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information. enable sso for a compute instance. |
get |
Get a compute resource. |
list |
List computes of the workspace. |
list_nodes |
Retrieve a list of a compute resource's nodes. |
list_sizes |
List the supported VM sizes in a location. |
list_usage |
List the current usage information as well as AzureML resource limits for the given subscription and location. |
begin_attach
Attach a compute resource to the workspace.
begin_attach(compute: Compute, **kwargs: Any) -> LROPoller[Compute]
Parameters
Name | Description |
---|---|
compute
Required
|
The compute resource definition. |
Returns
Type | Description |
---|---|
An instance of LROPoller that returns a Compute object once the long-running operation is complete. |
Examples
Attaching a compute resource to the workspace.
from azure.ai.ml.entities import AmlCompute
compute_obj = AmlCompute(
name=compute_name_2,
tags={"key1": "value1", "key2": "value2"},
min_instances=0,
max_instances=10,
idle_time_before_scale_down=100,
)
attached_compute = ml_client.compute.begin_attach(compute_obj)
begin_create_or_update
Create and register a compute resource.
begin_create_or_update(compute: Compute) -> LROPoller[Compute]
Parameters
Name | Description |
---|---|
compute
Required
|
The compute resource definition. |
Returns
Type | Description |
---|---|
An instance of LROPoller that returns a Compute object once the long-running operation is complete. |
Examples
Creating and registering a compute resource.
from azure.ai.ml.entities import AmlCompute
compute_obj = AmlCompute(
name=compute_name_1,
tags={"key1": "value1", "key2": "value2"},
min_instances=0,
max_instances=10,
idle_time_before_scale_down=100,
)
registered_compute = ml_client.compute.begin_create_or_update(compute_obj)
begin_delete
Delete or detach a compute resource.
begin_delete(name: str, *, action: str = 'Delete') -> LROPoller[None]
Parameters
Name | Description |
---|---|
name
Required
|
The name of the compute resource. |
Keyword-Only Parameters
Name | Description |
---|---|
action
|
Action to perform. Possible values: ["Delete", "Detach"]. Defaults to "Delete". |
Returns
Type | Description |
---|---|
A poller to track the operation status. |
Examples
Delete compute example.
ml_client.compute.begin_delete(compute_name_1, action="Detach")
ml_client.compute.begin_delete(compute_name_2)
begin_restart
Restart a compute instance.
begin_restart(name: str) -> LROPoller[None]
Parameters
Name | Description |
---|---|
name
Required
|
The name of the compute instance. |
Returns
Type | Description |
---|---|
A poller to track the operation status. |
Examples
Restarting a stopped compute instance.
ml_client.compute.begin_restart(ci_name)
begin_start
Start a compute instance.
begin_start(name: str) -> LROPoller[None]
Parameters
Name | Description |
---|---|
name
Required
|
The name of the compute instance. |
Returns
Type | Description |
---|---|
A poller to track the operation status. |
Examples
Starting a compute instance.
ml_client.compute.begin_start(ci_name)
begin_stop
Stop a compute instance.
begin_stop(name: str) -> LROPoller[None]
Parameters
Name | Description |
---|---|
name
Required
|
The name of the compute instance. |
Returns
Type | Description |
---|---|
A poller to track the operation status. |
Examples
Stopping a compute instance.
ml_client.compute.begin_stop(ci_name)
begin_update
Update a compute resource. Currently only valid for AmlCompute resource types.
begin_update(compute: Compute) -> LROPoller[Compute]
Parameters
Name | Description |
---|---|
compute
Required
|
The compute resource definition. |
Returns
Type | Description |
---|---|
An instance of LROPoller that returns a Compute object once the long-running operation is complete. |
Examples
Updating an AmlCompute resource.
compute_obj = ml_client.compute.get("cpu-cluster")
compute_obj.idle_time_before_scale_down = 200
updated_compute = ml_client.compute.begin_update(compute_obj)
enable_sso
Note
This is an experimental method, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.
enable sso for a compute instance.
enable_sso(*, name: str, enable_sso: bool = True) -> None
Keyword-Only Parameters
Name | Description |
---|---|
name
|
Name of the compute instance. |
enable_sso
|
enable sso bool flag Default to True |
get
Get a compute resource.
get(name: str) -> Compute
Parameters
Name | Description |
---|---|
name
Required
|
Name of the compute resource. |
Returns
Type | Description |
---|---|
A Compute object. |
Examples
Retrieving a compute resource from a workspace.
cpu_cluster = ml_client.compute.get("cpu-cluster")
list
List computes of the workspace.
list(*, compute_type: str | None = None) -> Iterable[Compute]
Keyword-Only Parameters
Name | Description |
---|---|
compute_type
|
The type of the compute to be listed, case-insensitive. Defaults to AMLCompute. |
Returns
Type | Description |
---|---|
An iterator like instance of Compute objects. |
Examples
Retrieving a list of the AzureML Kubernetes compute resources in a workspace.
compute_list = ml_client.compute.list(compute_type="AMLK8s") # cspell:disable-line
list_nodes
Retrieve a list of a compute resource's nodes.
list_nodes(name: str) -> Iterable[AmlComputeNodeInfo]
Parameters
Name | Description |
---|---|
name
Required
|
Name of the compute resource. |
Returns
Type | Description |
---|---|
An iterator-like instance of AmlComputeNodeInfo objects. |
Examples
Retrieving a list of nodes from a compute resource.
node_list = ml_client.compute.list_nodes(name="cpu-cluster")
list_sizes
List the supported VM sizes in a location.
list_sizes(*, location: str | None = None, compute_type: str | None = None) -> Iterable[VmSize]
Keyword-Only Parameters
Name | Description |
---|---|
location
|
The location upon which virtual-machine-sizes is queried. Defaults to workspace location. |
compute_type
|
The type of the compute to be listed, case-insensitive. Defaults to AMLCompute. |
Returns
Type | Description |
---|---|
An iterator over virtual machine size objects. |
Examples
Listing the supported VM sizes in the workspace location.
size_list = ml_client.compute.list_sizes()
list_usage
List the current usage information as well as AzureML resource limits for the given subscription and location.
list_usage(*, location: str | None = None) -> Iterable[Usage]
Keyword-Only Parameters
Name | Description |
---|---|
location
|
The location for which resource usage is queried. Defaults to workspace location. |
Returns
Type | Description |
---|---|
An iterator over current usage info objects. |
Examples
Listing resource usage for the workspace location.
usage_list = ml_client.compute.list_usage()
Azure SDK for Python