<jupyter_start><jupyter_text>Copyright (c) Microsoft Corporation. All rights reserved.Licensed under the MIT License.  Setup AML Workspace---This notebook walks you through all the necessary steps to configure your environment for this solution accelerator including:1. Connecting to your workspace 2. Create a config.json (this can be skipped if running on an AML compute instance)3. Create a compute cluster  1.0 Connect to workspaceConnect this solution accelerator to your AML workspace. This step isn't necessary if you're using a Notebook VM.The following cell allows you to specify your workspace parameters. This cell uses the python method os.getenv to read values from environment variables which is useful for automation. If no environment variable exists, the parameters will be set to the specified default values.<jupyter_code>import os

subscription_id = os.getenv("SUBSCRIPTION_ID", default="<my-subscription-id>")
resource_group = os.getenv("RESOURCE_GROUP", default="<my-resource-group>")
workspace_name = os.getenv("WORKSPACE_NAME", default="<my-workspace-name>")
workspace_region = os.getenv("WORKSPACE_REGION", default="westus2")
from azureml.core import Workspace

try:
    ws = Workspace(subscription_id=subscription_id, 
                   resource_group=resource_group, 
                   workspace_name=workspace_name)
    print("Workspace configuration succeeded. Skip the workspace creation steps below")
except:
    print("Workspace does not exist. Creating workspace")
    ws = Workspace.create(name=workspace_name, subscription_id=subscription_id, resource_group=resource_group,
                            location=workspace_region, create_resource_group=True, sku='enterprise', exist_ok=True)
ws.get_details()<jupyter_output><empty_output><jupyter_text>2.0 Write config fileWrite the details of the workspace to a config.json file:<jupyter_code>ws.write_config()<jupyter_output><empty_output><jupyter_text>3.0 Create compute clusterYou will need a compute cluster for training and batch forecasting.This is a one-time set up so you won't need to re-run this in future notebooks, but you'll need to use the same cluster name to reference this cluster in following notebooks.<jupyter_code># Choose a name for your CPU cluster
cpu_cluster_name = 'cpucluster'<jupyter_output><empty_output><jupyter_text>We create a STANDARD_D13_V2 compute cluster. D-series VMs are used for tasks that require higher compute power and temporary disk performance. This [page](https://docs.microsoft.com/azure/cloud-services/cloud-services-sizes-specs) will give you more information on VM sizes to help you decide which will best fit your use case.<jupyter_code>from azureml.core.compute import ComputeTarget, AmlCompute
from azureml.core.compute_target import ComputeTargetException

# Verify that cluster does not exist already
try:
    cpu_cluster = ComputeTarget(workspace=ws, name=cpu_cluster_name)
    print('Found an existing cluster, using it instead.')
except ComputeTargetException:
    compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D13_V2',
                                                           min_nodes=0,
                                                           max_nodes=20)
    cpu_cluster = ComputeTarget.create(ws, cpu_cluster_name, compute_config)
    cpu_cluster.wait_for_completion(show_output=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06861012956419317, 'fraction_numerical': 0.0055948174322732625, 'mean_word_length': 4.587171052631579, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '92730', 'license': 'MIT', 'n_tokens_mistral': 907, 'n_tokens_neox': 891, 'n_words': 307, 'path': '00_Setup_AML_Workspace.ipynb', 'repo_name': 'buswrecker/energy-many-models', 'size': '3396'}