ComponentOperations 類別

ComponentOperations。

您不應該直接具現化此類別。 相反地,您應該建立 MLClient 實例,為您具現化它,並將它附加為屬性。

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

建構函式

ComponentOperations(operation_scope: OperationScope, operation_config: OperationConfig, service_client: AzureMachineLearningWorkspaces | AzureMachineLearningWorkspaces, all_operations: OperationsContainer, preflight_operation: DeploymentsOperations | None = None, **kwargs: Dict)

參數

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

作業範圍。

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

作業組態。

service_client
Union[ <xref:azure.ai.ml._restclient.v2022_10_01.AzureMachineLearningWorkspaces>, <xref:azure.ai.ml._restclient.v2021_10_01_dataplanepreview.AzureMachineLearningWorkspaces>]
必要

API 作業的服務用戶端。

all_operations
<xref:azure.ai.ml._scope_dependent_operations.OperationsContainer>
必要

所有可用作業的容器。

preflight_operation
Optional[<xref:azure.ai.ml._vendor.azure_resources.operations.DeploymentsOperations>]
預設值: None

部署的預檢作業。

kwargs
Dict
必要

其他關鍵字引數。

方法

archive

封存元件。

create_or_update

建立或更新指定的元件。 如果有內嵌定義的實體,例如環境、程式碼,它們將會與元件一起建立。

download

注意

這是實驗性方法,隨時可能會變更。 請參閱 https://aka.ms/azuremlexperimental 以取得詳細資訊。

將指定的元件及其相依性下載至本機。 本機組件可用來在另一個工作區中建立元件,或用於離線開發。

get

傳回指定元件的相關資訊。

list

列出工作區的特定元件或元件。

restore

還原封存的元件。

validate

注意

這是實驗性方法,隨時可能會變更。 請參閱 https://aka.ms/azuremlexperimental 以取得詳細資訊。

驗證指定的元件。 如果有內嵌定義的實體,例如環境、程式碼,則不會建立它們。

archive

封存元件。

archive(name: str, version: str | None = None, label: str | None = None, **kwargs) -> None

參數

name
str
必要

元件的名稱。

version
str
必要

元件的版本。

label
str
必要

元件的標籤。 (與版本) 互斥。

範例

封存元件範例。


   ml_client.components.archive(name=component_example.name)

create_or_update

建立或更新指定的元件。 如果有內嵌定義的實體,例如環境、程式碼,它們將會與元件一起建立。

create_or_update(component: Component | function, version=None, *, skip_validation: bool = False, **kwargs) -> Component

參數

component
Union[Component, FunctionType]
必要

產生元件物件的元件物件或 mldesigner 元件函式

version
str
必要

要覆寫的元件版本。

skip_validation
bool

是否要在建立/更新元件之前略過驗證,預設為 False

傳回

指定的元件物件。

傳回類型

例外狀況

如果無法成功驗證 Component,則引發 。 錯誤訊息中將會提供詳細資料。

如果無法成功驗證元件資產 (,例如資料、程式碼、模型、環境) ,則引發。 錯誤訊息中將會提供詳細資料。

如果不支援元件類型,則會引發 。 錯誤訊息中將會提供詳細資料。

如果無法成功驗證元件模型,則引發 。 錯誤訊息中將會提供詳細資料。

如果提供的本機路徑指向空目錄,則會引發 。

範例

建立元件範例。


   from azure.ai.ml import load_component
   from azure.ai.ml.entities._component.component import Component

   component_example = load_component(
       source="./sdk/ml/azure-ai-ml/tests/test_configs/components/helloworld_component.yml",
       params_override=[{"version": "1.0.2"}],
   )
   component = ml_client.components.create_or_update(component_example)

download

注意

這是實驗性方法,隨時可能會變更。 請參閱 https://aka.ms/azuremlexperimental 以取得詳細資訊。

將指定的元件及其相依性下載至本機。 本機組件可用來在另一個工作區中建立元件,或用於離線開發。

download(name: str, download_path: PathLike | str = '.', *, version: str = None) -> None

參數

name
str
必要

程式碼元件的名稱。

download_path
str
必要

本機路徑作為下載目的地,預設為目前使用者目前的工作目錄。 如果不存在,將會建立 。

version
Optional[str]

元件的版本。

傳回

指定的元件物件。

傳回類型

例外狀況

如果download_path指向不是空的現有目錄,就會引發 。 已識別並擷取。 錯誤訊息中將會提供詳細資料。

get

傳回指定元件的相關資訊。

get(name: str, version: str | None = None, label: str | None = None) -> Component

參數

name
str
必要

程式碼元件的名稱。

version
Optional[str]
必要

元件的版本。

label
Optional[str]
必要

元件的標籤,與版本互斥。

傳回

指定的元件物件。

傳回類型

例外狀況

如果無法成功識別和擷取元件,則引發 。 錯誤訊息中將會提供詳細資料。

範例

取得元件範例。


   ml_client.components.get(name=component_example.name, version="1.0.2")

list

列出工作區的特定元件或元件。

list(name: str | None = None, *, list_view_type: ListViewType = ListViewType.ACTIVE_ONLY) -> Iterable[Component]

參數

name
Optional[str]
必要

如果未設定元件名稱,請列出工作區的所有元件

list_view_type

檢視類型,例如) 封存的元件,包括/排除 (。 預設值:ACTIVE_ONLY。

傳回

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

傳回類型

範例

列出元件範例。


   print(ml_client.components.list())

restore

還原封存的元件。

restore(name: str, version: str | None = None, label: str | None = None, **kwargs) -> None

參數

name
str
必要

元件的名稱。

version
str
必要

元件的版本。

label
str
必要

元件的標籤。 (與版本) 互斥。

範例

還原元件範例。


   ml_client.components.restore(name=component_example.name)

validate

注意

這是實驗性方法,隨時可能會變更。 請參閱 https://aka.ms/azuremlexperimental 以取得詳細資訊。

驗證指定的元件。 如果有內嵌定義的實體,例如環境、程式碼,則不會建立它們。

validate(component: Component | function, raise_on_failure: bool = False, **kwargs) -> ValidationResult

參數

component
Union[Component, FunctionType]
必要

產生元件物件的元件物件或 mldesigner 元件函式

raise_on_failure
bool
必要

是否要在驗證錯誤時引發例外狀況。 預設為 False

傳回

所有驗證錯誤

傳回類型