Skip to content

capture ValidationException errors when deleting endpoints #14

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 1 commit into from
Dec 7, 2017
Merged
Changes from all commits
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
20 changes: 16 additions & 4 deletions tests/integ/timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from contextlib import contextmanager
import logging

from botocore.exceptions import ClientError

LOGGER = logging.getLogger('timeout')


Expand Down Expand Up @@ -59,8 +61,13 @@ def timeout_and_delete_endpoint(estimator, seconds=0, minutes=0, hours=0):
try:
yield [t]
finally:
estimator.delete_endpoint()
LOGGER.info('deleted endpoint')
try:
estimator.delete_endpoint()
LOGGER.info('deleted endpoint')
except ClientError as ce:
if ce.response['Error']['Code'] == 'ValidationException':
# avoids the inner exception to be overwritten
pass


@contextmanager
Expand All @@ -69,5 +76,10 @@ def timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session, second
try:
yield [t]
finally:
sagemaker_session.delete_endpoint(endpoint_name)
LOGGER.info('deleted endpoint {}'.format(endpoint_name))
try:
sagemaker_session.delete_endpoint(endpoint_name)
LOGGER.info('deleted endpoint {}'.format(endpoint_name))
except ClientError as ce:
if ce.response['Error']['Code'] == 'ValidationException':
# avoids the inner exception to be overwritten
pass