Skip to content

Commit 716c6d8

Browse files
committed
add quickstart code
1 parent 23189c6 commit 716c6d8

File tree

1 file changed

+55
-0
lines changed
  • ignore/doc-qa/quickstart-create-workspace-with-python

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# code snippets for the quickstart-create-workspace-with-python article
2+
# <import>
3+
import azureml.core
4+
print(azureml.core.VERSION)
5+
# </import>
6+
7+
# this is NOT a snippet. If this code changes, go fix it in the article!
8+
from azureml.core import Workspace
9+
ws = Workspace.create(name='myworkspace',
10+
subscription_id='65a1016d-0f67-45d2-b838-b8f373d6d52e',
11+
resource_group='myresourcegroup',
12+
create_resource_group=True,
13+
location='eastus2' # or other supported Azure region
14+
)
15+
16+
# <getDetails>
17+
ws.get_details()
18+
# </getDetails>
19+
20+
# <writeConfig>
21+
# Create the configuration file.
22+
ws.write_config()
23+
24+
# Use this code to load the workspace from
25+
# other scripts and notebooks in this directory.
26+
# ws = Workspace.from_config()
27+
# </writeConfig>
28+
29+
# <useWs>
30+
from azureml.core import Experiment
31+
32+
# create a new experiment
33+
exp = Experiment(workspace=ws, name='myexp')
34+
35+
# start a run
36+
run = exp.start_logging()
37+
38+
# log a number
39+
run.log('my magic number', 42)
40+
41+
# log a list (Fibonacci numbers)
42+
run.log_list('my list', [1, 1, 2, 3, 5, 8, 13, 21, 34, 55])
43+
44+
# finish the run
45+
run.complete()
46+
# </useWs>
47+
48+
# <viewLog>
49+
print(run.get_portal_url())
50+
# </viewLog>
51+
52+
53+
# <delete>
54+
ws.delete(delete_dependent_resources=True)
55+
# </delete>

0 commit comments

Comments
 (0)