ModelOperations Class
ModelOperations.
You should not instantiate this class directly. Instead, you should create an MLClient instance that instantiates it for you and attaches it as an attribute.
- Inheritance
-
azure.ai.ml._scope_dependent_operations._ScopeDependentOperationsModelOperations
Constructor
ModelOperations(operation_scope: OperationScope, operation_config: OperationConfig, service_client: AzureMachineLearningWorkspaces | AzureMachineLearningWorkspaces, datastore_operations: DatastoreOperations, all_operations: OperationsContainer | None = None, **kwargs)
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
|
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>]
Service client to allow end users to operate on Azure Machine Learning Workspace resources (ServiceClient082023Preview or ServiceClient102021Dataplane). |
datastore_operations
Required
|
Represents a client for performing operations on Datastores. |
all_operations
|
<xref:azure.ai.ml._scope_dependent_operations.OperationsContainer>
All operations classes of an MLClient object. Default value: None
|
Methods
archive |
Archive a model asset. |
create_or_update |
Returns created or updated model asset. |
download |
Download files related to a model. |
get |
Returns information about the specified model asset. |
list |
List all model assets in workspace. |
package |
Note This is an experimental method, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information. Package a model asset |
restore |
Restore an archived model asset. |
share |
Note This is an experimental method, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information. Share a model asset from workspace to registry. |
archive
Archive a model asset.
archive(name: str, version: str | None = None, label: str | None = None, **kwargs: Any) -> None
Parameters
Name | Description |
---|---|
name
Required
|
Name of model asset. |
version
Required
|
Version of model asset. |
label
Required
|
Label of the model asset. (mutually exclusive with version) |
Examples
Archive a model.
ml_client.models.archive(name="model1", version="5")
create_or_update
Returns created or updated model asset.
create_or_update(model: Model | WorkspaceAssetReference) -> Model
Parameters
Name | Description |
---|---|
model
Required
|
Model asset object. |
Returns
Type | Description |
---|---|
Model asset object. |
Exceptions
Type | Description |
---|---|
Raised when the Model artifact path is already linked to another asset |
|
Raised if Model cannot be successfully validated. Details will be provided in the error message. |
|
Raised if local path provided points to an empty directory. |
download
Download files related to a model.
download(name: str, version: str, download_path: PathLike | str = '.') -> None
Parameters
Name | Description |
---|---|
name
Required
|
Name of the model. |
version
Required
|
Version of the model. |
download_path
Required
|
Local path as download destination, defaults to current working directory of the current user. Contents will be overwritten. |
Exceptions
Type | Description |
---|---|
ResourceNotFoundError
|
if can't find a model matching provided name. |
get
Returns information about the specified model asset.
get(name: str, version: str | None = None, label: str | None = None) -> Model
Parameters
Name | Description |
---|---|
name
Required
|
Name of the model. |
version
Required
|
Version of the model. |
label
Required
|
Label of the model. (mutually exclusive with version) |
Returns
Type | Description |
---|---|
Model asset object. |
Exceptions
Type | Description |
---|---|
Raised if Model cannot be successfully validated. Details will be provided in the error message. |
list
List all model assets in workspace.
list(name: str | None = None, stage: str | None = None, *, list_view_type: ListViewType = ListViewType.ACTIVE_ONLY) -> Iterable[Model]
Parameters
Name | Description |
---|---|
name
Required
|
Name of the model. |
stage
Required
|
The Model stage |
Keyword-Only Parameters
Name | Description |
---|---|
list_view_type
|
View type for including/excluding (for example) archived models. Defaults to <xref:ListViewType.ACTIVE_ONLY>. |
Returns
Type | Description |
---|---|
An iterator like instance of Model objects |
package
Note
This is an experimental method, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.
Package a model asset
package(name: str, version: str, package_request: ModelPackage, **kwargs: Any) -> Environment
Parameters
Name | Description |
---|---|
name
Required
|
Name of model asset. |
version
Required
|
Version of model asset. |
package_request
Required
|
Model package request. |
Returns
Type | Description |
---|---|
Environment object |
restore
Restore an archived model asset.
restore(name: str, version: str | None = None, label: str | None = None, **kwargs: Any) -> None
Parameters
Name | Description |
---|---|
name
Required
|
Name of model asset. |
version
Required
|
Version of model asset. |
label
Required
|
Label of the model asset. (mutually exclusive with version) |
Examples
Restore an archived model.
ml_client.models.restore(name="model1", version="5")
share
Note
This is an experimental method, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.
Share a model asset from workspace to registry.
share(name: str, version: str, *, share_with_name: str, share_with_version: str, registry_name: str) -> Model
Parameters
Name | Description |
---|---|
name
Required
|
Name of model asset. |
version
Required
|
Version of model asset. |
Keyword-Only Parameters
Name | Description |
---|---|
share_with_name
|
Name of model asset to share with. |
share_with_version
|
Version of model asset to share with. |
registry_name
|
Name of the destination registry. |
Returns
Type | Description |
---|---|
Model asset object. |
Azure SDK for Python