HDInsightCompute 類別
在 Azure Machine Learning 中管理 HDInsight 叢集計算目標。
Azure HDInsight 是巨量資料分析的常用平台。 此平台會提供 Apache Spark,可用來將您的模型定型。 如需詳細資訊,請參閱 什麼是 Azure Machine Learning 中的計算目標?
類別 ComputeTarget 建構函式。
擷取與所提供工作區相關聯的 Compute 物件的雲端表示法。 傳回對應至所擷取之 Compute 物件特定型別之子類別的實例。
建構函式
HDInsightCompute(workspace, name)
參數
名稱 | Description |
---|---|
workspace
必要
|
包含要擷取之 HDInsightCompute 物件的工作區物件。 |
name
必要
|
要擷取之 HDInsightCompute 對象的 名稱。 |
workspace
必要
|
包含要擷取之 Compute 物件的工作區物件。 |
name
必要
|
要擷取之 Compute 對象的 名稱。 |
備註
下列範例示範如何在 Azure 中建立 HDInsight 叢集的 Spark。
from azureml.core.compute import ComputeTarget, HDInsightCompute
from azureml.exceptions import ComputeTargetException
import os
try:
# If you want to connect using SSH key instead of username/password you can provide parameters private_key_file and private_key_passphrase
# Attaching a HDInsight cluster using the public address of the HDInsight cluster is no longer supported.
# Instead, use resourceId of the HDInsight cluster.
# The resourceId of the HDInsight Cluster can be constructed using the following string format:
# /subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.HDInsight/clusters/<cluster_name>.
# You can also use subscription_id, resource_group and cluster_name without constructing resourceId.
attach_config = HDInsightCompute.attach_configuration(resource_id='<resource_id>',
ssh_port=22,
username=os.environ.get('hdiusername', '<ssh_username>'),
password=os.environ.get('hdipassword', '<my_password>'))
hdi_compute = ComputeTarget.attach(workspace=ws,
name='myhdi',
attach_configuration=attach_config)
except ComputeTargetException as e:
print("Caught = {}".format(e.message))
hdi_compute.wait_for_completion(show_output=True)
方法
attach |
荒廢的。 請改用 將現有的 HDI 資源與提供的工作區產生關聯。 |
attach_configuration |
建立組態物件以附加 HDInsight 計算目標。 不再支援使用 HDInsight 叢集的公用地址連結 HDInsight 叢集。 請改用 HDInsight 叢集的 resourceId。 HDInsight 叢集的 resourceId 可以使用下列字元串格式來建構:“/subscriptions/<subscription_id/resourceGroups/>resource_group</ providers/Microsoft.HDInsight>/clusters/<cluster_name>”。 您也可以使用subscription_id、resource_group和cluster_name,而不建構 resourceId。 如需詳細資訊: https://aka.ms/azureml-compute-hdi |
delete |
HDInsightCompute 對象不支援Delete。 請改用 detach。 |
deserialize |
將 JSON 物件轉換成 HDInsightCompute 物件。 |
detach |
將 HDInsightCompute 對象與其相關聯的工作區中斷連結。 基礎雲端物件不會刪除,只會移除關聯。 |
get_credentials |
擷取 HDInsightCompute 目標的認證。 |
refresh_state |
執行物件的屬性就地更新。 此方法會根據對應雲端物件的目前狀態來更新屬性。 這主要用於手動輪詢計算狀態。 |
serialize |
將此 HDInsightCompute 物件轉換成 JSON 串行化字典。 |
attach
荒廢的。 請改用 attach_configuration
方法。
將現有的 HDI 資源與提供的工作區產生關聯。
static attach(workspace, name, username, address, ssh_port='22', password='', private_key_file='', private_key_passphrase='')
參數
名稱 | Description |
---|---|
workspace
必要
|
要與計算資源建立關聯的工作區物件。 |
name
必要
|
要與所提供工作區內的計算資源產生關聯的名稱。 不需要符合要附加的計算資源名稱。 |
username
必要
|
存取資源所需的用戶名稱。 |
address
必要
|
要附加之資源的位址。 |
ssh_port
|
資源的公開埠。 預設值為 22。 預設值: 22
|
password
必要
|
存取資源所需的密碼。 |
private_key_file
必要
|
包含資源私鑰的檔案路徑。 |
private_key_passphrase
必要
|
存取資源所需的私鑰片語。 |
傳回
類型 | Description |
---|---|
計算物件的 HDInsightCompute 物件表示法。 |
例外狀況
類型 | Description |
---|---|
attach_configuration
建立組態物件以附加 HDInsight 計算目標。
不再支援使用 HDInsight 叢集的公用地址連結 HDInsight 叢集。 請改用 HDInsight 叢集的 resourceId。 HDInsight 叢集的 resourceId 可以使用下列字元串格式來建構:“/subscriptions/<subscription_id/resourceGroups/>resource_group</ providers/Microsoft.HDInsight>/clusters/<cluster_name>”。
您也可以使用subscription_id、resource_group和cluster_name,而不建構 resourceId。 如需詳細資訊: https://aka.ms/azureml-compute-hdi
static attach_configuration(username, subscription_id=None, resource_group=None, cluster_name=None, resource_id=None, address=None, ssh_port='22', password='', private_key_file='', private_key_passphrase='')
參數
名稱 | Description |
---|---|
username
必要
|
存取資源所需的用戶名稱。 |
subscription_id
|
Azure 訂用帳戶標識碼 預設值: None
|
resource_group
|
HDI 叢集所在的資源群組名稱。 預設值: None
|
cluster_name
|
HDI 叢集名稱 預設值: None
|
resource_id
|
要連結之資源的 Azure Resource Manager (ARM) 資源識別碼。 預設值: None
|
address
|
要附加之資源的位址。 預設值: None
|
ssh_port
|
資源的公開埠。 預設值為 22。 預設值: 22
|
password
必要
|
存取資源所需的密碼。 |
private_key_file
必要
|
包含資源私鑰的檔案路徑。 |
private_key_passphrase
必要
|
存取資源所需的私鑰片語。 |
傳回
類型 | Description |
---|---|
附加 Compute 物件時要使用的組態物件。 |
delete
deserialize
將 JSON 物件轉換成 HDInsightCompute 物件。
static deserialize(workspace, object_dict)
參數
名稱 | Description |
---|---|
workspace
必要
|
HDInsightCompute 對象相關聯的工作區物件。 |
object_dict
必要
|
要轉換成 HDInsightCompute 物件的 JSON 物件。 |
傳回
類型 | Description |
---|---|
所提供 JSON 物件的 HDInsightCompute 表示法。 |
例外狀況
類型 | Description |
---|---|
備註
ComputeTargetException如果提供的工作區不是計算相關聯的工作區,則引發 。
detach
將 HDInsightCompute 對象與其相關聯的工作區中斷連結。
基礎雲端物件不會刪除,只會移除關聯。
detach()
例外狀況
類型 | Description |
---|---|
get_credentials
擷取 HDInsightCompute 目標的認證。
get_credentials()
傳回
類型 | Description |
---|---|
HDInsightCompute 目標的認證 |
例外狀況
類型 | Description |
---|---|
refresh_state
執行物件的屬性就地更新。
此方法會根據對應雲端物件的目前狀態來更新屬性。 這主要用於手動輪詢計算狀態。
refresh_state()
serialize
將此 HDInsightCompute 物件轉換成 JSON 串行化字典。
serialize()
傳回
類型 | Description |
---|---|
這個 HDICompute 物件的 JSON 表示法。 |