Skip to content

change: add deprecation warnings for estimator.delete_endpoint() and tuner.delete_endpoint() #1644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/sagemaker/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,11 @@ def delete_endpoint(self):
Raises:
botocore.exceptions.ClientError: If the endpoint does not exist.
"""
logging.warning(
"estimator.delete_endpoint() will be deprecated in SageMaker Python SDK v2. "
"Please use the delete_endpoint() function on your predictor instead."
)

self._ensure_latest_training_job(error_message="Endpoint was not created yet")
self.sagemaker_session.delete_endpoint(self.latest_training_job.name)

Expand Down
5 changes: 5 additions & 0 deletions src/sagemaker/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,11 @@ def delete_endpoint(self, endpoint_name=None):
Args:
endpoint_name (str): Name of the endpoint to delete
"""
logging.warning(
"HyperparameterTuner.delete_endpoint() will be deprecated in SageMaker Python SDK v2. "
"Please use the delete_endpoint() function on your predictor instead."
)

endpoint_name = endpoint_name or self.best_training_job()
self.sagemaker_session.delete_endpoint(endpoint_name)

Expand Down
19 changes: 19 additions & 0 deletions tests/unit/test_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,25 @@ def test_delete_endpoint_without_endpoint(sagemaker_session):
assert "Endpoint was not created yet" in str(error)


def test_delete_endpoint_deprecation_warning(sagemaker_session, caplog):
fw = DummyFramework(
entry_point=SCRIPT_PATH,
role="DummyRole",
sagemaker_session=sagemaker_session,
train_instance_count=INSTANCE_COUNT,
train_instance_type=INSTANCE_TYPE,
)
fw.latest_training_job = Mock(name="job")

fw.delete_endpoint()

expected_warning = (
"estimator.delete_endpoint() will be deprecated in SageMaker Python SDK v2. "
"Please use the delete_endpoint() function on your predictor instead."
)
assert expected_warning in caplog.text


def test_enable_cloudwatch_metrics(sagemaker_session):
fw = DummyFramework(
entry_point=SCRIPT_PATH,
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,17 @@ def test_delete_endpoint(tuner):
tuner.sagemaker_session.delete_endpoint.assert_called_with(JOB_NAME)


def test_delete_endpoint_deprecation_warning(tuner, caplog):
tuner.best_training_job = Mock()
tuner.delete_endpoint()

expected_warning = (
"HyperparameterTuner.delete_endpoint() will be deprecated in SageMaker Python SDK v2. "
"Please use the delete_endpoint() function on your predictor instead."
)
assert expected_warning in caplog.text


def test_fit_no_inputs(tuner, sagemaker_session):
script_path = os.path.join(DATA_DIR, "mxnet_mnist", "failure_script.py")
tuner.estimator = MXNet(
Expand Down