HDInsightCompute 类

在 Azure 机器学习中管理 HDInsight 群集计算目标。

Azure HDInsight 是用于大数据分析的热门平台。 该平台提供的 Apache Spark 可用于训练模型。 有关详细信息,请参阅什么是 Azure 机器学习中的计算目标?

类 ComputeTarget 构造函数。

检索与提供的工作区关联的 Compute 对象的云表示形式。 返回与检索的 Compute 对象的特定类型对应的子类的实例。

继承
HDInsightCompute

构造函数

HDInsightCompute(workspace, name)

参数

workspace
Workspace
必需

包含要检索的 HDInsightCompute 对象的工作区对象。

name
str
必需

要检索的 HDInsightCompute 对象的名称。

workspace
Workspace
必需

包含要检索的 Compute 对象的工作区对象。

name
str
必需

要检索的 Compute 对象的 的名称。

注解

下面的示例演示如何在 Azure 中创建 Spark for HDInsight 群集。


   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 群集的资源 ID:“/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 对象不支持删除操作。 请改用 detach

deserialize

将 JSON 对象转换为 HDInsightCompute 对象。

detach

将 HDInsightCompute 对象与其关联的工作区分离。

不会删除基础云对象,只会删除其关联。

get_credentials

检索 HDInsightCompute 目标的凭据。

refresh_state

执行对象属性的就地更新。

此方法根据相应云对象的当前状态更新属性。 这主要用于手动轮询计算状态。

serialize

将此 HDICompute 对象转换为 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 群集的资源 ID:“/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 订阅 ID

resource_group
str
默认值: None

HDI 群集所在的资源组的名称。

cluster_name
str
默认值: None

HDI 群集名称

resource_id
str
默认值: None

Azure 资源管理器 (ARM) 要附加的资源的资源 ID。

address
str
默认值: None

要附加的资源的地址。

ssh_port
int
默认值: 22

资源的已公开端口。 默认值为 22。

password
str
必需

访问资源所需的密码。

private_key_file
str
必需

包含资源私钥的文件的路径。

private_key_passphrase
str
必需

访问资源所需的私钥短语。

返回

要在附加计算对象时使用的配置对象。

返回类型

例外

delete

HDInsightCompute 对象不支持删除操作。 请改用 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

将此 HDICompute 对象转换为 JSON 序列化字典。

serialize()

返回

此 HDICompute 对象的 JSON 表示形式。

返回类型

例外