EnvironmentOperations 類別

EnvironmentOperations。

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

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

建構函式

EnvironmentOperations(operation_scope: OperationScope, operation_config: OperationConfig, service_client: AzureMachineLearningWorkspaces | AzureMachineLearningWorkspaces, all_operations: OperationsContainer, **kwargs: Any)

參數

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

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

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

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

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

服務用戶端可讓使用者在 Azure Machine Learning 工作區資源上運作, (ServiceClient042023Preview 或 ServiceClient102021Dataplane) 。

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

MLClient 物件的所有作業類別。

方法

archive

封存環境或環境版本。

create_or_update

傳回已建立或更新的環境資產。

get

傳回指定的環境資產。

list

列出工作區中的所有環境資產。

restore

還原封存的環境版本。

share

注意

這是實驗性方法,可以隨時變更。 請參閱 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.environments.archive("create-environment", "2.0")

create_or_update

傳回已建立或更新的環境資產。

create_or_update(environment: Environment) -> Environment

參數

environment
<xref:azure.ai.ml.entities._assets.Environment>
必要

環境物件

傳回

已建立或更新的環境物件

傳回類型

例外狀況

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

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

範例

建立環境。


   from azure.ai.ml.entities import BuildContext, Environment

   env_docker_context = Environment(
       build=BuildContext(
           path="./sdk/ml/azure-ai-ml/tests/test_configs/environment/environment_files",
           dockerfile_path="DockerfileNonDefault",
       ),
       name="create-environment",
       version="2.0",
       description="Environment created from a Docker context.",
   )
   ml_client.environments.create_or_update(env_docker_context)

get

傳回指定的環境資產。

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

參數

name
str
必要

環境的名稱。

version
str
必要

環境的版本。

label
str
必要

環境的標籤。 (與版本) 互斥

傳回

環境物件

傳回類型

例外狀況

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

範例

取得範例。


   ml_client.environments.get("create-environment", "2.0")

list

列出工作區中的所有環境資產。

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

參數

name
Optional[str]
必要

環境的名稱。

list_view_type

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

傳回

環境物件的實例之類的反覆運算器。

傳回類型

範例

清單範例。


   ml_client.environments.list()

restore

還原封存的環境版本。

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

參數

name
str
必要

環境的名稱。

version
str
必要

環境的版本。

label
str
必要

環境的標籤。 (與版本) 互斥

範例

還原範例。


   ml_client.environments.restore("create-environment", "2.0")

share

注意

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

從工作區共用環境資產到登錄。

share(name: str, version: str, *, share_with_name: str, share_with_version: str, registry_name: str) -> Environment

參數

name
str
必要

環境資產的名稱。

version
str
必要

環境資產的版本。

share_with_name
str

要共用的環境資產名稱。

share_with_version
str

要共用的環境資產版本。

registry_name
str

目的地登錄的名稱。

傳回

環境資產物件。

傳回類型