Skip to content

Commit e762430

Browse files
authored
Merge branch 'master' into deprecate_lambda_model
2 parents f2b2a0d + 110756e commit e762430

File tree

9 files changed

+93
-13
lines changed

9 files changed

+93
-13
lines changed

.githooks/pre-push

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
# this pre-push hook runs style checks and unit tests in python 3.6, 3.7, and 3.8 using tox.
3+
4+
set -e
5+
6+
TOX_PARALLEL_NO_SPINNER=1,
7+
PY_COLORS=0
8+
start_time=`date +%s`
9+
tox -e flake8,pylint,docstyle,black-check,twine --parallel all
10+
./ci-scripts/displaytime.sh 'flake8,pylint,docstyle,black-check,twine' $start_time
11+
start_time=`date +%s`
12+
tox -e sphinx,doc8 --parallel all
13+
./ci-scripts/displaytime.sh 'sphinx,doc8' $start_time
14+
start_time=`date +%s`
15+
tox -e py36,py37,py38 --parallel all -- tests/unit
16+
./ci-scripts/displaytime.sh 'py36,py37,py38 unit' $start_time

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v2.63.2 (2021-10-18)
4+
5+
### Bug Fixes and Other Changes
6+
7+
* Update timeouts for integ tests from 20 to 40
8+
39
## v2.63.1 (2021-10-14)
410

511
### Bug Fixes and Other Changes

README.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ You can also run them in parallel:
154154
tox -- -n auto tests/integ
155155

156156

157+
Git Hooks
158+
~~~~~~~~~
159+
160+
to enable all git hooks in the .githooks directory, run these commands in the repository directory:
161+
162+
::
163+
164+
find .git/hooks -type l -exec rm {} \;
165+
find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;
166+
167+
To enable an individual git hook, simply move it from the .githooks/ directory to the .git/hooks/ directory.
168+
157169
Building Sphinx docs
158170
~~~~~~~~~~~~~~~~~~~~
159171

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.63.2.dev0
1+
2.63.3.dev0

tests/integ/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
DATA_DIR = os.path.join(os.path.dirname(__file__), "..", "data")
2121
TRAINING_DEFAULT_TIMEOUT_MINUTES = 40
22-
TUNING_DEFAULT_TIMEOUT_MINUTES = 20
23-
TRANSFORM_DEFAULT_TIMEOUT_MINUTES = 20
22+
TUNING_DEFAULT_TIMEOUT_MINUTES = 40
23+
TRANSFORM_DEFAULT_TIMEOUT_MINUTES = 40
2424
AUTO_ML_DEFAULT_TIMEMOUT_MINUTES = 60
2525

2626
# these regions have some p2 and p3 instances, but not enough for continuous testing

tests/integ/test_marketplace.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
from sagemaker import AlgorithmEstimator, ModelPackage
2525
from sagemaker.serializers import CSVSerializer
2626
from sagemaker.tuner import IntegerParameter, HyperparameterTuner
27-
from sagemaker.utils import sagemaker_timestamp
28-
from sagemaker.utils import _aws_partition
27+
from sagemaker.utils import sagemaker_timestamp, _aws_partition, unique_name_from_base
2928
from tests.integ import DATA_DIR
3029
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
3130
from tests.integ.marketplace_utils import REGION_ACCOUNT_MAP
@@ -117,7 +116,7 @@ def test_marketplace_attach(sagemaker_session, cpu_instance_type):
117116
instance_count=1,
118117
instance_type=cpu_instance_type,
119118
sagemaker_session=sagemaker_session,
120-
base_job_name="test-marketplace",
119+
base_job_name=unique_name_from_base("test-marketplace"),
121120
)
122121

123122
train_input = mktplace.sagemaker_session.upload_data(
@@ -205,7 +204,7 @@ def test_marketplace_tuning_job(sagemaker_session, cpu_instance_type):
205204
instance_count=1,
206205
instance_type=cpu_instance_type,
207206
sagemaker_session=sagemaker_session,
208-
base_job_name="test-marketplace",
207+
base_job_name=unique_name_from_base("test-marketplace"),
209208
)
210209

211210
train_input = mktplace.sagemaker_session.upload_data(
@@ -218,7 +217,7 @@ def test_marketplace_tuning_job(sagemaker_session, cpu_instance_type):
218217

219218
tuner = HyperparameterTuner(
220219
estimator=mktplace,
221-
base_tuning_job_name="byo",
220+
base_tuning_job_name=unique_name_from_base("byo"),
222221
objective_metric_name="validation:accuracy",
223222
hyperparameter_ranges=hyperparameter_ranges,
224223
max_jobs=2,
@@ -248,7 +247,7 @@ def test_marketplace_transform_job(sagemaker_session, cpu_instance_type):
248247
instance_count=1,
249248
instance_type=cpu_instance_type,
250249
sagemaker_session=sagemaker_session,
251-
base_job_name="test-marketplace",
250+
base_job_name=unique_name_from_base("test-marketplace"),
252251
)
253252

254253
train_input = algo.sagemaker_session.upload_data(

tests/integ/test_model_monitor.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ def predictor(sagemaker_session, tensorflow_inference_latest_version):
9292
key_prefix="tensorflow-serving/models",
9393
)
9494
with tests.integ.timeout.timeout_and_delete_endpoint_by_name(
95-
endpoint_name=endpoint_name, sagemaker_session=sagemaker_session, hours=2
95+
endpoint_name=endpoint_name,
96+
sagemaker_session=sagemaker_session,
97+
hours=2,
98+
sleep_between_cleanup_attempts=20,
99+
exponential_sleep=True,
96100
):
97101
model = TensorFlowModel(
98102
model_data=model_data,

tests/integ/timeout.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def timeout_and_delete_endpoint_by_name(
5454
minutes=45,
5555
hours=0,
5656
sleep_between_cleanup_attempts=10,
57+
exponential_sleep=False,
5758
):
5859
limit = seconds + 60 * minutes + 3600 * hours
5960

@@ -83,7 +84,13 @@ def timeout_and_delete_endpoint_by_name(
8384
# avoids the inner exception to be overwritten
8485
pass
8586
# trying to delete the resource again in 10 seconds
86-
sleep(sleep_between_cleanup_attempts)
87+
if exponential_sleep:
88+
_sleep_between_cleanup_attempts = sleep_between_cleanup_attempts * (
89+
3 - attempts
90+
)
91+
else:
92+
_sleep_between_cleanup_attempts = sleep_between_cleanup_attempts
93+
sleep(_sleep_between_cleanup_attempts)
8794

8895

8996
@contextmanager
@@ -150,7 +157,9 @@ def _delete_schedules_associated_with_endpoint(sagemaker_session, endpoint_name)
150157
monitor.delete_monitoring_schedule()
151158
except Exception as e:
152159
LOGGER.warning(
153-
"Failed to delete monitor {}".format(monitor.monitoring_schedule_name), e
160+
"Failed to delete monitor {},\nError: {}".format(
161+
monitor.monitoring_schedule_name, e
162+
)
154163
)
155164

156165

tests/unit/test_timeout.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import time
2020

2121
import pytest
22-
from mock import Mock, patch
22+
from mock import Mock, patch, call
2323
import stopit
2424

2525
from botocore.exceptions import ClientError
@@ -44,6 +44,7 @@
4444
LONG_DURATION_TO_EXCEED_TIMEOUT = 0.002
4545
LONG_TIMEOUT_THAT_WILL_NEVER_BE_EXCEEDED = 10
4646
DURATION_TO_SLEEP_TO_ALLOW_BACKGROUND_THREAD_TO_COMPLETE = 0.2
47+
DURATION_TO_SLEEP = 0.01
4748

4849

4950
@pytest.fixture()
@@ -174,6 +175,39 @@ def test_timeout_and_delete_endpoint_by_name_retries_resource_deletion_on_failur
174175
assert session.delete_endpoint.call_count == 3
175176

176177

178+
@patch("tests.integ.timeout._show_logs", return_value=None, autospec=True)
179+
@patch("tests.integ.timeout._cleanup_logs", return_value=None, autospec=True)
180+
@patch(
181+
"tests.integ.timeout._delete_schedules_associated_with_endpoint",
182+
return_value=None,
183+
autospec=True,
184+
)
185+
@patch("tests.integ.timeout.sleep", return_value=None)
186+
def test_timeout_and_delete_endpoint_by_name_retries_resource_deletion_on_failure_with_exp_sleep(
187+
mock_sleep, _show_logs, _cleanup_logs, _delete_schedules_associated_with_endpoint, session
188+
):
189+
session.delete_endpoint = Mock(
190+
side_effect=ClientError(
191+
error_response={"Error": {"Code": 403, "Message": "ValidationException"}},
192+
operation_name="Unit Test",
193+
)
194+
)
195+
196+
with timeout_and_delete_endpoint_by_name(
197+
endpoint_name=ENDPOINT_NAME,
198+
sagemaker_session=session,
199+
hours=0,
200+
minutes=0,
201+
seconds=LONG_TIMEOUT_THAT_WILL_NEVER_BE_EXCEEDED,
202+
sleep_between_cleanup_attempts=DURATION_TO_SLEEP,
203+
exponential_sleep=True,
204+
):
205+
pass
206+
assert session.delete_endpoint.call_count == 3
207+
assert mock_sleep.call_count == 3
208+
assert mock_sleep.mock_calls == [call(0.01), call(0.02), call(0.03)]
209+
210+
177211
@patch("tests.integ.timeout._show_logs", return_value=None, autospec=True)
178212
@patch("tests.integ.timeout._cleanup_logs", return_value=None, autospec=True)
179213
@patch(

0 commit comments

Comments
 (0)