From 564129be5ac8883f654713730a33513b9085c4f6 Mon Sep 17 00:00:00 2001 From: djarpin Date: Sat, 25 Nov 2017 18:59:45 -0800 Subject: [PATCH] Updated: Markdown in several examples --- .../handling_kms_encrypted_data.ipynb | 60 +++++++++++-------- .../working_with_redshift_data.ipynb | 37 +++++++++--- .../xgboost_bring_your_own_model.ipynb | 2 +- 3 files changed, 65 insertions(+), 34 deletions(-) diff --git a/advanced_functionality/handling_kms_encrypted_data/handling_kms_encrypted_data.ipynb b/advanced_functionality/handling_kms_encrypted_data/handling_kms_encrypted_data.ipynb index be02f5e2be..4a143662ea 100644 --- a/advanced_functionality/handling_kms_encrypted_data/handling_kms_encrypted_data.ipynb +++ b/advanced_functionality/handling_kms_encrypted_data/handling_kms_encrypted_data.ipynb @@ -30,17 +30,20 @@ "\n", "## Setup\n", "\n", + "### Prerequisites\n", + "\n", + "In order to successfully run this notebook, you must first:\n", + "\n", + "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", + "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", + "\n", + "We use the `key-id` from the KMS key ARN `arn:aws:kms:region:acct-id:key/key-id`.\n", + "\n", "### General Setup\n", "Let's start by specifying:\n", "* AWS region.\n", "* The IAM role arn used to give learning and hosting access to your data. See the documentation for how to specify these.\n", - "* The S3 bucket that you want to use for training and model data.\n", - "\n", - "### KMS key setup\n", - "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", - "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", - "\n", - "We use the `key-id` from the KMS key ARN `arn:aws:kms:region:acct-id:key/key-id`." + "* The S3 bucket that you want to use for training and model data." ] }, { @@ -65,9 +68,9 @@ "assumed_role = boto3.client('sts').get_caller_identity()['Arn']\n", "role = re.sub(r'^(.+)sts::(\\d+):assumed-role/(.+?)/.*$', r'\\1iam::\\2:role/\\3', assumed_role)\n", "\n", - "kms_key_id = ''\n", + "kms_key_id = ''\n", "\n", - "bucket='' # put your s3 bucket name here, and create s3 bucket\n", + "bucket='' # put your s3 bucket name here, and create s3 bucket\n", "prefix = 'sagemarker/kms-new'\n", "# customize to your bucket where you have stored the data\n", "bucket_path = 'https://s3-{}.amazonaws.com/{}'.format(region,bucket)" @@ -98,7 +101,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from sklearn.datasets import load_boston\n", @@ -125,7 +130,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "from sklearn.model_selection import train_test_split\n", @@ -136,7 +143,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "def write_file(X, y, fname):\n", @@ -154,7 +163,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "train_file = 'train.csv'\n", @@ -217,7 +228,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "containers = {'us-west-2': '433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost:latest',\n", @@ -430,7 +443,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "runtime_client = boto3.client('sagemaker-runtime')" @@ -439,7 +454,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "import sys\n", @@ -513,15 +530,8 @@ "metadata": {}, "outputs": [], "source": [ - "client.delete_endpoint(EndpointName=endpoint_name)" + "#client.delete_endpoint(EndpointName=endpoint_name)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { @@ -540,7 +550,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.3" + "version": "3.6.2" }, "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." }, diff --git a/advanced_functionality/working_with_redshift_data/working_with_redshift_data.ipynb b/advanced_functionality/working_with_redshift_data/working_with_redshift_data.ipynb index 331f3c1c7b..ee1c612aa2 100644 --- a/advanced_functionality/working_with_redshift_data/working_with_redshift_data.ipynb +++ b/advanced_functionality/working_with_redshift_data/working_with_redshift_data.ipynb @@ -19,7 +19,16 @@ "\n", "\n", "## Introduction\n", - "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. " + "In this notebook we illustrate how to copy data from Redshift to S3 and vice-versa.\n", + "\n", + "### Prerequisites\n", + "In order to successfully run this notebook, you'll first need to:\n", + "1. Have a Redshift cluster within the same VPC.\n", + "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", + "1. Update the credential file (`redshift_creds_template.json.nogit`) file with the appropriate information.\n", + "\n", + "### Notebook Setup\n", + "Let's start by installing `psycopg2`, a PostgreSQL database adapter for the Python, adding a few imports and specifying a few configs. " ] }, { @@ -35,6 +44,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "collapsed": true, "isConfigCell": true }, "outputs": [], @@ -48,7 +58,7 @@ "\n", "region = boto3.Session().region_name\n", "\n", - "bucket='' # put your s3 bucket name here, and create s3 bucket\n", + "bucket='' # put your s3 bucket name here, and create s3 bucket\n", "prefix = 'sagemarker/redshift'\n", "# customize to your bucket where you have stored the data\n", "\n", @@ -67,6 +77,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "collapsed": true, "isConfigCell": true }, "outputs": [], @@ -89,7 +100,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"Reading from Redshift...\")\n", @@ -130,7 +143,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"Writing to S3...\")\n", @@ -152,7 +167,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"Reading from S3...\")\n", @@ -169,7 +186,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "print(\"Writing to Redshift...\")\n", @@ -195,7 +214,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "pd.options.display.max_rows = 2\n", @@ -222,7 +243,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.3" + "version": "3.6.2" }, "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." }, diff --git a/advanced_functionality/xgboost_bring_your_own_model/xgboost_bring_your_own_model.ipynb b/advanced_functionality/xgboost_bring_your_own_model/xgboost_bring_your_own_model.ipynb index ae394e6d4c..b82e04ec15 100644 --- a/advanced_functionality/xgboost_bring_your_own_model/xgboost_bring_your_own_model.ipynb +++ b/advanced_functionality/xgboost_bring_your_own_model/xgboost_bring_your_own_model.ipynb @@ -301,7 +301,7 @@ " 'InstanceType':'ml.m4.xlarge',\n", " 'InitialInstanceCount':1,\n", " 'InitialVariantWeight':1,\n", - " 'ModelName':model_file_name,\n", + " 'ModelName':model_name,\n", " 'VariantName':'AllTraffic'}])\n", "\n", "print(\"Endpoint Config Arn: \" + create_endpoint_config_response['EndpointConfigArn'])"