HDInsightCompute 類別

在 Azure Machine Learning 中管理 HDInsight 叢集計算目標。

Azure HDInsight 是巨量資料分析的常用平台。 此平台會提供 Apache Spark,可用來將您的模型定型。 如需詳細資訊,請參閱 什麼是 Azure Machine Learning 中的計算目標?

類別 ComputeTarget 建構函式。

擷取與所提供工作區相關聯之 Compute 物件的雲端標記法。 傳回對應至所擷取之 Compute 物件之特定型別之子類別的實例。

繼承
HDInsightCompute

建構函式

HDInsightCompute(workspace, name)

參數

workspace
Workspace
必要

包含要擷取之 HDInsightCompute 物件的工作區物件。

name
str
必要

要擷取之 HDInsightCompute 物件的 名稱。

workspace
Workspace
必要

包含要擷取之 Compute 物件的工作區物件。

name
str
必要

要擷取之 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)

完整範例可從 https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/training/train-in-spark/train-in-spark.ipynb

方法

attach

已淘汰。 請改用 attach_configuration 方法。

將現有的 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='')

參數

workspace
Workspace
必要

要與計算資源建立關聯的工作區物件。

name
str
必要

要與所提供工作區內的計算資源產生關聯的名稱。 不需要符合要附加的計算資源名稱。

username
str
必要

存取資源所需的使用者名稱。

address
str
必要

要附加之資源的位址。

ssh_port
int
預設值: 22

資源的公開端口。 預設為 22。

password
str
必要

存取資源所需的密碼。

private_key_file
str
必要

包含資源私密金鑰的檔案路徑。

private_key_passphrase
str
必要

存取資源所需的私密金鑰片語。

傳回

計算物件的 HDInsightCompute 物件表示。

傳回類型

例外狀況

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='')

參數

username
str
必要

存取資源所需的使用者名稱。

subscription_id
str
預設值: None

Azure 訂用帳戶識別碼

resource_group
str
預設值: None

HDI 叢集所在的資源組名。

cluster_name
str
預設值: None

HDI 叢集名稱

resource_id
str
預設值: None

要連結資源的 Azure Resource Manager (ARM) 資源識別碼。

address
str
預設值: None

要附加之資源的位址。

ssh_port
int
預設值: 22

資源的公開端口。 預設為 22。

password
str
必要

存取資源所需的密碼。

private_key_file
str
必要

包含資源私密金鑰的檔案路徑。

private_key_passphrase
str
必要

存取資源所需的私密金鑰片語。

傳回

附加 Compute 物件時要使用的組態物件。

傳回類型

例外狀況

delete

HDInsightCompute 物件不支援 Delete。 請改用 detach

delete()

例外狀況

deserialize

將 JSON 物件轉換成 HDInsightCompute 物件。

static deserialize(workspace, object_dict)

參數

workspace
Workspace
必要

與 HDInsightCompute 物件相關聯的工作區物件。

object_dict
dict
必要

要轉換成 HDInsightCompute 物件的 JSON 物件。

傳回

所提供 JSON 物件的 HDInsightCompute 標記法。

傳回類型

例外狀況

備註

ComputeTargetException如果提供的工作區不是計算相關聯的工作區,則引發 。

detach

中斷連結 HDInsightCompute 物件與其相關聯的工作區。

基礎雲端物件不會刪除,只會移除關聯。

detach()

例外狀況

get_credentials

擷取 HDInsightCompute 目標的認證。

get_credentials()

傳回

HDInsightCompute 目標的認證

傳回類型

例外狀況

refresh_state

執行 物件的屬性就地更新。

這個方法會根據對應雲端物件的目前狀態來更新屬性。 這主要用於手動輪詢計算狀態。

refresh_state()

例外狀況

serialize

將此 HDInsightCompute 物件轉換成 JSON 序列化字典。

serialize()

傳回

這個 HDICompute 物件的 JSON 表示。

傳回類型

例外狀況