Skip to content

Commit 48bc02e

Browse files
authored
Merge pull request #55 from awslabs/arpin_xgb_byom_updates
Updated: Markdown in several examples
2 parents a1769f0 + 564129b commit 48bc02e

File tree

3 files changed

+65
-34
lines changed

3 files changed

+65
-34
lines changed

advanced_functionality/handling_kms_encrypted_data/handling_kms_encrypted_data.ipynb

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,20 @@
3030
"\n",
3131
"## Setup\n",
3232
"\n",
33+
"### Prerequisites\n",
34+
"\n",
35+
"In order to successfully run this notebook, you must first:\n",
36+
"\n",
37+
"1. Have an existing KMS key from AWS IAM console or create one ([learn more](http://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html)).\n",
38+
"2. Allow the IAM role used for SageMaker to encrypt and decrypt data with this key from within applications and when using AWS services integrated with KMS ([learn more](http://docs.aws.amazon.com/console/kms/key-users)).\n",
39+
"\n",
40+
"We use the `key-id` from the KMS key ARN `arn:aws:kms:region:acct-id:key/key-id`.\n",
41+
"\n",
3342
"### General Setup\n",
3443
"Let's start by specifying:\n",
3544
"* AWS region.\n",
3645
"* The IAM role arn used to give learning and hosting access to your data. See the documentation for how to specify these.\n",
37-
"* The S3 bucket that you want to use for training and model data.\n",
38-
"\n",
39-
"### KMS key setup\n",
40-
"1. Use an existing KMS key from AWS IAM console or create one ([learn more](http://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html)).\n",
41-
"2. Allow the IAM role used for SageMaker to encrypt and decrypt data with this key from within applications and when using AWS services integrated with KMS ([learn more](http://docs.aws.amazon.com/console/kms/key-users)).\n",
42-
"\n",
43-
"We use the `key-id` from the KMS key ARN `arn:aws:kms:region:acct-id:key/key-id`."
46+
"* The S3 bucket that you want to use for training and model data."
4447
]
4548
},
4649
{
@@ -65,9 +68,9 @@
6568
"assumed_role = boto3.client('sts').get_caller_identity()['Arn']\n",
6669
"role = re.sub(r'^(.+)sts::(\\d+):assumed-role/(.+?)/.*$', r'\\1iam::\\2:role/\\3', assumed_role)\n",
6770
"\n",
68-
"kms_key_id = '<bring your own key-id>'\n",
71+
"kms_key_id = '<your_kms_key_arn_here>'\n",
6972
"\n",
70-
"bucket='<s3 bucket>' # put your s3 bucket name here, and create s3 bucket\n",
73+
"bucket='<your_s3_bucket_name_here>' # put your s3 bucket name here, and create s3 bucket\n",
7174
"prefix = 'sagemarker/kms-new'\n",
7275
"# customize to your bucket where you have stored the data\n",
7376
"bucket_path = 'https://s3-{}.amazonaws.com/{}'.format(region,bucket)"
@@ -98,7 +101,9 @@
98101
{
99102
"cell_type": "code",
100103
"execution_count": null,
101-
"metadata": {},
104+
"metadata": {
105+
"collapsed": true
106+
},
102107
"outputs": [],
103108
"source": [
104109
"from sklearn.datasets import load_boston\n",
@@ -125,7 +130,9 @@
125130
{
126131
"cell_type": "code",
127132
"execution_count": null,
128-
"metadata": {},
133+
"metadata": {
134+
"collapsed": true
135+
},
129136
"outputs": [],
130137
"source": [
131138
"from sklearn.model_selection import train_test_split\n",
@@ -136,7 +143,9 @@
136143
{
137144
"cell_type": "code",
138145
"execution_count": null,
139-
"metadata": {},
146+
"metadata": {
147+
"collapsed": true
148+
},
140149
"outputs": [],
141150
"source": [
142151
"def write_file(X, y, fname):\n",
@@ -154,7 +163,9 @@
154163
{
155164
"cell_type": "code",
156165
"execution_count": null,
157-
"metadata": {},
166+
"metadata": {
167+
"collapsed": true
168+
},
158169
"outputs": [],
159170
"source": [
160171
"train_file = 'train.csv'\n",
@@ -217,7 +228,9 @@
217228
{
218229
"cell_type": "code",
219230
"execution_count": null,
220-
"metadata": {},
231+
"metadata": {
232+
"collapsed": true
233+
},
221234
"outputs": [],
222235
"source": [
223236
"containers = {'us-west-2': '433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost:latest',\n",
@@ -430,7 +443,9 @@
430443
{
431444
"cell_type": "code",
432445
"execution_count": null,
433-
"metadata": {},
446+
"metadata": {
447+
"collapsed": true
448+
},
434449
"outputs": [],
435450
"source": [
436451
"runtime_client = boto3.client('sagemaker-runtime')"
@@ -439,7 +454,9 @@
439454
{
440455
"cell_type": "code",
441456
"execution_count": null,
442-
"metadata": {},
457+
"metadata": {
458+
"collapsed": true
459+
},
443460
"outputs": [],
444461
"source": [
445462
"import sys\n",
@@ -513,15 +530,8 @@
513530
"metadata": {},
514531
"outputs": [],
515532
"source": [
516-
"client.delete_endpoint(EndpointName=endpoint_name)"
533+
"#client.delete_endpoint(EndpointName=endpoint_name)"
517534
]
518-
},
519-
{
520-
"cell_type": "code",
521-
"execution_count": null,
522-
"metadata": {},
523-
"outputs": [],
524-
"source": []
525535
}
526536
],
527537
"metadata": {
@@ -540,7 +550,7 @@
540550
"name": "python",
541551
"nbconvert_exporter": "python",
542552
"pygments_lexer": "ipython3",
543-
"version": "3.6.3"
553+
"version": "3.6.2"
544554
},
545555
"notice": "Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with the License. A copy of the License is located at http://aws.amazon.com/apache2.0/ or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."
546556
},

advanced_functionality/working_with_redshift_data/working_with_redshift_data.ipynb

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@
1919
"\n",
2020
"\n",
2121
"## Introduction\n",
22-
"In this notebook we illustrate how to copy data from Redshift to S3 and vice-versa. We have a Redshift cluster within the same VPC, and have preloaded it with data from the [iris data set](https://archive.ics.uci.edu/ml/datasets/iris). Let's start by installing `psycopg2`, a PostgreSQL database adapter for the Python, adding a few imports and specifying a few configs. "
22+
"In this notebook we illustrate how to copy data from Redshift to S3 and vice-versa.\n",
23+
"\n",
24+
"### Prerequisites\n",
25+
"In order to successfully run this notebook, you'll first need to:\n",
26+
"1. Have a Redshift cluster within the same VPC.\n",
27+
"1. Preload that cluster with data from the [iris data set](https://archive.ics.uci.edu/ml/datasets/iris) in a table named public.irisdata.\n",
28+
"1. Update the credential file (`redshift_creds_template.json.nogit`) file with the appropriate information.\n",
29+
"\n",
30+
"### Notebook Setup\n",
31+
"Let's start by installing `psycopg2`, a PostgreSQL database adapter for the Python, adding a few imports and specifying a few configs. "
2332
]
2433
},
2534
{
@@ -35,6 +44,7 @@
3544
"cell_type": "code",
3645
"execution_count": null,
3746
"metadata": {
47+
"collapsed": true,
3848
"isConfigCell": true
3949
},
4050
"outputs": [],
@@ -48,7 +58,7 @@
4858
"\n",
4959
"region = boto3.Session().region_name\n",
5060
"\n",
51-
"bucket='<S3 bucket>' # put your s3 bucket name here, and create s3 bucket\n",
61+
"bucket='<your_s3_bucket_name_here>' # put your s3 bucket name here, and create s3 bucket\n",
5262
"prefix = 'sagemarker/redshift'\n",
5363
"# customize to your bucket where you have stored the data\n",
5464
"\n",
@@ -67,6 +77,7 @@
6777
"cell_type": "code",
6878
"execution_count": null,
6979
"metadata": {
80+
"collapsed": true,
7081
"isConfigCell": true
7182
},
7283
"outputs": [],
@@ -89,7 +100,9 @@
89100
{
90101
"cell_type": "code",
91102
"execution_count": null,
92-
"metadata": {},
103+
"metadata": {
104+
"collapsed": true
105+
},
93106
"outputs": [],
94107
"source": [
95108
"print(\"Reading from Redshift...\")\n",
@@ -130,7 +143,9 @@
130143
{
131144
"cell_type": "code",
132145
"execution_count": null,
133-
"metadata": {},
146+
"metadata": {
147+
"collapsed": true
148+
},
134149
"outputs": [],
135150
"source": [
136151
"print(\"Writing to S3...\")\n",
@@ -152,7 +167,9 @@
152167
{
153168
"cell_type": "code",
154169
"execution_count": null,
155-
"metadata": {},
170+
"metadata": {
171+
"collapsed": true
172+
},
156173
"outputs": [],
157174
"source": [
158175
"print(\"Reading from S3...\")\n",
@@ -169,7 +186,9 @@
169186
{
170187
"cell_type": "code",
171188
"execution_count": null,
172-
"metadata": {},
189+
"metadata": {
190+
"collapsed": true
191+
},
173192
"outputs": [],
174193
"source": [
175194
"print(\"Writing to Redshift...\")\n",
@@ -195,7 +214,9 @@
195214
{
196215
"cell_type": "code",
197216
"execution_count": null,
198-
"metadata": {},
217+
"metadata": {
218+
"collapsed": true
219+
},
199220
"outputs": [],
200221
"source": [
201222
"pd.options.display.max_rows = 2\n",
@@ -222,7 +243,7 @@
222243
"name": "python",
223244
"nbconvert_exporter": "python",
224245
"pygments_lexer": "ipython3",
225-
"version": "3.6.3"
246+
"version": "3.6.2"
226247
},
227248
"notice": "Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with the License. A copy of the License is located at http://aws.amazon.com/apache2.0/ or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."
228249
},

advanced_functionality/xgboost_bring_your_own_model/xgboost_bring_your_own_model.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@
301301
" 'InstanceType':'ml.m4.xlarge',\n",
302302
" 'InitialInstanceCount':1,\n",
303303
" 'InitialVariantWeight':1,\n",
304-
" 'ModelName':model_file_name,\n",
304+
" 'ModelName':model_name,\n",
305305
" 'VariantName':'AllTraffic'}])\n",
306306
"\n",
307307
"print(\"Endpoint Config Arn: \" + create_endpoint_config_response['EndpointConfigArn'])"

0 commit comments

Comments
 (0)