-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_model_job.py
More file actions
29 lines (25 loc) · 825 Bytes
/
deploy_model_job.py
File metadata and controls
29 lines (25 loc) · 825 Bytes
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
import sagemaker as sage
from sagemaker import Model
# get and pass the auth role and image path, same as before
# this step is unchanged from the training script
role = sage.get_execution_role()
sess = sage.Session()
account = sess.boto_session.client('sts').get_caller_identity()['Account']
region = sess.boto_session.region_name
image = '{}.dkr.ecr.{}.amazonaws.com/docker-sagemaker'.format(account, region)
# create a new Model object
clf = Model(
# insert model path below
model_data='s3://docker-sagemaker/lr_model.tar.gz',
image=image,
role=role,
sagemaker_session=sess
)
# deploy it to an endpoint
predictor = clf.deploy(1, 'ml.c4.2xlarge')
# connect to the endpoint
predictor = sage.predictor.RealTimePredictor(
'lr_model.tar.gz',
sagemaker_session=sess,
content_type="text/csv"
)