Skip to content

fix: add kms_key optional arg to Pipeline.deploy() #1962

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 4 commits into from
Oct 22, 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
6 changes: 6 additions & 0 deletions src/sagemaker/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def deploy(
wait=True,
update_endpoint=False,
data_capture_config=None,
kms_key=None,
):
"""Deploy the ``Model`` to an ``Endpoint``.

Expand Down Expand Up @@ -156,6 +157,9 @@ def deploy(
data_capture_config (sagemaker.model_monitor.DataCaptureConfig): Specifies
configuration related to Endpoint data capture for use with
Amazon SageMaker Model Monitoring. Default: None.
kms_key (str): The ARN, Key ID or Alias of the KMS key that is used to
encrypt the data on the storage volume attached to the instance hosting
the endpoint.

Returns:
callable[string, sagemaker.session.Session] or None: Invocation of
Expand Down Expand Up @@ -192,6 +196,7 @@ def deploy(
initial_instance_count=initial_instance_count,
instance_type=instance_type,
tags=tags,
kms_key=kms_key,
data_capture_config_dict=data_capture_config_dict,
)
self.sagemaker_session.update_endpoint(
Expand All @@ -202,6 +207,7 @@ def deploy(
name=self.endpoint_name,
production_variants=[production_variant],
tags=tags,
kms_key=kms_key,
wait=wait,
data_capture_config_dict=data_capture_config_dict,
)
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/test_pipeline_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def test_deploy(tfo, time, sagemaker_session):
model = PipelineModel(
models=[framework_model, sparkml_model], role=ROLE, sagemaker_session=sagemaker_session
)
model.deploy(instance_type=INSTANCE_TYPE, initial_instance_count=1)
kms_key = "pipeline-model-deploy-kms-key"
model.deploy(instance_type=INSTANCE_TYPE, initial_instance_count=1, kms_key=kms_key)
sagemaker_session.endpoint_from_production_variants.assert_called_with(
name="mi-1-2017-10-10-14-14-15",
production_variants=[
Expand All @@ -126,6 +127,7 @@ def test_deploy(tfo, time, sagemaker_session):
}
],
tags=None,
kms_key=kms_key,
wait=True,
data_capture_config_dict=None,
)
Expand Down Expand Up @@ -154,6 +156,7 @@ def test_deploy_endpoint_name(tfo, time, sagemaker_session):
}
],
tags=None,
kms_key=None,
wait=True,
data_capture_config_dict=None,
)
Expand Down Expand Up @@ -183,6 +186,7 @@ def test_deploy_update_endpoint(tfo, time, sagemaker_session):
initial_instance_count=INSTANCE_COUNT,
instance_type=INSTANCE_TYPE,
tags=None,
kms_key=None,
data_capture_config_dict=None,
)
config_name = sagemaker_session.create_endpoint_config(
Expand Down Expand Up @@ -275,6 +279,7 @@ def test_deploy_tags(tfo, time, sagemaker_session):
],
tags=tags,
wait=True,
kms_key=None,
data_capture_config_dict=None,
)

Expand Down