Skip to content

feat: Add target_model to support multi-model endpoints #3215

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 11, 2022
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
5 changes: 5 additions & 0 deletions src/sagemaker/clarify.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def __init__(
custom_attributes=None,
accelerator_type=None,
endpoint_name_prefix=None,
target_model=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a required param?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No

):
r"""Initializes a configuration of a model and the endpoint to be created for it.
Expand Down Expand Up @@ -234,6 +235,9 @@ def __init__(
for making inferences to the model.
endpoint_name_prefix (str): The endpoint name prefix of a new endpoint. Must follow
pattern ``^[a-zA-Z0-9](-\*[a-zA-Z0-9]``.
target_model (str): Sets the target model name when using a multi-model endpoint. For
more information about multi-model endpoints, see
https://docs.aws.amazon.com/sagemaker/latest/dg/multi-model-endpoints.html
Raises:
ValueError: when the ``endpoint_name_prefix`` is invalid, ``accept_type`` is invalid,
Expand Down Expand Up @@ -281,6 +285,7 @@ def __init__(
self.predictor_config["content_template"] = content_template
_set(custom_attributes, "custom_attributes", self.predictor_config)
_set(accelerator_type, "accelerator_type", self.predictor_config)
_set(target_model, "target_model", 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 @@ -240,6 +240,7 @@ def test_model_config():
accept_type = "text/csv"
content_type = "application/jsonlines"
custom_attributes = "c000b4f9-df62-4c85-a0bf-7c525f9104a4"
target_model = "target_model_name"
accelerator_type = "ml.eia1.medium"
model_config = ModelConfig(
model_name=model_name,
Expand All @@ -249,6 +250,7 @@ def test_model_config():
content_type=content_type,
custom_attributes=custom_attributes,
accelerator_type=accelerator_type,
target_model=target_model,
)
expected_config = {
"model_name": model_name,
Expand All @@ -258,6 +260,7 @@ def test_model_config():
"content_type": content_type,
"custom_attributes": custom_attributes,
"accelerator_type": accelerator_type,
"target_model": target_model,
}
assert expected_config == model_config.get_predictor_config()

Expand Down