Skip to content

Commit c8006fa

Browse files
authored
Add Local Mode Batch Transform support. (#414)
Creating local batch transform jobs will perform all the steps locally. The serving container will be created the same way as it is for serving but then the data will be fed to it and written to the corresponding output location. Data splits and batch strategies are implemented as closely as possible to the behavior in SageMaker so that the end results are consistent.
1 parent 80ba921 commit c8006fa

20 files changed

+1465
-173
lines changed

CHANGELOG.rst

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
CHANGELOG
33
=========
44

5-
======
5+
1.11.3dev
6+
=========
7+
8+
* feature: Local Mode: Add support for Batch Inference
9+
610
1.11.2
711
======
812

913
* enhancement: Enable setting VPC config when creating/deploying models
1014
* enhancement: Local Mode: accept short lived credentials with a warning message
1115
* bug-fix: Local Mode: pass in job name as parameter for training environment variable
1216

13-
=======
1417
1.11.1
1518
======
1619

README.rst

+21
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,27 @@ Here is an end-to-end example:
226226
predictor.delete_endpoint()
227227
228228
229+
If you don't want to deploy your model locally, you can also choose to perform a Local Batch Transform Job. This is
230+
useful if you want to test your container before creating a Sagemaker Batch Transform Job. Note that the performance
231+
will not match Batch Transform Jobs hosted on SageMaker but it is still a useful tool to ensure you have everything
232+
right or if you are not dealing with huge amounts of data.
233+
234+
Here is an end-to-end example:
235+
236+
.. code:: python
237+
238+
from sagemaker.mxnet import MXNet
239+
240+
mxnet_estimator = MXNet('train.py',
241+
train_instance_type='local',
242+
train_instance_count=1)
243+
244+
mxnet_estimator.fit('file:///tmp/my_training_data')
245+
transformer = mxnet_estimator.transformer(1, 'local', assemble_with='Line', max_payload=1)
246+
transformer.transform('s3://my/transform/data, content_type='text/csv', split_type='Line')
247+
transformer.wait()
248+
249+
229250
For detailed examples of running Docker in local mode, see:
230251
231252
- `TensorFlow local mode example notebook <https://github.com/awslabs/amazon-sagemaker-examples/blob/master/sagemaker-python-sdk/tensorflow_distributed_mnist/tensorflow_local_mode_mnist.ipynb>`__.

src/sagemaker/amazon/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def write_spmatrix_to_sparse_tensor(file, array, labels=None):
153153
def read_records(file):
154154
"""Eagerly read a collection of amazon Record protobuf objects from file."""
155155
records = []
156-
for record_data in _read_recordio(file):
156+
for record_data in read_recordio(file):
157157
record = Record()
158158
record.ParseFromString(record_data)
159159
records.append(record)
@@ -183,7 +183,7 @@ def _write_recordio(f, data):
183183
f.write(padding[pad])
184184

185185

186-
def _read_recordio(f):
186+
def read_recordio(f):
187187
while(True):
188188
try:
189189
read_kmagic, = struct.unpack('I', f.read(4))

0 commit comments

Comments
 (0)