DataReference 類別

表示資料存放區中資料的參考。

DataReference 代表資料存放區中的路徑,可用來描述執行中應如何及何處提供資料。 它不再是 Azure Machine Learning 中資料存取和傳遞的建議方法。 資料集支援從 Azure Blob 儲存體、Azure 檔案儲存體、Azure Data Lake Storage Gen1、Azure Data Lake Storage Gen2、Azure SQL 資料庫和適用於 PostgreSQL 的 Azure 資料庫存取資料 透過整合介面與新增的資料管理功能。 建議您使用資料集來讀取機器學習專案中的資料。

如需如何在兩個常見案例中使用 Azure ML 資料集的詳細資訊,請參閱文章:

類別 DataReference 建構函式。

繼承
builtins.object
DataReference

建構函式

DataReference(datastore, data_reference_name=None, path_on_datastore=None, mode='mount', path_on_compute=None, overwrite=False)

參數

datastore
Union[AbstractAzureStorageDatastore, AzureDataLakeDatastore]
必要

要參考的資料存放區。

data_reference_name
str
預設值: None

資料參考的名稱。

path_on_datastore
str
預設值: None

支援儲存體中的資料參考相對路徑。

mode
str
預設值: mount

資料參考上的作業。 支援的值是 'mount' (預設) 和 'download'。

當您的腳本需要特定 (例如輸入資料的硬式編碼) 路徑時,請使用 「下載」模式。 在此情況下,當您宣告 DataReference 時,請使用 path_on_compute 參數指定路徑。 Azure Machine Learning 會在執行腳本之前,先下載該路徑所指定的資料。

使用 「掛接」模式,會使用掛接的資料建立臨時目錄,而環境變數$AZUREML_DATAREFERENCE_ < data_reference_name > 會設定臨時目錄的路徑。 如果您將 DataReference 傳遞至管線步驟的引數清單 (,例如 PythonScriptStep) ,則參考會在執行時間擴充至本機資料路徑。

path_on_compute
str
預設值: None

資料參考之計算目標上的路徑。

overwrite
bool
預設值: False

指出是否要覆寫現有的資料。

datastore
Union[AbstractAzureStorageDatastore, AzureDataLakeDatastore]
必要

要參考的資料存放區。

data_reference_name
str
必要

資料參考的名稱。

path_on_datastore
str
必要

支援儲存體中的資料參考相對路徑。

mode
str
必要

資料參考上的作業。 支援的值 'mount' (預設) 和 'download'。

當您的腳本需要特定 (例如輸入資料的硬式編碼) 路徑時,請使用 「下載」模式。 在此情況下,當您宣告 DataReference 時,請使用 path_on_compute 參數指定路徑。 Azure Machine Learning 會在執行腳本之前,先下載該路徑所指定的資料。

使用 「掛接」模式,會使用掛接的資料建立臨時目錄,而環境變數$AZUREML_DATAREFERENCE_ < data_reference_name > 會設定臨時目錄的路徑。 如果您將 DataReference 傳遞至管線步驟的引數清單 (,例如 PythonScriptStep) ,則參考會在執行時間擴充至本機資料路徑。

path_on_compute
str
必要

資料參考之計算目標上的路徑。

overwrite
bool
必要

指出是否要覆寫現有的資料。

備註

DataReference 會定義資料位置,以及如何在目標計算系結上使用資料 (掛接或上傳) 。 資料存放區中資料的路徑可以是根 /、資料存放區內的目錄,或資料存放區中的檔案。

方法

as_download

切換要下載的資料參考作業。

DataReference 下載僅支援 Azure Blob 和 Azure 檔案共用。 若要從 Azure Blob、Azure 檔案共用、Azure Data Lake Gen1 和 Azure Data Lake Gen2 下載資料,建議您使用 Azure Machine Learning 資料集。 如需如何建立和使用資料集的詳細資訊,請流覽 https://docs.microsoft.com/en-us/azure/machine-learning/how-to-train-with-datasets

as_mount

切換要掛接的資料參考作業。

DataReference 掛接僅支援 Azure Blob。 若要在 Azure Blob、Azure 檔案共用、Azure Data Lake Gen1 和 Azure Data Lake Gen2 中掛接資料,建議您使用 Azure Machine Learning 資料集。 如需如何建立和使用資料集的詳細資訊,請流覽 https://docs.microsoft.com/en-us/azure/machine-learning/how-to-train-with-datasets

as_upload

切換要上傳的資料參考作業。

如需支援上傳資料之計算和資料存放區的詳細資訊,請參閱: https://aka.ms/datastore-matrix

create

使用 DataPath 和 DataPathComputeBinding 建立 DataReference。

path

根據指定的路徑建立 DataReference 實例。

to_config

將 DataReference 物件轉換為 DataReferenceConfiguration 物件。

as_download

切換要下載的資料參考作業。

DataReference 下載僅支援 Azure Blob 和 Azure 檔案共用。 若要從 Azure Blob、Azure 檔案共用、Azure Data Lake Gen1 和 Azure Data Lake Gen2 下載資料,建議您使用 Azure Machine Learning 資料集。 如需如何建立和使用資料集的詳細資訊,請流覽 https://docs.microsoft.com/en-us/azure/machine-learning/how-to-train-with-datasets

as_download(path_on_compute=None, overwrite=False)

參數

path_on_compute
str
預設值: None

資料參考計算上的路徑。

overwrite
bool
預設值: False

指出是否要覆寫現有的資料。

傳回

新的資料參考物件。

傳回類型

as_mount

切換要掛接的資料參考作業。

DataReference 掛接僅支援 Azure Blob。 若要在 Azure Blob、Azure 檔案共用、Azure Data Lake Gen1 和 Azure Data Lake Gen2 中掛接資料,建議您使用 Azure Machine Learning 資料集。 如需如何建立和使用資料集的詳細資訊,請流覽 https://docs.microsoft.com/en-us/azure/machine-learning/how-to-train-with-datasets

as_mount()

傳回

新的資料參考物件。

傳回類型

as_upload

切換要上傳的資料參考作業。

如需支援上傳資料之計算和資料存放區的詳細資訊,請參閱: https://aka.ms/datastore-matrix

as_upload(path_on_compute=None, overwrite=False)

參數

path_on_compute
str
預設值: None

資料參考計算上的路徑。

overwrite
bool
預設值: False

指出是否要覆寫現有的資料。

傳回

新的資料參考物件。

傳回類型

create

使用 DataPath 和 DataPathComputeBinding 建立 DataReference。

static create(data_reference_name=None, datapath=None, datapath_compute_binding=None)

參數

data_reference_name
str
預設值: None

要建立之資料參考的名稱。

datapath
DataPath
預設值: None

[必要]要使用的資料路徑。

datapath_compute_binding
DataPathComputeBinding
預設值: None

[必要]要使用的 Datapath 計算系結。

傳回

DataReference 物件。

傳回類型

path

根據指定的路徑建立 DataReference 實例。

path(path=None, data_reference_name=None)

參數

path
str
預設值: None

資料存放區上的路徑。

data_reference_name
str
預設值: None

資料參考的名稱。

傳回

資料參考物件。

傳回類型

to_config

將 DataReference 物件轉換為 DataReferenceConfiguration 物件。

to_config()

傳回

新的 DataReferenceConfiguration 物件。

傳回類型