Skip to content

breaking: deprecate update_endpoint arg in deploy() #1661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/sagemaker/automl/automl.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ def deploy(
endpoint_name=None,
tags=None,
wait=True,
update_endpoint=False,
vpc_config=None,
enable_network_isolation=False,
model_kms_key=None,
Expand Down Expand Up @@ -372,11 +371,6 @@ def deploy(
specific endpoint.
wait (bool): Whether the call should wait until the deployment of
model completes (default: True).
update_endpoint (bool): Flag to update the model in an existing
Amazon SageMaker endpoint. If True, this will deploy a new
EndpointConfig to an already existing endpoint and delete
resources corresponding to the previous EndpointConfig. If
False, a new endpoint will be created. Default: False
vpc_config (dict): Specifies a VPC that your training jobs and hosted models have
access to. Contents include "SecurityGroupIds" and "Subnets".
enable_network_isolation (bool): Isolates the training container. No inbound or
Expand Down Expand Up @@ -414,7 +408,6 @@ def deploy(
endpoint_name=endpoint_name,
tags=tags,
wait=wait,
update_endpoint=update_endpoint,
)

def _check_problem_type_and_job_objective(self, problem_type, job_objective):
Expand Down
7 changes: 0 additions & 7 deletions src/sagemaker/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,6 @@ def deploy(
accelerator_type=None,
endpoint_name=None,
use_compiled_model=False,
update_endpoint=False,
wait=True,
model_name=None,
kms_key=None,
Expand Down Expand Up @@ -670,11 +669,6 @@ def deploy(
used.
use_compiled_model (bool): Flag to select whether to use compiled
(optimized) model. Default: False.
update_endpoint (bool): Flag to update the model in an existing
Amazon SageMaker endpoint. If True, this will deploy a new
EndpointConfig to an already existing endpoint and delete
resources corresponding to the previous EndpointConfig. Default:
False
wait (bool): Whether the call should wait until the deployment of
model completes (default: True).
model_name (str): Name to use for creating an Amazon SageMaker
Expand Down Expand Up @@ -728,7 +722,6 @@ def deploy(
initial_instance_count=initial_instance_count,
accelerator_type=accelerator_type,
endpoint_name=endpoint_name,
update_endpoint=update_endpoint,
tags=tags or self.tags,
wait=wait,
kms_key=kms_key,
Expand Down
37 changes: 8 additions & 29 deletions src/sagemaker/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ def deploy(
instance_type,
accelerator_type=None,
endpoint_name=None,
update_endpoint=False,
tags=None,
kms_key=None,
wait=True,
Expand Down Expand Up @@ -444,11 +443,6 @@ def deploy(
https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html
endpoint_name (str): The name of the endpoint to create (default:
None). If not specified, a unique endpoint name will be created.
update_endpoint (bool): Flag to update the model in an existing
Amazon SageMaker endpoint. If True, this will deploy a new
EndpointConfig to an already existing endpoint and delete
resources corresponding to the previous EndpointConfig. If
False, a new endpoint will be created. Default: False
tags (List[dict[str, str]]): The list of tags to attach to this
specific endpoint.
kms_key (str): The ARN of the KMS key that is used to encrypt the
Expand Down Expand Up @@ -497,29 +491,14 @@ def deploy(
if data_capture_config is not None:
data_capture_config_dict = data_capture_config._to_request_dict()

if update_endpoint:
endpoint_config_name = self.sagemaker_session.create_endpoint_config(
name=self.name,
model_name=self.name,
initial_instance_count=initial_instance_count,
instance_type=instance_type,
accelerator_type=accelerator_type,
tags=tags,
kms_key=kms_key,
data_capture_config_dict=data_capture_config_dict,
)
self.sagemaker_session.update_endpoint(
self.endpoint_name, endpoint_config_name, wait=wait
)
else:
self.sagemaker_session.endpoint_from_production_variants(
name=self.endpoint_name,
production_variants=[production_variant],
tags=tags,
kms_key=kms_key,
wait=wait,
data_capture_config_dict=data_capture_config_dict,
)
self.sagemaker_session.endpoint_from_production_variants(
name=self.endpoint_name,
production_variants=[production_variant],
tags=tags,
kms_key=kms_key,
wait=wait,
data_capture_config_dict=data_capture_config_dict,
)

if self.predictor_cls:
return self.predictor_cls(self.endpoint_name, self.sagemaker_session)
Expand Down
37 changes: 8 additions & 29 deletions src/sagemaker/multidatamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ def deploy(
instance_type,
accelerator_type=None,
endpoint_name=None,
update_endpoint=False,
tags=None,
kms_key=None,
wait=True,
Expand Down Expand Up @@ -179,11 +178,6 @@ def deploy(
https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html
endpoint_name (str): The name of the endpoint to create (default:
None). If not specified, a unique endpoint name will be created.
update_endpoint (bool): Flag to update the model in an existing
Amazon SageMaker endpoint. If True, this will deploy a new
EndpointConfig to an already existing endpoint and delete
resources corresponding to the previous EndpointConfig. If
False, a new endpoint will be created. Default: False
tags (List[dict[str, str]]): The list of tags to attach to this
specific endpoint.
kms_key (str): The ARN of the KMS key that is used to encrypt the
Expand Down Expand Up @@ -241,29 +235,14 @@ def deploy(
if data_capture_config is not None:
data_capture_config_dict = data_capture_config._to_request_dict()

if update_endpoint:
endpoint_config_name = self.sagemaker_session.create_endpoint_config(
name=self.name,
model_name=self.name,
initial_instance_count=initial_instance_count,
instance_type=instance_type,
accelerator_type=accelerator_type,
tags=tags,
kms_key=kms_key,
data_capture_config_dict=data_capture_config_dict,
)
self.sagemaker_session.update_endpoint(
self.endpoint_name, endpoint_config_name, wait=wait
)
else:
self.sagemaker_session.endpoint_from_production_variants(
name=self.endpoint_name,
production_variants=[production_variant],
tags=tags,
kms_key=kms_key,
wait=wait,
data_capture_config_dict=data_capture_config_dict,
)
self.sagemaker_session.endpoint_from_production_variants(
name=self.endpoint_name,
production_variants=[production_variant],
tags=tags,
kms_key=kms_key,
wait=wait,
data_capture_config_dict=data_capture_config_dict,
)

if predictor:
return predictor(self.endpoint_name, self.sagemaker_session)
Expand Down
2 changes: 0 additions & 2 deletions src/sagemaker/tensorflow/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ def deploy(
instance_type,
accelerator_type=None,
endpoint_name=None,
update_endpoint=False,
tags=None,
kms_key=None,
wait=True,
Expand All @@ -217,7 +216,6 @@ def deploy(
instance_type=instance_type,
accelerator_type=accelerator_type,
endpoint_name=endpoint_name,
update_endpoint=update_endpoint,
tags=tags,
kms_key=kms_key,
wait=wait,
Expand Down
37 changes: 0 additions & 37 deletions tests/integ/test_mxnet_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,43 +247,6 @@ def test_deploy_model_and_update_endpoint(
assert new_config["ProductionVariants"][0]["InitialInstanceCount"] == 1


def test_deploy_model_with_update_non_existing_endpoint(
mxnet_training_job,
sagemaker_session,
mxnet_full_version,
mxnet_full_py_version,
cpu_instance_type,
alternative_cpu_instance_type,
):
endpoint_name = "test-mxnet-deploy-model-{}".format(sagemaker_timestamp())
expected_error_message = (
'Endpoint with name "{}" does not exist; '
"please use an existing endpoint name".format(endpoint_name)
)

with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
desc = sagemaker_session.sagemaker_client.describe_training_job(
TrainingJobName=mxnet_training_job
)
model_data = desc["ModelArtifacts"]["S3ModelArtifacts"]
script_path = os.path.join(DATA_DIR, "mxnet_mnist", "mnist.py")
model = MXNetModel(
model_data,
"SageMakerRole",
entry_point=script_path,
py_version=mxnet_full_py_version,
sagemaker_session=sagemaker_session,
framework_version=mxnet_full_version,
)
model.deploy(1, alternative_cpu_instance_type, endpoint_name=endpoint_name)
sagemaker_session.sagemaker_client.describe_endpoint(EndpointName=endpoint_name)

with pytest.raises(ValueError, message=expected_error_message):
model.deploy(
1, cpu_instance_type, update_endpoint=True, endpoint_name="non-existing-endpoint"
)


@pytest.mark.canary_quick
@pytest.mark.regional_testing
@pytest.mark.skipif(
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/sagemaker/automl/test_auto_ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@ def test_deploy_optional_args(candidate_estimator, sagemaker_session, candidate_
endpoint_name=JOB_NAME,
tags=TAGS,
wait=False,
update_endpoint=True,
vpc_config=VPC_CONFIG,
enable_network_isolation=True,
model_kms_key=OUTPUT_KMS_KEY,
Expand Down Expand Up @@ -591,7 +590,6 @@ def test_deploy_optional_args(candidate_estimator, sagemaker_session, candidate_
endpoint_name=JOB_NAME,
tags=TAGS,
wait=False,
update_endpoint=True,
)


Expand Down
66 changes: 0 additions & 66 deletions tests/unit/sagemaker/model/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,69 +266,3 @@ def test_deploy_predictor_cls(production_variant, sagemaker_session):
assert isinstance(predictor, sagemaker.predictor.Predictor)
assert predictor.endpoint_name == endpoint_name
assert predictor.sagemaker_session == sagemaker_session


def test_deploy_update_endpoint(sagemaker_session):
model = Model(MODEL_IMAGE, MODEL_DATA, role=ROLE, sagemaker_session=sagemaker_session)
model.deploy(
instance_type=INSTANCE_TYPE, initial_instance_count=INSTANCE_COUNT, update_endpoint=True
)
sagemaker_session.create_endpoint_config.assert_called_with(
name=model.name,
model_name=model.name,
initial_instance_count=INSTANCE_COUNT,
instance_type=INSTANCE_TYPE,
accelerator_type=None,
tags=None,
kms_key=None,
data_capture_config_dict=None,
)
config_name = sagemaker_session.create_endpoint_config(
name=model.name,
model_name=model.name,
initial_instance_count=INSTANCE_COUNT,
instance_type=INSTANCE_TYPE,
accelerator_type=ACCELERATOR_TYPE,
)
sagemaker_session.update_endpoint.assert_called_with(model.name, config_name, wait=True)
sagemaker_session.create_endpoint.assert_not_called()


def test_deploy_update_endpoint_optional_args(sagemaker_session):
endpoint_name = "endpoint-name"
tags = [{"Key": "Value"}]
kms_key = "foo"
data_capture_config = Mock()

model = Model(MODEL_IMAGE, MODEL_DATA, role=ROLE, sagemaker_session=sagemaker_session)
model.deploy(
instance_type=INSTANCE_TYPE,
initial_instance_count=INSTANCE_COUNT,
update_endpoint=True,
endpoint_name=endpoint_name,
accelerator_type=ACCELERATOR_TYPE,
tags=tags,
kms_key=kms_key,
wait=False,
data_capture_config=data_capture_config,
)
sagemaker_session.create_endpoint_config.assert_called_with(
name=model.name,
model_name=model.name,
initial_instance_count=INSTANCE_COUNT,
instance_type=INSTANCE_TYPE,
accelerator_type=ACCELERATOR_TYPE,
tags=tags,
kms_key=kms_key,
data_capture_config_dict=data_capture_config._to_request_dict(),
)
config_name = sagemaker_session.create_endpoint_config(
name=model.name,
model_name=model.name,
initial_instance_count=INSTANCE_COUNT,
instance_type=INSTANCE_TYPE,
accelerator_type=ACCELERATOR_TYPE,
wait=False,
)
sagemaker_session.update_endpoint.assert_called_with(endpoint_name, config_name, wait=False)
sagemaker_session.create_endpoint.assert_not_called()
24 changes: 0 additions & 24 deletions tests/unit/test_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,6 @@ def test_generic_to_deploy_kms(create_model, sagemaker_session):
initial_instance_count=INSTANCE_COUNT,
accelerator_type=None,
endpoint_name=endpoint_name,
update_endpoint=False,
tags=None,
wait=True,
kms_key=kms_key,
Expand Down Expand Up @@ -2190,29 +2189,6 @@ def test_generic_deploy_accelerator_type(sagemaker_session):
assert args["production_variants"][0]["InstanceType"] == INSTANCE_TYPE


def test_deploy_with_update_endpoint(sagemaker_session):
estimator = Estimator(
IMAGE_NAME,
ROLE,
INSTANCE_COUNT,
INSTANCE_TYPE,
output_path=OUTPUT_PATH,
sagemaker_session=sagemaker_session,
)
estimator.set_hyperparameters(**HYPERPARAMS)
estimator.fit({"train": "s3://bucket/training-prefix"})
endpoint_name = "endpoint-name"
estimator.deploy(
INSTANCE_COUNT, INSTANCE_TYPE, endpoint_name=endpoint_name, update_endpoint=True
)

update_endpoint_args = sagemaker_session.update_endpoint.call_args[0]
assert update_endpoint_args[0] == endpoint_name
assert update_endpoint_args[1].startWith(IMAGE_NAME)

sagemaker_session.create_endpoint.assert_not_called()


def test_deploy_with_model_name(sagemaker_session):
estimator = Estimator(
IMAGE_NAME,
Expand Down
Loading