Skip to content

Instantly share code, notes, and snippets.

@maxbrenner-ai
Created August 25, 2020 23:47
Show Gist options
  • Save maxbrenner-ai/3db43b36fee6ce7fbc3c9789c06aa6de to your computer and use it in GitHub Desktop.
Save maxbrenner-ai/3db43b36fee6ce7fbc3c9789c06aa6de to your computer and use it in GitHub Desktop.
sagemaker deploy model code - setup
# Install sagemaker (version 1.72)
import sys
!{sys.executable} -m pip install --quiet sagemaker==1.72 -U
# Imports
import io
import os
import sys
import time
import json
from IPython.display import display
from time import strftime, gmtime
import boto3
import re
import sagemaker
from sagemaker import get_execution_role
# Get the boto3 session and sagemaker client, as well as the current execution role
sess = boto3.Session()
sm = sess.client('sagemaker')
role = sagemaker.get_execution_role()
# Name of the docker image containing the model code
docker_image_name = '<Name of docker image in registry on AWS>'
# Name and prefix for the S3 bucket storing the model output
account_id = sess.client('sts', region_name=sess.region_name).get_caller_identity()["Account"]
bucket = 'sagemaker-studio-{}-{}'.format(sess.region_name, account_id)
prefix = 'anomaly-detection'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment