This repository has been archived by the owner on Jan 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnippets.json
191 lines (180 loc) · 6.48 KB
/
snippets.json
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
{
"Basic core imports": {
"prefix": ["imports", "workspace-imports-creation"],
"body": [
"from azureml.core import Workspace, Experiment, Run, RunConfiguration, ComputeTarget, Environment, ScriptRunConfig$1",
"$0"
],
"description": "Import essential packages"
},
"Pipeline Imports": {
"prefix": "pipeline-imports",
"body": [
"from azureml.pipeline.core import Pipeline, PipelineData, PipelineParameter",
"from azureml.pipeline.steps import PythonScriptStep$1",
"$0"
],
"description": "Basic imports for pipeline"
},
"Create AML Workspace from config": {
"prefix": ["workspace-quick","fromconfig","from-config"],
"body": [
"ws = Workspace.from_config()",
"$0"
],
"description": "Default workspace creation"
},
"Create AML Workspace from config and auth": {
"prefix": "workspace-from-config-auth",
"body": [
"from azureml.core.authentication import InteractiveLoginAuthentication",
"config = {'subscription_id':'$1',",
"'resource_group':'$2',",
"'workspace_name' :'$3'}",
"auth = InteractiveLoginAuthentication()",
"ws = Workspace(**config,auth = auth)",
"$0"
],
"description": "Create workspace from config and auth"
},
"Register Azure Blob Container From SAS": {
"prefix": ["datastore-register-blob-sas","reg-blob-sas"],
"body": [
"ds = Datastore.register_azure_blob_container(",
" workspace='$1',",
" datastore_name='$2',",
" container_name='$3',",
" account_name='$4',",
" sas_token='$5',",
")",
"$0"
],
"description": "Register Azure Blob container to workspace via SAS"
},
"Create Compute Cluster with SSH": {
"prefix": ["create-compute-cluster-ssh"],
"body": [
"from azureml.core.compute import AmlCompute",
"from azureml.core.compute_target import ComputeTargetException",
"ssh_public_key = '$1'",
"compute_config = AmlCompute.provisioning_configuration(vm_size='$4',min_nodes=$5, max_nodes=$6,admin_username='$7',admin_user_ssh_key=ssh_public_key,vm_priority='${8|lowpriority,dedicated|}',remote_login_port_public_access='Enabled')",
"cluster$0 = ComputeTarget.create(workspace=$9, name='$10', compute_config)"
],
"description": "Create compute cluster with SSH enabled"
},
"AML Template Script Run Config": {
"prefix": ["scr", "aml-template-script"],
"body": [
"from azureml.core import Workspace, Experiment, ScriptRunConfig",
"",
"# get workspace",
"ws = Workspace.from_config()",
"",
"# get/create experiment",
"exp = Experiment(ws, '$1')",
"",
"# set up script run configuration",
"config = ScriptRunConfig(",
" source_directory='.',",
" script='$2.py',",
" #arguments=['--meaning', 42],",
")",
"",
"# submit script to AML",
"run = exp.submit(config)",
"print(run.get_portal_url()) # link to ml.azure.com",
"$0"
],
"description": "Template for control plane to launch script on AML"
},
"AML Template Estimator": {
"prefix": ["aml-template-estimator"],
"body": [
"from azureml.core import Workspace, Experiment, ComputeTarget",
"from azureml.train.estimator import Estimator",
"",
"# get workspace",
"ws = Workspace.from_config()",
"",
"# get/create experiment",
"exp = Experiment(ws, '$1')",
"",
"# define compute target",
"compute_target = ComputeTarget(ws, '$2')",
"",
"# set up script run configuration",
"config = Estimator(",
" source_directory='.',",
" entry_script='$3.py',",
" compute_target=compute_target,",
" #script_params={'--meaning': 42},",
")",
"",
"# submit script to AML",
"run = exp.submit(config)",
"print(run.get_portal_url()) # link to ml.azure.com",
"$0"
],
"description": "Template for control plane to launch estimator on AML"
},
"Environment-From-Pip": {
"prefix": ["environment-from-pip"],
"body": [
"from azureml.core import Environment",
"env = Environment.from_pip_requirements(",
" name='$1',",
" file_path='$2',",
")",
"",
"$0"
],
"description": "Create AML Environment from pip requirements.txt"
},
"Environment-From-Conda-Spec": {
"prefix": ["environment-from-conda-spec"],
"body": [
"from azureml.core import Environment",
"env = Environment.from_conda_specification(",
" name='$1',",
" file_path='$2',",
")",
"",
"$0"
],
"description": "Create AML Environment from conda env.yml"
},
"Environment-From-Conda-Existing": {
"prefix": ["environment-from-conda-existing"],
"body": [
"from azureml.core import Environment",
"env = Environment.from_existing_conda_environment(",
" name='$1',",
" conda_environment_name='$2',",
")",
"",
"$0"
],
"description": "Create AML Environment from an existing Conda environment"
},
"Environment": {
"prefix": ["environment-from-sdk"],
"body": [
"from azureml.core import Environment",
"from azureml.core.conda_dependencies import CondaDependencies",
"env = Environment($1)",
"",
"conda = CondaDependencies()",
"",
"# add channels",
"conda.add_channel('$2')",
"",
"# add conda packages",
"conda.add_conda_package('$3')",
"",
"# add pip packages",
"conda.add_pip_package('$4')",
"$0"
],
"description": "Create AML Environment using the SDK"
}
}