Skip to content

Commit 8eb0e57

Browse files
authored
Merge branch 'master' into P50369404
2 parents 18c25b5 + 554ba08 commit 8eb0e57

File tree

12 files changed

+267
-12
lines changed

12 files changed

+267
-12
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

src/sagemaker/deprecations.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,46 @@ def renamed_warning(phrase):
5050
_warn(f"{phrase} has been renamed")
5151

5252

53+
def deprecation_warn(name, date, msg=None):
54+
"""Raise a warning for soon to be deprecated feature in sagemaker>=2
55+
56+
Args:
57+
name (str): Name of the feature
58+
date (str): the date when the feature will be deprecated
59+
msg (str): the prefix phrase of the warning message.
60+
"""
61+
_warn(f"{name} will be deprecated on {date}.{msg}")
62+
63+
64+
def deprecation_warning(date, msg=None):
65+
"""Decorator for raising deprecation warning for a feature in sagemaker>=2
66+
67+
Args:
68+
date (str): the date when the feature will be deprecated
69+
msg (str): the prefix phrase of the warning message.
70+
71+
Usage:
72+
@deprecation_warning(msg="message", date="date")
73+
def sample_function():
74+
print("xxxx....")
75+
76+
@deprecation_warning(msg="message", date="date")
77+
class SampleClass():
78+
def __init__(self):
79+
print("xxxx....")
80+
81+
"""
82+
83+
def deprecate(obj):
84+
def wrapper(*args, **kwargs):
85+
deprecation_warn(obj.__name__, date, msg)
86+
return obj(*args, **kwargs)
87+
88+
return wrapper
89+
90+
return deprecate
91+
92+
5393
def renamed_kwargs(old_name, new_name, value, kwargs):
5494
"""Checks if the deprecated argument is in kwargs
5595
@@ -106,6 +146,28 @@ def func(*args, **kwargs): # pylint: disable=W0613
106146
return func
107147

108148

149+
def deprecated(obj):
150+
"""Decorator for raising deprecated warning for a feature in sagemaker>=2
151+
152+
Usage:
153+
@deprecated
154+
def sample_function():
155+
print("xxxx....")
156+
157+
@deprecated
158+
class SampleClass():
159+
def __init__(self):
160+
print("xxxx....")
161+
162+
"""
163+
164+
def wrapper(*args, **kwargs):
165+
removed_warning(obj.__name__)
166+
return obj(*args, **kwargs)
167+
168+
return wrapper
169+
170+
109171
def deprecated_function(func, name):
110172
"""Wrap a function with a deprecation warning.
111173

src/sagemaker/serverless/model.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@
2020
import botocore
2121

2222
from sagemaker.model import ModelBase
23-
23+
from sagemaker.deprecations import deprecation_warning
2424
from .predictor import LambdaPredictor
2525

2626

27+
@deprecation_warning(
28+
msg="Based on customer experience and feedback an"
29+
" alternative support will be added in near future",
30+
date="10/27/2021",
31+
)
2732
class LambdaModel(ModelBase):
2833
"""A model that can be deployed to Lambda."""
2934

src/sagemaker/serverless/predictor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@
2020

2121
from sagemaker import deserializers, serializers
2222
from sagemaker.predictor import PredictorBase
23+
from sagemaker.deprecations import deprecation_warning
2324

2425

26+
@deprecation_warning(
27+
msg="Based on customer experience and feedback an"
28+
" alternative support will be added in near future",
29+
date="10/27/2021",
30+
)
2531
class LambdaPredictor(PredictorBase):
2632
"""A deployed model hosted on Lambda."""
2733

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

0 commit comments

Comments
 (0)