ComputeOperations 類別

ComputeOperations。

不應該直接具現化這個類別。 請改用 MLClient 物件的 計算 屬性。

繼承
azure.ai.ml._scope_dependent_operations._ScopeDependentOperations
ComputeOperations

建構函式

ComputeOperations(operation_scope: OperationScope, operation_config: OperationConfig, service_client: AzureMachineLearningWorkspaces, **kwargs: Dict)

參數

operation_scope
<xref:azure.ai.ml._scope_dependent_operations.OperationScope>
必要

MLClient 物件的作業類別範圍變數。

operation_config
<xref:azure.ai.ml._scope_dependent_operations.OperationConfig>
必要

MLClient 物件的作業類別的常見組態。

service_client
<xref:azure.ai.ml._restclient.v2023_02_01_preview.AzureMachineLearningWorkspaces>
必要

服務用戶端可讓使用者在 Azure Machine Learning 工作區資源上運作。

方法

begin_attach

將計算資源附加至工作區。

begin_create_or_update

建立和註冊計算資源。

begin_delete

刪除或卸離計算資源。

begin_restart

重新開機計算實例。

begin_start

啟動計算實例。

begin_stop

停止計算實例。

begin_update

更新計算資源。 目前僅適用于 AmlCompute 資源類型。

get

取得計算資源。

list

列出工作區的計算。

list_nodes

擷取計算資源節點的清單。

list_sizes

列出位置中支援的 VM 大小。

list_usage

列出指定訂用帳戶和位置的目前使用量資訊,以及 AzureML 資源限制。

begin_attach

將計算資源附加至工作區。

begin_attach(compute: Compute, **kwargs: Any) -> LROPoller[Compute]

參數

compute
Compute
必要

計算資源定義。

傳回

LROPoller 的實例,一旦長時間執行的作業完成,就會傳回 Compute 物件。

傳回類型

範例

將計算資源附加至工作區。


   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

建立和註冊計算資源。

begin_create_or_update(compute: Compute) -> LROPoller[Compute]

參數

compute
Compute
必要

計算資源定義。

傳回

LROPoller 的實例,一旦長時間執行的作業完成,就會傳回 Compute 物件。

傳回類型

範例

建立和註冊計算資源。


   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

刪除或卸離計算資源。

begin_delete(name: str, *, action: str = 'Delete') -> LROPoller[None]

參數

name
str
必要

計算資源的名稱。

action

要執行的動作。 可能的值:[「Delete」, 「Detach」]。 預設為 「Delete」。

傳回

用來追蹤作業狀態的輪詢器。

傳回類型

範例

刪除計算範例。


   ml_client.compute.begin_delete(compute_name_1, action="Detach")

   ml_client.compute.begin_delete(compute_name_2)

begin_restart

重新開機計算實例。

begin_restart(name: str) -> LROPoller[None]

參數

name
str
必要

計算實例的名稱。

傳回

用來追蹤作業狀態的輪詢器。

傳回類型

範例

重新開機已停止的計算實例。


   ml_client.compute.begin_restart(ci_name)

begin_start

啟動計算實例。

begin_start(name: str) -> LROPoller[None]

參數

name
str
必要

計算實例的名稱。

傳回

用來追蹤作業狀態的輪詢器。

傳回類型

範例

啟動計算實例。


   ml_client.compute.begin_start(ci_name)

begin_stop

停止計算實例。

begin_stop(name: str) -> LROPoller[None]

參數

name
str
必要

計算實例的名稱。

傳回

用來追蹤作業狀態的輪詢器。

傳回類型

範例

停止計算實例。


   ml_client.compute.begin_stop(ci_name)

begin_update

更新計算資源。 目前僅適用于 AmlCompute 資源類型。

begin_update(compute: Compute) -> LROPoller[Compute]

參數

compute
Compute
必要

計算資源定義。

傳回

LROPoller 的實例,一旦長時間執行的作業完成,就會傳回 Compute 物件。

傳回類型

範例

更新 AmlCompute 資源。


   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)

get

取得計算資源。

get(name: str) -> Compute

參數

name
str
必要

計算資源的名稱。

傳回

計算物件。

傳回類型

範例

從工作區擷取計算資源。


   cpu_cluster = ml_client.compute.get("cpu-cluster")

list

列出工作區的計算。

list(*, compute_type: str | None = None) -> Iterable[Compute]

參數

compute_type
Optional[str]

要列出的計算類型,不區分大小寫。 預設為 AMLCompute。

傳回

反覆運算器,例如 Compute 物件的實例。

傳回類型

範例

擷取工作區中 AzureML Kubernetes 計算資源的清單。


   compute_list = ml_client.compute.list(compute_type="AMLK8s")  # cspell:disable-line

list_nodes

擷取計算資源節點的清單。

list_nodes(name: str) -> Iterable[AmlComputeNodeInfo]

參數

name
str
必要

計算資源的名稱。

傳回

AmlComputeNodeInfo 物件的類似反覆運算器實例。

傳回類型

範例

從計算資源擷取節點清單。


   node_list = ml_client.compute.list_nodes(name="cpu-cluster")

list_sizes

列出位置中支援的 VM 大小。

list_sizes(*, location: str | None = None, compute_type: str | None = None) -> Iterable[VmSize]

參數

location
str

查詢虛擬機器大小的位置。 預設為工作區位置。

compute_type
Optional[str]

要列出的計算類型,不區分大小寫。 預設為 AMLCompute。

傳回

虛擬機器大小物件的反覆運算器。

傳回類型

範例

列出工作區位置中支援的 VM 大小。


   size_list = ml_client.compute.list_sizes()

list_usage

列出指定訂用帳戶和位置的目前使用量資訊,以及 AzureML 資源限制。

list_usage(*, location: str | None = None) -> Iterable[Usage]

參數

location
Optional[str]

查詢資源使用量的位置。 預設為工作區位置。

傳回

目前使用量資訊物件的反覆運算器。

傳回類型

範例

列出工作區位置的資源使用量。


   usage_list = ml_client.compute.list_usage()