Skip to content

Commit 75198c3

Browse files
authored
breaking: deprecate update_endpoint arg in deploy() (#1661)
1 parent 89b27c8 commit 75198c3

File tree

10 files changed

+16
-245
lines changed

10 files changed

+16
-245
lines changed

src/sagemaker/automl/automl.py

-7
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ def deploy(
343343
endpoint_name=None,
344344
tags=None,
345345
wait=True,
346-
update_endpoint=False,
347346
vpc_config=None,
348347
enable_network_isolation=False,
349348
model_kms_key=None,
@@ -372,11 +371,6 @@ def deploy(
372371
specific endpoint.
373372
wait (bool): Whether the call should wait until the deployment of
374373
model completes (default: True).
375-
update_endpoint (bool): Flag to update the model in an existing
376-
Amazon SageMaker endpoint. If True, this will deploy a new
377-
EndpointConfig to an already existing endpoint and delete
378-
resources corresponding to the previous EndpointConfig. If
379-
False, a new endpoint will be created. Default: False
380374
vpc_config (dict): Specifies a VPC that your training jobs and hosted models have
381375
access to. Contents include "SecurityGroupIds" and "Subnets".
382376
enable_network_isolation (bool): Isolates the training container. No inbound or
@@ -414,7 +408,6 @@ def deploy(
414408
endpoint_name=endpoint_name,
415409
tags=tags,
416410
wait=wait,
417-
update_endpoint=update_endpoint,
418411
)
419412

420413
def _check_problem_type_and_job_objective(self, problem_type, job_objective):

src/sagemaker/estimator.py

-7
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,6 @@ def deploy(
640640
accelerator_type=None,
641641
endpoint_name=None,
642642
use_compiled_model=False,
643-
update_endpoint=False,
644643
wait=True,
645644
model_name=None,
646645
kms_key=None,
@@ -670,11 +669,6 @@ def deploy(
670669
used.
671670
use_compiled_model (bool): Flag to select whether to use compiled
672671
(optimized) model. Default: False.
673-
update_endpoint (bool): Flag to update the model in an existing
674-
Amazon SageMaker endpoint. If True, this will deploy a new
675-
EndpointConfig to an already existing endpoint and delete
676-
resources corresponding to the previous EndpointConfig. Default:
677-
False
678672
wait (bool): Whether the call should wait until the deployment of
679673
model completes (default: True).
680674
model_name (str): Name to use for creating an Amazon SageMaker
@@ -728,7 +722,6 @@ def deploy(
728722
initial_instance_count=initial_instance_count,
729723
accelerator_type=accelerator_type,
730724
endpoint_name=endpoint_name,
731-
update_endpoint=update_endpoint,
732725
tags=tags or self.tags,
733726
wait=wait,
734727
kms_key=kms_key,

src/sagemaker/model.py

+8-29
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ def deploy(
411411
instance_type,
412412
accelerator_type=None,
413413
endpoint_name=None,
414-
update_endpoint=False,
415414
tags=None,
416415
kms_key=None,
417416
wait=True,
@@ -444,11 +443,6 @@ def deploy(
444443
https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html
445444
endpoint_name (str): The name of the endpoint to create (default:
446445
None). If not specified, a unique endpoint name will be created.
447-
update_endpoint (bool): Flag to update the model in an existing
448-
Amazon SageMaker endpoint. If True, this will deploy a new
449-
EndpointConfig to an already existing endpoint and delete
450-
resources corresponding to the previous EndpointConfig. If
451-
False, a new endpoint will be created. Default: False
452446
tags (List[dict[str, str]]): The list of tags to attach to this
453447
specific endpoint.
454448
kms_key (str): The ARN of the KMS key that is used to encrypt the
@@ -497,29 +491,14 @@ def deploy(
497491
if data_capture_config is not None:
498492
data_capture_config_dict = data_capture_config._to_request_dict()
499493

500-
if update_endpoint:
501-
endpoint_config_name = self.sagemaker_session.create_endpoint_config(
502-
name=self.name,
503-
model_name=self.name,
504-
initial_instance_count=initial_instance_count,
505-
instance_type=instance_type,
506-
accelerator_type=accelerator_type,
507-
tags=tags,
508-
kms_key=kms_key,
509-
data_capture_config_dict=data_capture_config_dict,
510-
)
511-
self.sagemaker_session.update_endpoint(
512-
self.endpoint_name, endpoint_config_name, wait=wait
513-
)
514-
else:
515-
self.sagemaker_session.endpoint_from_production_variants(
516-
name=self.endpoint_name,
517-
production_variants=[production_variant],
518-
tags=tags,
519-
kms_key=kms_key,
520-
wait=wait,
521-
data_capture_config_dict=data_capture_config_dict,
522-
)
494+
self.sagemaker_session.endpoint_from_production_variants(
495+
name=self.endpoint_name,
496+
production_variants=[production_variant],
497+
tags=tags,
498+
kms_key=kms_key,
499+
wait=wait,
500+
data_capture_config_dict=data_capture_config_dict,
501+
)
523502

524503
if self.predictor_cls:
525504
return self.predictor_cls(self.endpoint_name, self.sagemaker_session)

src/sagemaker/multidatamodel.py

+8-29
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ def deploy(
144144
instance_type,
145145
accelerator_type=None,
146146
endpoint_name=None,
147-
update_endpoint=False,
148147
tags=None,
149148
kms_key=None,
150149
wait=True,
@@ -179,11 +178,6 @@ def deploy(
179178
https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html
180179
endpoint_name (str): The name of the endpoint to create (default:
181180
None). If not specified, a unique endpoint name will be created.
182-
update_endpoint (bool): Flag to update the model in an existing
183-
Amazon SageMaker endpoint. If True, this will deploy a new
184-
EndpointConfig to an already existing endpoint and delete
185-
resources corresponding to the previous EndpointConfig. If
186-
False, a new endpoint will be created. Default: False
187181
tags (List[dict[str, str]]): The list of tags to attach to this
188182
specific endpoint.
189183
kms_key (str): The ARN of the KMS key that is used to encrypt the
@@ -241,29 +235,14 @@ def deploy(
241235
if data_capture_config is not None:
242236
data_capture_config_dict = data_capture_config._to_request_dict()
243237

244-
if update_endpoint:
245-
endpoint_config_name = self.sagemaker_session.create_endpoint_config(
246-
name=self.name,
247-
model_name=self.name,
248-
initial_instance_count=initial_instance_count,
249-
instance_type=instance_type,
250-
accelerator_type=accelerator_type,
251-
tags=tags,
252-
kms_key=kms_key,
253-
data_capture_config_dict=data_capture_config_dict,
254-
)
255-
self.sagemaker_session.update_endpoint(
256-
self.endpoint_name, endpoint_config_name, wait=wait
257-
)
258-
else:
259-
self.sagemaker_session.endpoint_from_production_variants(
260-
name=self.endpoint_name,
261-
production_variants=[production_variant],
262-
tags=tags,
263-
kms_key=kms_key,
264-
wait=wait,
265-
data_capture_config_dict=data_capture_config_dict,
266-
)
238+
self.sagemaker_session.endpoint_from_production_variants(
239+
name=self.endpoint_name,
240+
production_variants=[production_variant],
241+
tags=tags,
242+
kms_key=kms_key,
243+
wait=wait,
244+
data_capture_config_dict=data_capture_config_dict,
245+
)
267246

268247
if predictor:
269248
return predictor(self.endpoint_name, self.sagemaker_session)

src/sagemaker/tensorflow/model.py

-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ def deploy(
201201
instance_type,
202202
accelerator_type=None,
203203
endpoint_name=None,
204-
update_endpoint=False,
205204
tags=None,
206205
kms_key=None,
207206
wait=True,
@@ -217,7 +216,6 @@ def deploy(
217216
instance_type=instance_type,
218217
accelerator_type=accelerator_type,
219218
endpoint_name=endpoint_name,
220-
update_endpoint=update_endpoint,
221219
tags=tags,
222220
kms_key=kms_key,
223221
wait=wait,

tests/integ/test_mxnet_train.py

-37
Original file line numberDiff line numberDiff line change
@@ -247,43 +247,6 @@ def test_deploy_model_and_update_endpoint(
247247
assert new_config["ProductionVariants"][0]["InitialInstanceCount"] == 1
248248

249249

250-
def test_deploy_model_with_update_non_existing_endpoint(
251-
mxnet_training_job,
252-
sagemaker_session,
253-
mxnet_full_version,
254-
mxnet_full_py_version,
255-
cpu_instance_type,
256-
alternative_cpu_instance_type,
257-
):
258-
endpoint_name = "test-mxnet-deploy-model-{}".format(sagemaker_timestamp())
259-
expected_error_message = (
260-
'Endpoint with name "{}" does not exist; '
261-
"please use an existing endpoint name".format(endpoint_name)
262-
)
263-
264-
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
265-
desc = sagemaker_session.sagemaker_client.describe_training_job(
266-
TrainingJobName=mxnet_training_job
267-
)
268-
model_data = desc["ModelArtifacts"]["S3ModelArtifacts"]
269-
script_path = os.path.join(DATA_DIR, "mxnet_mnist", "mnist.py")
270-
model = MXNetModel(
271-
model_data,
272-
"SageMakerRole",
273-
entry_point=script_path,
274-
py_version=mxnet_full_py_version,
275-
sagemaker_session=sagemaker_session,
276-
framework_version=mxnet_full_version,
277-
)
278-
model.deploy(1, alternative_cpu_instance_type, endpoint_name=endpoint_name)
279-
sagemaker_session.sagemaker_client.describe_endpoint(EndpointName=endpoint_name)
280-
281-
with pytest.raises(ValueError, message=expected_error_message):
282-
model.deploy(
283-
1, cpu_instance_type, update_endpoint=True, endpoint_name="non-existing-endpoint"
284-
)
285-
286-
287250
@pytest.mark.canary_quick
288251
@pytest.mark.regional_testing
289252
@pytest.mark.skipif(

tests/unit/sagemaker/automl/test_auto_ml.py

-2
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,6 @@ def test_deploy_optional_args(candidate_estimator, sagemaker_session, candidate_
563563
endpoint_name=JOB_NAME,
564564
tags=TAGS,
565565
wait=False,
566-
update_endpoint=True,
567566
vpc_config=VPC_CONFIG,
568567
enable_network_isolation=True,
569568
model_kms_key=OUTPUT_KMS_KEY,
@@ -591,7 +590,6 @@ def test_deploy_optional_args(candidate_estimator, sagemaker_session, candidate_
591590
endpoint_name=JOB_NAME,
592591
tags=TAGS,
593592
wait=False,
594-
update_endpoint=True,
595593
)
596594

597595

tests/unit/sagemaker/model/test_deploy.py

-66
Original file line numberDiff line numberDiff line change
@@ -266,69 +266,3 @@ def test_deploy_predictor_cls(production_variant, sagemaker_session):
266266
assert isinstance(predictor, sagemaker.predictor.Predictor)
267267
assert predictor.endpoint_name == endpoint_name
268268
assert predictor.sagemaker_session == sagemaker_session
269-
270-
271-
def test_deploy_update_endpoint(sagemaker_session):
272-
model = Model(MODEL_IMAGE, MODEL_DATA, role=ROLE, sagemaker_session=sagemaker_session)
273-
model.deploy(
274-
instance_type=INSTANCE_TYPE, initial_instance_count=INSTANCE_COUNT, update_endpoint=True
275-
)
276-
sagemaker_session.create_endpoint_config.assert_called_with(
277-
name=model.name,
278-
model_name=model.name,
279-
initial_instance_count=INSTANCE_COUNT,
280-
instance_type=INSTANCE_TYPE,
281-
accelerator_type=None,
282-
tags=None,
283-
kms_key=None,
284-
data_capture_config_dict=None,
285-
)
286-
config_name = sagemaker_session.create_endpoint_config(
287-
name=model.name,
288-
model_name=model.name,
289-
initial_instance_count=INSTANCE_COUNT,
290-
instance_type=INSTANCE_TYPE,
291-
accelerator_type=ACCELERATOR_TYPE,
292-
)
293-
sagemaker_session.update_endpoint.assert_called_with(model.name, config_name, wait=True)
294-
sagemaker_session.create_endpoint.assert_not_called()
295-
296-
297-
def test_deploy_update_endpoint_optional_args(sagemaker_session):
298-
endpoint_name = "endpoint-name"
299-
tags = [{"Key": "Value"}]
300-
kms_key = "foo"
301-
data_capture_config = Mock()
302-
303-
model = Model(MODEL_IMAGE, MODEL_DATA, role=ROLE, sagemaker_session=sagemaker_session)
304-
model.deploy(
305-
instance_type=INSTANCE_TYPE,
306-
initial_instance_count=INSTANCE_COUNT,
307-
update_endpoint=True,
308-
endpoint_name=endpoint_name,
309-
accelerator_type=ACCELERATOR_TYPE,
310-
tags=tags,
311-
kms_key=kms_key,
312-
wait=False,
313-
data_capture_config=data_capture_config,
314-
)
315-
sagemaker_session.create_endpoint_config.assert_called_with(
316-
name=model.name,
317-
model_name=model.name,
318-
initial_instance_count=INSTANCE_COUNT,
319-
instance_type=INSTANCE_TYPE,
320-
accelerator_type=ACCELERATOR_TYPE,
321-
tags=tags,
322-
kms_key=kms_key,
323-
data_capture_config_dict=data_capture_config._to_request_dict(),
324-
)
325-
config_name = sagemaker_session.create_endpoint_config(
326-
name=model.name,
327-
model_name=model.name,
328-
initial_instance_count=INSTANCE_COUNT,
329-
instance_type=INSTANCE_TYPE,
330-
accelerator_type=ACCELERATOR_TYPE,
331-
wait=False,
332-
)
333-
sagemaker_session.update_endpoint.assert_called_with(endpoint_name, config_name, wait=False)
334-
sagemaker_session.create_endpoint.assert_not_called()

tests/unit/test_estimator.py

-24
Original file line numberDiff line numberDiff line change
@@ -2081,7 +2081,6 @@ def test_generic_to_deploy_kms(create_model, sagemaker_session):
20812081
initial_instance_count=INSTANCE_COUNT,
20822082
accelerator_type=None,
20832083
endpoint_name=endpoint_name,
2084-
update_endpoint=False,
20852084
tags=None,
20862085
wait=True,
20872086
kms_key=kms_key,
@@ -2190,29 +2189,6 @@ def test_generic_deploy_accelerator_type(sagemaker_session):
21902189
assert args["production_variants"][0]["InstanceType"] == INSTANCE_TYPE
21912190

21922191

2193-
def test_deploy_with_update_endpoint(sagemaker_session):
2194-
estimator = Estimator(
2195-
IMAGE_NAME,
2196-
ROLE,
2197-
INSTANCE_COUNT,
2198-
INSTANCE_TYPE,
2199-
output_path=OUTPUT_PATH,
2200-
sagemaker_session=sagemaker_session,
2201-
)
2202-
estimator.set_hyperparameters(**HYPERPARAMS)
2203-
estimator.fit({"train": "s3://bucket/training-prefix"})
2204-
endpoint_name = "endpoint-name"
2205-
estimator.deploy(
2206-
INSTANCE_COUNT, INSTANCE_TYPE, endpoint_name=endpoint_name, update_endpoint=True
2207-
)
2208-
2209-
update_endpoint_args = sagemaker_session.update_endpoint.call_args[0]
2210-
assert update_endpoint_args[0] == endpoint_name
2211-
assert update_endpoint_args[1].startWith(IMAGE_NAME)
2212-
2213-
sagemaker_session.create_endpoint.assert_not_called()
2214-
2215-
22162192
def test_deploy_with_model_name(sagemaker_session):
22172193
estimator = Estimator(
22182194
IMAGE_NAME,

0 commit comments

Comments
 (0)