DataOperations Class

DataOperations.

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._ScopeDependentOperations
DataOperations

Constructor

DataOperations(operation_scope: OperationScope, operation_config: OperationConfig, service_client: AzureMachineLearningWorkspaces | AzureMachineLearningWorkspaces, service_client_012024_preview: AzureMachineLearningWorkspaces, datastore_operations: DatastoreOperations, **kwargs: Any)

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 (ServiceClient042023Preview or ServiceClient102021Dataplane).

datastore_operations
Required

Represents a client for performing operations on Datastores.

service_client_012024_preview
Required

Methods

archive

Archive a data asset.

create_or_update

Returns created or updated data asset.

If not already in storage, asset will be uploaded to the workspace's blob storage.

get

Get the specified data asset.

import_data

Note

This is an experimental method, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.

Returns the data import job that is creating the data asset.

list

List the data assets of the workspace.

list_materialization_status

List materialization jobs of the asset.

mount

Note

This is an experimental method, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.

Mount a data asset to a local path, so that you can access data inside it under a local path with any tools of your choice.

restore

Restore an archived data 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 data asset from workspace to registry.

archive

Archive a data asset.

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

Parameters

Name Description
name
Required
str

Name of data asset.

version
Required
str

Version of data asset.

label
Required
str

Label of the data asset. (mutually exclusive with version)

Returns

Type Description

None

Examples

Archive data asset example.


   ml_client.data.archive("data_asset_name")

create_or_update

Returns created or updated data asset.

If not already in storage, asset will be uploaded to the workspace's blob storage.

create_or_update(data: Data) -> Data

Parameters

Name Description
data
Required

Data asset object.

Returns

Type Description

Data asset object.

Exceptions

Type Description

Raised when the Data artifact path is already linked to another asset

Raised if Data cannot be successfully validated. Details will be provided in the error message.

Raised if local path provided points to an empty directory.

Examples

Create data assets example.


   from azure.ai.ml.entities import Data

   data_asset_example = Data(name=data_asset_name, version="2.0", path="./sdk/ml/azure-ai-ml/samples/src")
   ml_client.data.create_or_update(data_asset_example)

get

Get the specified data asset.

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

Parameters

Name Description
name
Required
str

Name of data asset.

version
Required
str

Version of data asset.

label
Required
str

Label of the data asset. (mutually exclusive with version)

Returns

Type Description

Data asset object.

Exceptions

Type Description

Raised if Data cannot be successfully identified and retrieved. Details will be provided in the error message.

Examples

Get data assets example.


   ml_client.data.get(name="data_asset_name", version="2.0")

import_data

Note

This is an experimental method, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.

Returns the data import job that is creating the data asset.

import_data(data_import: DataImport, **kwargs: Any) -> PipelineJob

Parameters

Name Description
data_import
Required

DataImport object.

Returns

Type Description

data import job object.

Examples

Import data assets example.


   from azure.ai.ml.entities._data_import.data_import import DataImport
   from azure.ai.ml.entities._inputs_outputs.external_data import Database

   database_example = Database(query="SELECT ID FROM DataTable", connection="azureml:my_azuresqldb_connection")
   data_import_example = DataImport(
       name="data_asset_name", path="azureml://datastores/workspaceblobstore/paths/", source=database_example
   )
   ml_client.data.import_data(data_import_example)

list

List the data assets of the workspace.

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

Parameters

Name Description
name
Required

Name of a specific data asset, optional.

Keyword-Only Parameters

Name Description
list_view_type

View type for including/excluding (for example) archived data assets. Default: ACTIVE_ONLY.

Returns

Type Description

An iterator like instance of Data objects

Examples

List data assets example.


   ml_client.data.list(name="data_asset_name")

list_materialization_status

List materialization jobs of the asset.

list_materialization_status(name: str, *, list_view_type: ListViewType = ListViewType.ACTIVE_ONLY, **kwargs: Any) -> Iterable[PipelineJob]

Parameters

Name Description
name
Required
str

name of asset being created by the materialization jobs.

Keyword-Only Parameters

Name Description
list_view_type

View type for including/excluding (for example) archived jobs. Default: ACTIVE_ONLY.

Returns

Type Description

An iterator like instance of Job objects.

Examples

List materialization jobs example.


   ml_client.data.list_materialization_status("data_asset_name")

mount

Note

This is an experimental method, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.

Mount a data asset to a local path, so that you can access data inside it under a local path with any tools of your choice.

mount(path: str, mount_point: str | None = None, mode: str = 'ro_mount', debug: bool = False, persistent: bool = False, **_kwargs) -> None

Parameters

Name Description
path
Required
str

The data asset path to mount, in the form of azureml: or azureml::.

mount_point
Required
str

A local path used as mount point.

mode
Required
str

Mount mode. Only ro_mount (read-only) is supported for data asset mount.

debug
Required

Whether to enable verbose logging.

persistent
Required

Whether to persist the mount after reboot. Applies only when running on Compute Instance, where the 'CI_NAME' environment variable is set."

Returns

Type Description

None

restore

Restore an archived data asset.

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

Parameters

Name Description
name
Required
str

Name of data asset.

version
Required
str

Version of data asset.

label
Required
str

Label of the data asset. (mutually exclusive with version)

Returns

Type Description

None

Examples

Restore data asset example.


   ml_client.data.restore("data_asset_name")

share

Note

This is an experimental method, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.

Share a data asset from workspace to registry.

share(name: str, version: str, *, share_with_name: str, share_with_version: str, registry_name: str, **kwargs: Any) -> Data

Parameters

Name Description
name
Required
str

Name of data asset.

version
Required
str

Version of data asset.

Keyword-Only Parameters

Name Description
share_with_name
str

Name of data asset to share with.

share_with_version
str

Version of data asset to share with.

registry_name
str

Name of the destination registry.

Returns

Type Description

Data asset object.

Examples

Share data asset example.


       ml_client.data.share(
           name="data_asset_name",
           version="2.0",
           registry_name="my-registry",
           share_with_name="transformed-nyc-taxi-data-shared-from-ws",
           share_with_version="2.0",
       )