Skip to content

Commit 62304b5

Browse files
committed
Remove supplemental containers from sdk
1 parent f298f54 commit 62304b5

File tree

3 files changed

+18
-62
lines changed

3 files changed

+18
-62
lines changed

src/sagemaker/session.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def train(self, image, input_mode, input_config, role, job_name, output_config,
238238
LOGGER.debug('train request: {}'.format(json.dumps(train_request, indent=4)))
239239
self.sagemaker_client.create_training_job(**train_request)
240240

241-
def create_model(self, name, role, primary_container, supplemental_containers=None):
241+
def create_model(self, name, role, primary_container):
242242
"""Create an Amazon SageMaker ``Model``.
243243
244244
Specify the S3 location of the model artifacts and Docker image containing
@@ -253,36 +253,27 @@ def create_model(self, name, role, primary_container, supplemental_containers=No
253253
primary_container (str or dict[str, str]): Docker image which defines the inference code.
254254
You can also specify the return value of ``sagemaker.container_def()``, which is used to create
255255
more advanced container configurations, including model containers which need artifacts from S3.
256-
supplemental_containers (list[str or dict[str, str]]): List of Docker images which define
257-
additional containers that need to be run in addition to the primary container (default: None).
258-
You can also specify the return values of ``sagemaker.container_def()``, which the API uses to create
259-
more advanced container configurations, including model containers which need artifacts from S3.
260256
261257
Returns:
262258
str: Name of the Amazon SageMaker ``Model`` created.
263259
"""
264260
role = self.expand_role(role)
265261
primary_container = _expand_container_def(primary_container)
266-
if supplemental_containers is None:
267-
supplemental_containers = []
268-
supplemental_containers = [_expand_container_def(sc) for sc in supplemental_containers]
269262
LOGGER.info('Creating model with name: {}'.format(name))
270263
LOGGER.debug("create_model request: {}".format({
271264
'name': name,
272265
'role': role,
273-
'primary_container': primary_container,
274-
'supplemental_containers': supplemental_containers
266+
'primary_container': primary_container
275267
}))
276268

277269
self.sagemaker_client.create_model(ModelName=name,
278270
PrimaryContainer=primary_container,
279-
SupplementalContainers=supplemental_containers,
280271
ExecutionRoleArn=role)
281272

282273
return name
283274

284275
def create_model_from_job(self, training_job_name, name=None, role=None, primary_container_image=None,
285-
model_data_url=None, env={}, supplemental_containers=None):
276+
model_data_url=None, env={}):
286277
"""Create an Amazon SageMaker ``Model`` from a SageMaker Training Job.
287278
288279
Args:
@@ -296,8 +287,6 @@ def create_model_from_job(self, training_job_name, name=None, role=None, primary
296287
model_data_url (str): S3 location of the model data (default: None). If None, defaults to
297288
the ``ModelS3Artifacts`` of ``training_job_name``.
298289
env (dict[string,string]): Model environment variables (default: {}).
299-
supplemental_containers (list[dict[str, str]]): A list of supplemental Docker containers
300-
(default: None). Defines the ``SupplementalContainers`` property on the created ``Model``.
301290
302291
Returns:
303292
str: The name of the created ``Model``.
@@ -309,7 +298,7 @@ def create_model_from_job(self, training_job_name, name=None, role=None, primary
309298
primary_container_image or training_job['AlgorithmSpecification']['TrainingImage'],
310299
model_data_url=model_data_url or training_job['ModelArtifacts']['S3ModelArtifacts'],
311300
env=env)
312-
return self.create_model(name, role, primary_container, supplemental_containers)
301+
return self.create_model(name, role, primary_container)
313302

314303
def create_endpoint_config(self, name, model_name, initial_instance_count, instance_type):
315304
"""Create an Amazon SageMaker endpoint configuration.

tests/unit/test_create_deploy_entities.py

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License"). You
4-
# may not use this file except in compliance with the License. A copy of
5-
# the License is located at
6-
#
7-
# http://aws.amazon.com/apache2.0/
8-
#
9-
# or in the "license" file accompanying this file. This file is
10-
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11-
# ANY KIND, either express or implied. See the License for the specific
12-
# language governing permissions and limitations under the License.
1+
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
1313
import pytest
1414
from mock import Mock
1515

@@ -36,46 +36,23 @@ def sagemaker_session():
3636

3737

3838
def test_create_model(sagemaker_session):
39-
supplemental_containers = [FULL_CONTAINER_DEF, FULL_CONTAINER_DEF]
4039

41-
returned_name = sagemaker_session.create_model(name=MODEL_NAME, role=ROLE, primary_container=FULL_CONTAINER_DEF,
42-
supplemental_containers=supplemental_containers)
40+
returned_name = sagemaker_session.create_model(name=MODEL_NAME, role=ROLE, primary_container=FULL_CONTAINER_DEF)
4341

4442
assert returned_name == MODEL_NAME
4543
sagemaker_session.sagemaker_client.create_model.assert_called_once_with(
4644
ModelName=MODEL_NAME,
4745
PrimaryContainer=FULL_CONTAINER_DEF,
48-
SupplementalContainers=supplemental_containers,
4946
ExecutionRoleArn=EXPANDED_ROLE)
5047

5148

52-
def test_create_model_no_supplemental_containers(sagemaker_session):
53-
sagemaker_session.create_model(name=MODEL_NAME, role=ROLE, primary_container=FULL_CONTAINER_DEF)
54-
55-
_1, _2, create_model_kwargs = sagemaker_session.sagemaker_client.create_model.mock_calls[0]
56-
assert create_model_kwargs['SupplementalContainers'] == []
57-
58-
5949
def test_create_model_expand_primary_container(sagemaker_session):
6050
sagemaker_session.create_model(name=MODEL_NAME, role=ROLE, primary_container=IMAGE)
6151

6252
_1, _2, create_model_kwargs = sagemaker_session.sagemaker_client.create_model.mock_calls[0]
6353
assert create_model_kwargs['PrimaryContainer'] == {'Environment': {}, 'Image': IMAGE}
6454

6555

66-
def test_create_model_expand_supplemental_containers(sagemaker_session):
67-
supp_image1 = 'suppimage1'
68-
supp_image2 = 'suppimage2'
69-
supplemental_containers = [supp_image1, supp_image2]
70-
71-
sagemaker_session.create_model(name=MODEL_NAME, role=ROLE, primary_container=IMAGE,
72-
supplemental_containers=supplemental_containers)
73-
74-
expected = [{'Environment': {}, 'Image': supp_image1}, {'Environment': {}, 'Image': supp_image2}]
75-
_1, _2, create_model_kwargs = sagemaker_session.sagemaker_client.create_model.mock_calls[0]
76-
assert create_model_kwargs['SupplementalContainers'] == expected
77-
78-
7956
def test_create_endpoint_config(sagemaker_session):
8057
returned_name = sagemaker_session.create_endpoint_config(name=ENDPOINT_CONFIG_NAME, model_name=MODEL_NAME,
8158
initial_instance_count=INITIAL_INSTANCE_COUNT,

tests/unit/test_session.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ def test_create_model_from_job(sagemaker_session):
331331
ModelName='jobname',
332332
PrimaryContainer={
333333
'Environment': {}, 'ModelDataUrl': 's3://sagemaker-123/output/jobname/model/model.tar.gz',
334-
'Image': 'myimage'},
335-
SupplementalContainers=[])
334+
'Image': 'myimage'})
336335

337336

338337
def test_create_model_from_job_with_image(sagemaker_session):
@@ -355,15 +354,6 @@ def test_create_model_from_job_with_container_def(sagemaker_session):
355354
assert c_def['Environment'] == {'a': 'b'}
356355

357356

358-
def test_create_model_from_job_with_supplemental_containers(sagemaker_session):
359-
ims = sagemaker_session
360-
ims.sagemaker_client.describe_training_job.return_value = COMPLETED_DESCRIBE_JOB_RESULT
361-
ims.create_model_from_job(JOB_NAME, supplemental_containers=[sagemaker.container_def('some-image')])
362-
[create_model_call] = ims.sagemaker_client.create_model.call_args_list
363-
[c_def] = create_model_call[1]['SupplementalContainers']
364-
assert c_def['Image'] == 'some-image'
365-
366-
367357
def test_endpoint_from_production_variants(sagemaker_session):
368358
ims = sagemaker_session
369359
ims.sagemaker_client.describe_endpoint = Mock(return_value={'EndpointStatus': 'InService'})

0 commit comments

Comments
 (0)