File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,18 @@ def best_training_job(self):
208
208
except KeyError :
209
209
raise Exception ('Best training job not available for tuning job: {}' .format (self .latest_tuning_job .name ))
210
210
211
+ def delete_endpoint (self , endpoint_name = None ):
212
+ """Delete an Amazon SageMaker endpoint.
213
+
214
+ If an endpoint name is not specified, this defaults to looking for an endpoint that
215
+ shares a name with the best training job for deletion.
216
+
217
+ Args:
218
+ endpoint_name (str): Name of the endpoint to delete
219
+ """
220
+ endpoint_name = endpoint_name or self .best_training_job ()
221
+ self .sagemaker_session .delete_endpoint (endpoint_name )
222
+
211
223
def _ensure_last_tuning_job (self ):
212
224
if self .latest_tuning_job is None :
213
225
raise ValueError ('No tuning job available' )
Original file line number Diff line number Diff line change @@ -432,6 +432,17 @@ def test_wait(tuner):
432
432
tuner .estimator .sagemaker_session .wait_for_tuning_job .assert_called_once_with (JOB_NAME )
433
433
434
434
435
+ def test_delete_endpoint (tuner ):
436
+ tuner .latest_tuning_job = _TuningJob (tuner .estimator .sagemaker_session , JOB_NAME )
437
+
438
+ tuning_job_description = {'BestTrainingJob' : {'TrainingJobName' : JOB_NAME }}
439
+ tuner .estimator .sagemaker_session .sagemaker_client .describe_hyper_parameter_tuning_job = Mock (
440
+ name = 'describe_hyper_parameter_tuning_job' , return_value = tuning_job_description )
441
+
442
+ tuner .delete_endpoint ()
443
+ tuner .sagemaker_session .delete_endpoint .assert_called_with (JOB_NAME )
444
+
445
+
435
446
#################################################################################
436
447
# _ParameterRange Tests
437
448
You can’t perform that action at this time.
0 commit comments