ComponentOperations 類別
ComponentOperations。
您不應該直接具現化此類別。 相反地,您應該建立 MLClient 實例,為您具現化它,並將它附加為屬性。
- 繼承
-
azure.ai.ml._scope_dependent_operations._ScopeDependentOperationsComponentOperations
建構函式
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>]
部署的預檢作業。
方法
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
參數
範例
封存元件範例。
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
參數
- 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
參數
傳回
指定的元件物件。
傳回類型
例外狀況
如果download_path指向不是空的現有目錄,就會引發 。 已識別並擷取。 錯誤訊息中將會提供詳細資料。
get
傳回指定元件的相關資訊。
get(name: str, version: str | None = None, label: str | None = None) -> Component
參數
傳回
指定的元件物件。
傳回類型
例外狀況
如果無法成功識別和擷取元件,則引發 。 錯誤訊息中將會提供詳細資料。
範例
取得元件範例。
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]
參數
- list_view_type
檢視類型,例如) 封存的元件,包括/排除 (。 預設值:ACTIVE_ONLY。
傳回
反覆運算器,例如元件物件的實例
傳回類型
範例
列出元件範例。
print(ml_client.components.list())
restore
還原封存的元件。
restore(name: str, version: str | None = None, label: str | None = None, **kwargs) -> None
參數
範例
還原元件範例。
ml_client.components.restore(name=component_example.name)
validate
注意
這是實驗性方法,隨時可能會變更。 請參閱 https://aka.ms/azuremlexperimental 以取得詳細資訊。
驗證指定的元件。 如果有內嵌定義的實體,例如環境、程式碼,則不會建立它們。
validate(component: Component | function, raise_on_failure: bool = False, **kwargs) -> ValidationResult
參數
傳回
所有驗證錯誤
傳回類型
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應