-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathsetup-workspace.py
More file actions
42 lines (37 loc) · 1.25 KB
/
setup-workspace.py
File metadata and controls
42 lines (37 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# imports
import argparse
from azureml.core import Workspace
from azureml.core.compute import ComputeTarget, AmlCompute, AksCompute
# setup argparse
parser = argparse.ArgumentParser()
parser.add_argument("--subscription-id", type=str, default=None)
parser.add_argument("--workspace-name", type=str, default="default")
parser.add_argument("--resource-group", type=str, default="azureml-template")
parser.add_argument("--location", type=str, default="eastus")
args = parser.parse_args()
# define aml compute target(s) to create
amlcomputes = {
"cpu-cluster": {
"vm_size": "STANDARD_DS3_V2",
"min_nodes": 0,
"max_nodes": 3,
"idle_seconds_before_scaledown": 1200,
}
}
# create workspace
ws = Workspace.create(
args.workspace_name,
subscription_id=args.subscription_id,
resource_group=args.resource_group,
location=args.location,
create_resource_group=True,
exist_ok=True,
show_output=True,
)
ws.write_config()
# create aml compute targets
for ct_name in amlcomputes:
if ct_name not in ws.compute_targets:
compute_config = AmlCompute.provisioning_configuration(**amlcomputes[ct_name])
ct = ComputeTarget.create(ws, ct_name, compute_config)
ct.wait_for_completion(show_output=True)