Skip to content

Commit 8ab188f

Browse files
authored
Merge branch 'master' into feat/jumpstart-model-url
2 parents c7cc789 + 6ce11cb commit 8ab188f

File tree

83 files changed

+1839
-419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1839
-419
lines changed

.githooks/pre-push

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ start_time=`date +%s`
1212
tox -e sphinx,doc8 --parallel all
1313
./ci-scripts/displaytime.sh 'sphinx,doc8' $start_time
1414
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
15+
tox -e py36,py37,py38,py39 --parallel all -- tests/unit
16+
./ci-scripts/displaytime.sh 'py36,py37,py38,py39 unit' $start_time

CHANGELOG.md

+57
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,62 @@
11
# Changelog
22

3+
## v2.83.0 (2022-04-04)
4+
5+
### Features
6+
7+
* Hugging Face Transformers 4.17 for TF 2.6
8+
9+
### Bug Fixes and Other Changes
10+
11+
* IOC image version select issue
12+
13+
## v2.82.2 (2022-04-01)
14+
15+
### Bug Fixes and Other Changes
16+
17+
* Revert "fix: Fix Pipeline variables related customer issues (#2959)"
18+
* Refactor repack_model script injection, fixes tar.gz error
19+
20+
## v2.82.1 (2022-03-31)
21+
22+
### Bug Fixes and Other Changes
23+
24+
* Update Inferentia Image URI Config
25+
* Fix Pipeline variables related customer issues
26+
* more logging info for static pipeline test data setup
27+
28+
## v2.82.0 (2022-03-30)
29+
30+
### Features
31+
32+
* pluggable instance fallback mechanism, add CapacityError
33+
* support passing Env Vars to local mode training
34+
35+
## v2.81.1 (2022-03-29)
36+
37+
### Bug Fixes and Other Changes
38+
39+
* Update black-check version, add support for Spark 3.1 Processing
40+
41+
## v2.81.0 (2022-03-26)
42+
43+
### Features
44+
45+
* Retrieve data configuration
46+
* enable EnableInterContainerTrafficEncryption for model monitoring
47+
* Hugging Face Transformers 4.17 for PT 1.10
48+
49+
### Bug Fixes and Other Changes
50+
51+
* remove `new` from serverless
52+
* temporarily skip tests impacted by data inconsistency
53+
* Implement override solution for pipeline variables
54+
55+
### Documentation Changes
56+
57+
* add documentation for image_uri serverless use case
58+
* minor fixes for smddp 1.4.0 doc
59+
360
## v2.80.0 (2022-03-18)
461

562
### Features

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
recursive-include src/sagemaker *.py
22

33
include src/sagemaker/image_uri_config/*.json
4+
recursive-include requirements *
45

56
include VERSION
67
include LICENSE.txt

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.80.1.dev0
1+
2.83.1.dev0

doc/overview.rst

+32-2
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,28 @@ to configure or manage the underlying infrastructure. After you trained a model,
12261226
Serverless endpoint and then invoke the endpoint with the model to get inference results back. More information about
12271227
SageMaker Serverless Inference can be found in the `AWS documentation <https://docs.aws.amazon.com/sagemaker/latest/dg/serverless-endpoints.html>`__.
12281228

1229+
For using SageMaker Serverless Inference, if you plan to use any of the SageMaker-provided container or Bring Your Own Container
1230+
model, you will need to pass ``image_uri``. An example to use ``image_uri`` for creating MXNet model:
1231+
1232+
.. code:: python
1233+
1234+
from sagemaker.mxnet import MXNetModel
1235+
import sagemaker
1236+
1237+
role = sagemaker.get_execution_role()
1238+
1239+
# create MXNet Model Class
1240+
mxnet_model = MXNetModel(
1241+
model_data="s3://my_bucket/pretrained_model/model.tar.gz", # path to your trained sagemaker model
1242+
role=role, # iam role with permissions to create an Endpoint
1243+
entry_point="inference.py",
1244+
image_uri="763104351884.dkr.ecr.us-west-2.amazonaws.com/mxnet-inference:1.4.1-cpu-py3" # image wanted to use
1245+
)
1246+
1247+
For more Amazon SageMaker provided algorithms and containers image paths, please check this page: `Amazon SageMaker provided
1248+
algorithms and Deep Learning Containers <https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html>`_.
1249+
After creating model using ``image_uri``, you can then follow the steps below to create serverless endpoint.
1250+
12291251
To deploy serverless endpoint, you will need to create a ``ServerlessInferenceConfig``.
12301252
If you create ``ServerlessInferenceConfig`` without specifying its arguments, the default ``MemorySizeInMB`` will be **2048** and
12311253
the default ``MaxConcurrency`` will be **5** :
@@ -1235,14 +1257,14 @@ the default ``MaxConcurrency`` will be **5** :
12351257
from sagemaker.serverless import ServerlessInferenceConfig
12361258
12371259
# Create an empty ServerlessInferenceConfig object to use default values
1238-
serverless_config = new ServerlessInferenceConfig()
1260+
serverless_config = ServerlessInferenceConfig()
12391261
12401262
Or you can specify ``MemorySizeInMB`` and ``MaxConcurrency`` in ``ServerlessInferenceConfig`` (example shown below):
12411263

12421264
.. code:: python
12431265
12441266
# Specify MemorySizeInMB and MaxConcurrency in the serverless config object
1245-
serverless_config = new ServerlessInferenceConfig(
1267+
serverless_config = ServerlessInferenceConfig(
12461268
memory_size_in_mb=4096,
12471269
max_concurrency=10,
12481270
)
@@ -1254,6 +1276,14 @@ Then use the ``ServerlessInferenceConfig`` in the estimator's ``deploy()`` metho
12541276
# Deploys the model that was generated by fit() to a SageMaker serverless endpoint
12551277
serverless_predictor = estimator.deploy(serverless_inference_config=serverless_config)
12561278
1279+
Or directly using model's ``deploy()`` method to deploy a serverless endpoint:
1280+
1281+
.. code:: python
1282+
1283+
# Deploys the model to a SageMaker serverless endpoint
1284+
serverless_predictor = model.deploy(serverless_inference_config=serverless_config)
1285+
1286+
12571287
After deployment is complete, you can use predictor's ``predict()`` method to invoke the serverless endpoint just like
12581288
real-time endpoints:
12591289

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
urllib3==1.26.8
2+
docker-compose==1.29.2
3+
docker~=5.0.0
4+
PyYAML==5.4.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scipy==1.5.4
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
tox==3.24.5
2+
flake8==4.0.1
3+
pytest==6.0.2
4+
pytest-cov==3.0.0
5+
pytest-rerunfailures==10.2
6+
pytest-timeout==2.1.0
7+
pytest-xdist==2.4.0
8+
coverage>=5.2, <6.2
9+
mock==4.0.3
10+
contextlib2==21.6.0
11+
awslogs==0.14.0
12+
black==22.3.0
13+
stopit==1.1.2
14+
apache-airflow==2.2.4
15+
apache-airflow-providers-amazon==3.0.0
16+
attrs==20.3.0
17+
fabric==2.6.0
18+
requests==2.27.1
19+
sagemaker-experiments==0.1.35
20+
Jinja2==3.0.3
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
doc8==0.10.1
2+
Pygments==2.11.2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pydocstyle==6.1.1
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
flake8==4.0.1
2+
flake8-future-import==0.4.6
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mypy==0.942
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pydocstyle==6.1.1
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pylint==2.6.2
2+
astroid==2.4.2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pyenchant==3.2.2
2+
pylint==2.6.2
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
twine==3.8.0

setup.py

+19-32
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import os
1717
from glob import glob
1818

19-
from setuptools import setup, find_packages
19+
from setuptools import find_packages, setup
2020

2121

2222
def read(fname):
@@ -31,6 +31,20 @@ def read_version():
3131
return read("VERSION").strip()
3232

3333

34+
def read_requirements(filename):
35+
"""Reads requirements file which lists package dependencies.
36+
37+
Args:
38+
filename: type(str) Relative file path of requirements.txt file
39+
40+
Returns:
41+
list of dependencies extracted from file
42+
"""
43+
with open(os.path.abspath(filename)) as fp:
44+
deps = [line.strip() for line in fp.readlines()]
45+
return deps
46+
47+
3448
# Declare minimal set for installation
3549
required_packages = [
3650
"attrs==20.3.0",
@@ -47,42 +61,15 @@ def read_version():
4761
]
4862

4963
# Specific use case dependencies
64+
# Keep format of *_requirements.txt to be tracked by dependabot
5065
extras = {
51-
"local": [
52-
"urllib3==1.26.8",
53-
"docker-compose==1.29.2",
54-
"docker~=5.0.0",
55-
"PyYAML==5.4.1", # PyYAML version has to match docker-compose requirements
56-
],
57-
"scipy": ["scipy==1.5.4"],
66+
"local": read_requirements("requirements/extras/local_requirements.txt"),
67+
"scipy": read_requirements("requirements/extras/scipy_requirements.txt"),
5868
}
5969
# Meta dependency groups
6070
extras["all"] = [item for group in extras.values() for item in group]
6171
# Tests specific dependencies (do not need to be included in 'all')
62-
extras["test"] = (
63-
[
64-
extras["all"],
65-
"tox==3.24.5",
66-
"flake8==4.0.1",
67-
"pytest==6.0.2",
68-
"pytest-cov==3.0.0",
69-
"pytest-rerunfailures==10.2",
70-
"pytest-timeout==2.1.0",
71-
"pytest-xdist==2.4.0",
72-
"coverage>=5.2, <6.2",
73-
"mock==4.0.3",
74-
"contextlib2==21.6.0",
75-
"awslogs==0.14.0",
76-
"black==22.1.0",
77-
"stopit==1.1.2",
78-
"apache-airflow==2.2.3",
79-
"apache-airflow-providers-amazon==3.0.0",
80-
"attrs==20.3.0",
81-
"fabric==2.6.0",
82-
"requests==2.27.1",
83-
"sagemaker-experiments==0.1.35",
84-
],
85-
)
72+
extras["test"] = (extras["all"] + read_requirements("requirements/extras/test_requirements.txt"),)
8673

8774
setup(
8875
name="sagemaker",

src/sagemaker/chainer/model.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,14 @@ def __init__(
9999
file which should be executed as the entry point to model
100100
hosting. If ``source_dir`` is specified, then ``entry_point``
101101
must point to a file located at the root of ``source_dir``.
102-
image_uri (str): A Docker image URI (default: None). If not specified, a
103-
default image for Chainer will be used. If ``framework_version``
104-
or ``py_version`` are ``None``, then ``image_uri`` is required. If
105-
also ``None``, then a ``ValueError`` will be raised.
102+
image_uri (str): A Docker image URI (default: None). In serverless
103+
inferece, it is required. More image information can be found in
104+
`Amazon SageMaker provided algorithms and Deep Learning Containers
105+
<https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html>`_.
106+
In instance based inference, if not specified, a default image for
107+
Chainer will be used. If ``framework_version`` or ``py_version``
108+
are ``None``, then ``image_uri`` is required. If also ``None``,
109+
then a ``ValueError`` will be raised.
106110
framework_version (str): Chainer version you want to use for
107111
executing your model training code. Defaults to ``None``. Required
108112
unless ``image_uri`` is provided.

src/sagemaker/estimator.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@
7474
get_config_value,
7575
name_from_base,
7676
)
77-
from sagemaker.workflow.entities import Expression
78-
from sagemaker.workflow.parameters import Parameter
79-
from sagemaker.workflow.properties import Properties
77+
from sagemaker.workflow.entities import PipelineVariable
8078

8179
logger = logging.getLogger(__name__)
8280

@@ -602,7 +600,7 @@ def _json_encode_hyperparameters(hyperparameters: Dict[str, Any]) -> Dict[str, A
602600
current_hyperparameters = hyperparameters
603601
if current_hyperparameters is not None:
604602
hyperparameters = {
605-
str(k): (v if isinstance(v, (Parameter, Expression, Properties)) else json.dumps(v))
603+
str(k): (v.to_string() if isinstance(v, PipelineVariable) else json.dumps(v))
606604
for (k, v) in current_hyperparameters.items()
607605
}
608606
return hyperparameters
@@ -1813,7 +1811,7 @@ def _get_train_args(cls, estimator, inputs, experiment_config):
18131811
current_hyperparameters = estimator.hyperparameters()
18141812
if current_hyperparameters is not None:
18151813
hyperparameters = {
1816-
str(k): (v if isinstance(v, (Parameter, Expression, Properties)) else str(v))
1814+
str(k): (v.to_string() if isinstance(v, PipelineVariable) else str(v))
18171815
for (k, v) in current_hyperparameters.items()
18181816
}
18191817

src/sagemaker/exceptions.py

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ def __init__(self, message, allowed_statuses, actual_status):
2323
super(UnexpectedStatusException, self).__init__(message)
2424

2525

26+
class CapacityError(UnexpectedStatusException):
27+
"""Raised when resource status is not expected and fails with a reason of CapacityError"""
28+
29+
2630
class AsyncInferenceError(Exception):
2731
"""The base exception class for Async Inference exceptions."""
2832

src/sagemaker/huggingface/model.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ def __init__(
133133
py_version (str): Python version you want to use for executing your
134134
model training code. Defaults to ``None``. Required unless
135135
``image_uri`` is provided.
136-
image_uri (str): A Docker image URI. Defaults to None. If not specified, a
136+
image_uri (str): A Docker image URI. Defaults to None. For serverless
137+
inferece, it is required. More image information can be found in
138+
`Amazon SageMaker provided algorithms and Deep Learning Containers
139+
<https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html>`_.
140+
For instance based inference, if not specified, a
137141
default image for PyTorch will be used. If ``framework_version``
138142
or ``py_version`` are ``None``, then ``image_uri`` is required. If
139143
also ``None``, then a ``ValueError`` will be raised.

0 commit comments

Comments
 (0)