Skip to content

feature: Add support for accelerator in Clarify #2249

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 6 commits into from
Apr 8, 2021
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
9 changes: 6 additions & 3 deletions src/sagemaker/clarify.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def __init__(
content_type=None,
content_template=None,
custom_attributes=None,
accelerator_type=None,
):
"""Initializes a configuration of a model and the endpoint to be created for it.

Expand Down Expand Up @@ -151,6 +152,9 @@ def __init__(
Section 3.3.6. Field Value Components (
https://tools.ietf.org/html/rfc7230#section-3.2.6) of the Hypertext Transfer
Protocol (HTTP/1.1).
accelerator_type (str): The Elastic Inference accelerator type to deploy to the model
endpoint instance for making inferences to the model, see
https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html.
"""
self.predictor_config = {
"model_name": model_name,
Expand Down Expand Up @@ -178,9 +182,8 @@ def __init__(
f" Please include a placeholder $features."
)
self.predictor_config["content_template"] = content_template

if custom_attributes is not None:
self.predictor_config["custom_attributes"] = custom_attributes
_set(custom_attributes, "custom_attributes", self.predictor_config)
_set(accelerator_type, "accelerator_type", self.predictor_config)

def get_predictor_config(self):
"""Returns part of the predictor dictionary of the analysis config."""
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_clarify.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@ def test_model_config():
accept_type = "text/csv"
content_type = "application/jsonlines"
custom_attributes = "c000b4f9-df62-4c85-a0bf-7c525f9104a4"
accelerator_type = "ml.eia1.medium"
model_config = ModelConfig(
model_name=model_name,
instance_type=instance_type,
instance_count=instance_count,
accept_type=accept_type,
content_type=content_type,
custom_attributes=custom_attributes,
accelerator_type=accelerator_type,
)
expected_config = {
"model_name": model_name,
Expand All @@ -107,6 +109,7 @@ def test_model_config():
"accept_type": accept_type,
"content_type": content_type,
"custom_attributes": custom_attributes,
"accelerator_type": accelerator_type,
}
assert expected_config == model_config.get_predictor_config()

Expand Down