Skip to content

Commit 17e33ba

Browse files
authored
generate unique endpoint names for SKLearn E2E Notebook (#1046)
1 parent 2fb1d7c commit 17e33ba

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

sagemaker-python-sdk/scikit_learn_randomforest/Sklearn_on_SageMaker_end2end.ipynb

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@
268268
" train_instance_count=1,\n",
269269
" train_instance_type='ml.c5.xlarge',\n",
270270
" framework_version='0.20.0',\n",
271+
" base_job_name='rf-scikit',\n",
271272
" metric_definitions=[\n",
272273
" {'Name': 'median-AE',\n",
273274
" 'Regex': \"AE-at-50th-percentile: ([0-9.]+).*$\"}],\n",
@@ -519,12 +520,9 @@
519520
"metadata": {},
520521
"outputs": [],
521522
"source": [
522-
"endpoint_name = 'rf-scikit-endpoint'\n",
523-
"\n",
524-
"model.deploy(\n",
523+
"predictor = model.deploy(\n",
525524
" instance_type='ml.c5.large',\n",
526-
" initial_instance_count=1,\n",
527-
" endpoint_name=endpoint_name)"
525+
" initial_instance_count=1)"
528526
]
529527
},
530528
{
@@ -534,16 +532,6 @@
534532
"### Invoke with the Python SDK"
535533
]
536534
},
537-
{
538-
"cell_type": "code",
539-
"execution_count": null,
540-
"metadata": {},
541-
"outputs": [],
542-
"source": [
543-
"# we use the SklearnPredictor from the python SDK\n",
544-
"predictor = sagemaker.sklearn.model.SKLearnPredictor(endpoint_name=endpoint_name)"
545-
]
546-
},
547535
{
548536
"cell_type": "code",
549537
"execution_count": null,
@@ -585,7 +573,7 @@
585573
"source": [
586574
"# csv serialization\n",
587575
"response = runtime.invoke_endpoint(\n",
588-
" EndpointName=endpoint_name,\n",
576+
" EndpointName=predictor.endpoint,\n",
589577
" Body=testX[data.feature_names].to_csv(header=False, index=False).encode('utf-8'),\n",
590578
" ContentType='text/csv')\n",
591579
"\n",
@@ -615,7 +603,7 @@
615603
"np.save(buffer, testX[data.feature_names].values)\n",
616604
"\n",
617605
"response = runtime.invoke_endpoint(\n",
618-
" EndpointName=endpoint_name,\n",
606+
" EndpointName=predictor.endpoint,\n",
619607
" Body=buffer.getvalue(),\n",
620608
" ContentType='application/x-npy')\n",
621609
"\n",
@@ -635,15 +623,8 @@
635623
"metadata": {},
636624
"outputs": [],
637625
"source": [
638-
"sm_boto3.delete_endpoint(EndpointName=endpoint_name)"
626+
"sm_boto3.delete_endpoint(EndpointName=predictor.endpoint)"
639627
]
640-
},
641-
{
642-
"cell_type": "code",
643-
"execution_count": null,
644-
"metadata": {},
645-
"outputs": [],
646-
"source": []
647628
}
648629
],
649630
"metadata": {

0 commit comments

Comments
 (0)