def main(name, vm_size, nodes):
    ws = Workspace.from_config()

    try:
        compute_cluster = ComputeTarget(ws, name)
    except:
        compute_config = AmlCompute.provisioning_configuration(vm_size=vm_size,
                                                               min_nodes=1,
                                                               max_nodes=nodes)

        compute_cluster = ComputeTarget.create(ws, name, compute_config)
        compute_cluster.wait_for_completion(show_output=True)
Ejemplo n.º 2
0
try:
    compute_target = ComputeTarget(workspace=workspace, name=cluster_name)
    print('Found existing compute target')
except ComputeTargetException:
    print('Creating a new compute target...')
    compute_config = AmlCompute.provisioning_configuration(
        vm_size='STANDARD_D3_V2', max_nodes=1)

    # create the cluster
    compute_target = ComputeTarget.create(workspace, cluster_name,
                                          compute_config)

    # can poll for a minimum number of nodes and for a specific timeout.
    # if no min node count is provided it uses the scale settings for the cluster
    compute_target.wait_for_completion(show_output=True,
                                       min_node_count=None,
                                       timeout_in_minutes=20)

# store the connection string in AML workspace Key Vault
# (secret name is 'debugrelay-' + MD5(azrelay_connection_string) )
#hybrid_connection_string_secret =\
#    f"debugrelay-{hashlib.md5(azrelay_connection_string.encode('utf-8')).hexdigest()}"
#workspace.get_default_keyvault().set_secret(hybrid_connection_string_secret, azrelay_connection_string)

# Configuring a PythonScriptStep with a RunConfiguration
# that includes debugpy and azure-debug-relay

run_config = RunConfiguration()
conda_dependencies = run_config.environment.python.conda_dependencies
conda_dependencies.add_conda_package("pip")
conda_dependencies.add_conda_package("scikit-learn")