Skip to content

Commit b6ce6b6

Browse files
authored
Merge branch 'zwei' into clean-up-tests-bc-no-more-python-2-skl
2 parents a787e47 + 4f54ab9 commit b6ce6b6

Some content is hidden

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

51 files changed

+330
-164
lines changed

doc/api/inference/predictors.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Predictors
33

44
Make real-time predictions against SageMaker endpoints with Python objects
55

6-
.. autoclass:: sagemaker.predictor.RealTimePredictor
6+
.. autoclass:: sagemaker.predictor.Predictor
77
:members:
88
:undoc-members:
99
:show-inheritance:

doc/frameworks/chainer/using_chainer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ You can provide your own implementations for these functions in your hosting scr
325325
If you omit any definition then the SageMaker Chainer model server will use its default implementation for that
326326
function.
327327

328-
The ``RealTimePredictor`` used by Chainer in the SageMaker Python SDK serializes NumPy arrays to the `NPY <https://docs.scipy.org/doc/numpy/neps/npy-format.html>`_ format
328+
The ``Predictor`` used by Chainer in the SageMaker Python SDK serializes NumPy arrays to the `NPY <https://docs.scipy.org/doc/numpy/neps/npy-format.html>`_ format
329329
by default, with Content-Type ``application/x-npy``. The SageMaker Chainer model server can deserialize NPY-formatted
330330
data (along with JSON and CSV data).
331331

doc/frameworks/pytorch/using_pytorch.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ You can provide your own implementations for these functions in your hosting scr
417417
If you omit any definition then the SageMaker PyTorch model server will use its default implementation for that
418418
function.
419419

420-
The ``RealTimePredictor`` used by PyTorch in the SageMaker Python SDK serializes NumPy arrays to the `NPY <https://docs.scipy.org/doc/numpy/neps/npy-format.html>`_ format
420+
The ``Predictor`` used by PyTorch in the SageMaker Python SDK serializes NumPy arrays to the `NPY <https://docs.scipy.org/doc/numpy/neps/npy-format.html>`_ format
421421
by default, with Content-Type ``application/x-npy``. The SageMaker PyTorch model server can deserialize NPY-formatted
422422
data (along with JSON and CSV data).
423423

doc/frameworks/sklearn/using_sklearn.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ You can provide your own implementations for these functions in your hosting scr
299299
If you omit any definition then the SageMaker Scikit-learn model server will use its default implementation for that
300300
function.
301301

302-
The ``RealTimePredictor`` used by Scikit-learn in the SageMaker Python SDK serializes NumPy arrays to the `NPY <https://docs.scipy.org/doc/numpy/neps/npy-format.html>`_ format
302+
The ``Predictor`` used by Scikit-learn in the SageMaker Python SDK serializes NumPy arrays to the `NPY <https://docs.scipy.org/doc/numpy/neps/npy-format.html>`_ format
303303
by default, with Content-Type ``application/x-npy``. The SageMaker Scikit-learn model server can deserialize NPY-formatted
304304
data (along with JSON and CSV data).
305305

doc/frameworks/tensorflow/upgrade_from_legacy.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,16 @@ From a model:
206206
Predictors
207207
----------
208208

209-
If you want to use your model for endpoints, then you can use the :class:`sagemaker.predictor.RealTimePredictor` class instead of the legacy ``sagemaker.tensorflow.TensorFlowPredictor`` class:
209+
If you want to use your model for endpoints, then you can use the :class:`sagemaker.predictor.Predictor` class instead of the legacy ``sagemaker.tensorflow.TensorFlowPredictor`` class:
210210

211211
.. code:: python
212212
213213
from sagemaker.model import FrameworkModel
214-
from sagemaker.predictor import RealTimePredictor
214+
from sagemaker.predictor import Predictor
215215
216216
model = FrameworkModel(
217217
...
218-
predictor_cls=RealTimePredictor,
218+
predictor_cls=Predictor,
219219
)
220220
221221
predictor = model.deploy(...)

doc/overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ How do I make predictions against an existing endpoint?
11241124
Create a ``Predictor`` object and provide it with your endpoint name,
11251125
then call its ``predict()`` method with your input.
11261126
1127-
You can use either the generic ``RealTimePredictor`` class, which by default does not perform any serialization/deserialization transformations on your input,
1127+
You can use either the generic ``Predictor`` class, which by default does not perform any serialization/deserialization transformations on your input,
11281128
but can be configured to do so through constructor arguments:
11291129
http://sagemaker.readthedocs.io/en/stable/predictors.html
11301130

src/sagemaker/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
from sagemaker.model import Model, ModelPackage # noqa: F401
5151
from sagemaker.pipeline import PipelineModel # noqa: F401
52-
from sagemaker.predictor import RealTimePredictor # noqa: F401
52+
from sagemaker.predictor import Predictor # noqa: F401
5353
from sagemaker.processing import Processor, ScriptProcessor # noqa: F401
5454
from sagemaker.session import Session # noqa: F401
5555
from sagemaker.session import container_def, pipeline_container_def # noqa: F401

src/sagemaker/algorithm.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from sagemaker import vpc_utils
1919
from sagemaker.estimator import EstimatorBase
2020
from sagemaker.transformer import Transformer
21-
from sagemaker.predictor import RealTimePredictor
21+
from sagemaker.predictor import Predictor
2222

2323

2424
class AlgorithmEstimator(EstimatorBase):
@@ -246,15 +246,15 @@ def create_model(
246246
"""Create a model to deploy.
247247
248248
The serializer, deserializer, content_type, and accept arguments are
249-
only used to define a default RealTimePredictor. They are ignored if an
249+
only used to define a default Predictor. They are ignored if an
250250
explicit predictor class is passed in. Other arguments are passed
251251
through to the Model class.
252252
253253
Args:
254254
role (str): The ``ExecutionRoleArn`` IAM Role ARN for the ``Model``,
255255
which is also used during transform jobs. If not specified, the
256256
role from the Estimator will be used.
257-
predictor_cls (RealTimePredictor): The predictor class to use when
257+
predictor_cls (Predictor): The predictor class to use when
258258
deploying the model.
259259
serializer (callable): Should accept a single argument, the input
260260
data, and return a sequence of bytes. May provide a content_type
@@ -285,9 +285,7 @@ def create_model(
285285
if predictor_cls is None:
286286

287287
def predict_wrapper(endpoint, session):
288-
return RealTimePredictor(
289-
endpoint, session, serializer, deserializer, content_type, accept
290-
)
288+
return Predictor(endpoint, session, serializer, deserializer, content_type, accept)
291289

292290
predictor_cls = predict_wrapper
293291

src/sagemaker/amazon/factorization_machines.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer
1818
from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa
1919
from sagemaker.amazon.validation import gt, isin, ge
20-
from sagemaker.predictor import RealTimePredictor
20+
from sagemaker.predictor import Predictor
2121
from sagemaker.model import Model
2222
from sagemaker.session import Session
2323
from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
@@ -261,13 +261,13 @@ def create_model(self, vpc_config_override=VPC_CONFIG_DEFAULT, **kwargs):
261261
)
262262

263263

264-
class FactorizationMachinesPredictor(RealTimePredictor):
264+
class FactorizationMachinesPredictor(Predictor):
265265
"""Performs binary-classification or regression prediction from input
266266
vectors.
267267
268268
The implementation of
269-
:meth:`~sagemaker.predictor.RealTimePredictor.predict` in this
270-
`RealTimePredictor` requires a numpy ``ndarray`` as input. The array should
269+
:meth:`~sagemaker.predictor.Predictor.predict` in this
270+
`Predictor` requires a numpy ``ndarray`` as input. The array should
271271
contain the same number of columns as the feature-dimension of the data used
272272
to fit the model this Predictor performs inference on.
273273

src/sagemaker/amazon/ipinsights.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from sagemaker.amazon.amazon_estimator import AmazonAlgorithmEstimatorBase, registry
1717
from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa
1818
from sagemaker.amazon.validation import ge, le
19-
from sagemaker.predictor import RealTimePredictor, csv_serializer, json_deserializer
19+
from sagemaker.predictor import Predictor, csv_serializer, json_deserializer
2020
from sagemaker.model import Model
2121
from sagemaker.session import Session
2222
from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
@@ -173,13 +173,13 @@ def _prepare_for_training(self, records, mini_batch_size=None, job_name=None):
173173
)
174174

175175

176-
class IPInsightsPredictor(RealTimePredictor):
176+
class IPInsightsPredictor(Predictor):
177177
"""Returns dot product of entity and IP address embeddings as a score for
178178
compatibility.
179179
180180
The implementation of
181-
:meth:`~sagemaker.predictor.RealTimePredictor.predict` in this
182-
`RealTimePredictor` requires a numpy ``ndarray`` as input. The array should
181+
:meth:`~sagemaker.predictor.Predictor.predict` in this
182+
`Predictor` requires a numpy ``ndarray`` as input. The array should
183183
contain two columns. The first column should contain the entity ID. The
184184
second column should contain the IPv4 address in dot notation.
185185
"""

src/sagemaker/amazon/kmeans.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer
1818
from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa
1919
from sagemaker.amazon.validation import gt, isin, ge, le
20-
from sagemaker.predictor import RealTimePredictor
20+
from sagemaker.predictor import Predictor
2121
from sagemaker.model import Model
2222
from sagemaker.session import Session
2323
from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
@@ -194,12 +194,12 @@ def hyperparameters(self):
194194
return hp_dict
195195

196196

197-
class KMeansPredictor(RealTimePredictor):
197+
class KMeansPredictor(Predictor):
198198
"""Assigns input vectors to their closest cluster in a KMeans model.
199199
200200
The implementation of
201-
:meth:`~sagemaker.predictor.RealTimePredictor.predict` in this
202-
`RealTimePredictor` requires a numpy ``ndarray`` as input. The array should
201+
:meth:`~sagemaker.predictor.Predictor.predict` in this
202+
`Predictor` requires a numpy ``ndarray`` as input. The array should
203203
contain the same number of columns as the feature-dimension of the data used
204204
to fit the model this Predictor performs inference on.
205205

src/sagemaker/amazon/knn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer
1818
from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa
1919
from sagemaker.amazon.validation import ge, isin
20-
from sagemaker.predictor import RealTimePredictor
20+
from sagemaker.predictor import Predictor
2121
from sagemaker.model import Model
2222
from sagemaker.session import Session
2323
from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
@@ -182,12 +182,12 @@ def _prepare_for_training(self, records, mini_batch_size=None, job_name=None):
182182
)
183183

184184

185-
class KNNPredictor(RealTimePredictor):
185+
class KNNPredictor(Predictor):
186186
"""Performs classification or regression prediction from input vectors.
187187
188188
The implementation of
189-
:meth:`~sagemaker.predictor.RealTimePredictor.predict` in this
190-
`RealTimePredictor` requires a numpy ``ndarray`` as input. The array should
189+
:meth:`~sagemaker.predictor.Predictor.predict` in this
190+
`Predictor` requires a numpy ``ndarray`` as input. The array should
191191
contain the same number of columns as the feature-dimension of the data used
192192
to fit the model this Predictor performs inference on.
193193

src/sagemaker/amazon/lda.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer
1818
from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa
1919
from sagemaker.amazon.validation import gt
20-
from sagemaker.predictor import RealTimePredictor
20+
from sagemaker.predictor import Predictor
2121
from sagemaker.model import Model
2222
from sagemaker.session import Session
2323
from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
@@ -166,12 +166,12 @@ def _prepare_for_training( # pylint: disable=signature-differs
166166
)
167167

168168

169-
class LDAPredictor(RealTimePredictor):
169+
class LDAPredictor(Predictor):
170170
"""Transforms input vectors to lower-dimesional representations.
171171
172172
The implementation of
173-
:meth:`~sagemaker.predictor.RealTimePredictor.predict` in this
174-
`RealTimePredictor` requires a numpy ``ndarray`` as input. The array should
173+
:meth:`~sagemaker.predictor.Predictor.predict` in this
174+
`Predictor` requires a numpy ``ndarray`` as input. The array should
175175
contain the same number of columns as the feature-dimension of the data used
176176
to fit the model this Predictor performs inference on.
177177

src/sagemaker/amazon/linear_learner.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer
1818
from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa
1919
from sagemaker.amazon.validation import isin, gt, lt, ge, le
20-
from sagemaker.predictor import RealTimePredictor
20+
from sagemaker.predictor import Predictor
2121
from sagemaker.model import Model
2222
from sagemaker.session import Session
2323
from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
@@ -426,13 +426,13 @@ def _prepare_for_training(self, records, mini_batch_size=None, job_name=None):
426426
)
427427

428428

429-
class LinearLearnerPredictor(RealTimePredictor):
429+
class LinearLearnerPredictor(Predictor):
430430
"""Performs binary-classification or regression prediction from input
431431
vectors.
432432
433433
The implementation of
434-
:meth:`~sagemaker.predictor.RealTimePredictor.predict` in this
435-
`RealTimePredictor` requires a numpy ``ndarray`` as input. The array should
434+
:meth:`~sagemaker.predictor.Predictor.predict` in this
435+
`Predictor` requires a numpy ``ndarray`` as input. The array should
436436
contain the same number of columns as the feature-dimension of the data used
437437
to fit the model this Predictor performs inference on.
438438

src/sagemaker/amazon/ntm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer
1818
from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa
1919
from sagemaker.amazon.validation import ge, le, isin
20-
from sagemaker.predictor import RealTimePredictor
20+
from sagemaker.predictor import Predictor
2121
from sagemaker.model import Model
2222
from sagemaker.session import Session
2323
from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
@@ -196,12 +196,12 @@ def _prepare_for_training( # pylint: disable=signature-differs
196196
)
197197

198198

199-
class NTMPredictor(RealTimePredictor):
199+
class NTMPredictor(Predictor):
200200
"""Transforms input vectors to lower-dimesional representations.
201201
202202
The implementation of
203-
:meth:`~sagemaker.predictor.RealTimePredictor.predict` in this
204-
`RealTimePredictor` requires a numpy ``ndarray`` as input. The array should
203+
:meth:`~sagemaker.predictor.Predictor.predict` in this
204+
`Predictor` requires a numpy ``ndarray`` as input. The array should
205205
contain the same number of columns as the feature-dimension of the data used
206206
to fit the model this Predictor performs inference on.
207207

src/sagemaker/amazon/object2vec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from sagemaker.amazon.amazon_estimator import AmazonAlgorithmEstimatorBase, registry
1717
from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa
1818
from sagemaker.amazon.validation import ge, le, isin
19-
from sagemaker.predictor import RealTimePredictor
19+
from sagemaker.predictor import Predictor
2020
from sagemaker.model import Model
2121
from sagemaker.session import Session
2222
from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
@@ -184,7 +184,7 @@ def __init__(
184184
may be deployed to an Amazon SageMaker Endpoint by invoking
185185
:meth:`~sagemaker.amazon.estimator.EstimatorBase.deploy`. As well as
186186
deploying an Endpoint, deploy returns a
187-
:class:`~sagemaker.amazon.RealTimePredictor` object that can be used for
187+
:class:`~sagemaker.amazon.Predictor` object that can be used for
188188
inference calls using the trained model hosted in the SageMaker
189189
Endpoint.
190190
@@ -358,7 +358,7 @@ def __init__(self, model_data, role, sagemaker_session=None, **kwargs):
358358
image,
359359
model_data,
360360
role,
361-
predictor_cls=RealTimePredictor,
361+
predictor_cls=Predictor,
362362
sagemaker_session=sagemaker_session,
363363
**kwargs
364364
)

src/sagemaker/amazon/pca.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer
1818
from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa
1919
from sagemaker.amazon.validation import gt, isin
20-
from sagemaker.predictor import RealTimePredictor
20+
from sagemaker.predictor import Predictor
2121
from sagemaker.model import Model
2222
from sagemaker.session import Session
2323
from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
@@ -178,12 +178,12 @@ def _prepare_for_training(self, records, mini_batch_size=None, job_name=None):
178178
)
179179

180180

181-
class PCAPredictor(RealTimePredictor):
181+
class PCAPredictor(Predictor):
182182
"""Transforms input vectors to lower-dimesional representations.
183183
184184
The implementation of
185-
:meth:`~sagemaker.predictor.RealTimePredictor.predict` in this
186-
`RealTimePredictor` requires a numpy ``ndarray`` as input. The array should
185+
:meth:`~sagemaker.predictor.Predictor.predict` in this
186+
`Predictor` requires a numpy ``ndarray`` as input. The array should
187187
contain the same number of columns as the feature-dimension of the data used
188188
to fit the model this Predictor performs inference on.
189189

src/sagemaker/amazon/randomcutforest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from sagemaker.amazon.common import numpy_to_record_serializer, record_deserializer
1818
from sagemaker.amazon.hyperparameter import Hyperparameter as hp # noqa
1919
from sagemaker.amazon.validation import ge, le
20-
from sagemaker.predictor import RealTimePredictor
20+
from sagemaker.predictor import Predictor
2121
from sagemaker.model import Model
2222
from sagemaker.session import Session
2323
from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
@@ -157,12 +157,12 @@ def _prepare_for_training(self, records, mini_batch_size=None, job_name=None):
157157
)
158158

159159

160-
class RandomCutForestPredictor(RealTimePredictor):
160+
class RandomCutForestPredictor(Predictor):
161161
"""Assigns an anomaly score to each of the datapoints provided.
162162
163163
The implementation of
164-
:meth:`~sagemaker.predictor.RealTimePredictor.predict` in this
165-
`RealTimePredictor` requires a numpy ``ndarray`` as input. The array should
164+
:meth:`~sagemaker.predictor.Predictor.predict` in this
165+
`Predictor` requires a numpy ``ndarray`` as input. The array should
166166
contain the same number of columns as the feature-dimension of the data used
167167
to fit the model this Predictor performs inference on.
168168

src/sagemaker/chainer/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
)
2525
from sagemaker.model import FrameworkModel, MODEL_SERVER_WORKERS_PARAM_NAME
2626
from sagemaker.chainer import defaults
27-
from sagemaker.predictor import RealTimePredictor, npy_serializer, numpy_deserializer
27+
from sagemaker.predictor import Predictor, npy_serializer, numpy_deserializer
2828

2929
logger = logging.getLogger("sagemaker")
3030

3131

32-
class ChainerPredictor(RealTimePredictor):
33-
"""A RealTimePredictor for inference against Chainer Endpoints.
32+
class ChainerPredictor(Predictor):
33+
"""A Predictor for inference against Chainer Endpoints.
3434
3535
This is able to serialize Python lists, dictionaries, and numpy arrays to
3636
multidimensional tensors for Chainer inference.

src/sagemaker/cli/compatibility/v2/ast_transformer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
modifiers.tf_legacy_mode.TensorBoardParameterRemover(),
2424
modifiers.deprecated_params.TensorFlowScriptModeParameterRemover(),
2525
modifiers.tfs.TensorFlowServingConstructorRenamer(),
26+
modifiers.airflow.ModelConfigArgModifier(),
2627
]
2728

2829
IMPORT_MODIFIERS = [modifiers.tfs.TensorFlowServingImportRenamer()]

src/sagemaker/cli/compatibility/v2/modifiers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from __future__ import absolute_import
1515

1616
from sagemaker.cli.compatibility.v2.modifiers import ( # noqa: F401 (imported but unused)
17+
airflow,
1718
deprecated_params,
1819
framework_version,
1920
tf_legacy_mode,

0 commit comments

Comments
 (0)