-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: jumpstart EULA models #3999
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2367d16
feat: jumpstart EULA models (initial commit)
evakravi 5af2b17
chore: add support for custom attributes to predictor class
evakravi 01ff3e5
chore: address PR comments, fix failing tests
evakravi 882773e
chore: modify metadata keys, add unit test for custom attributes
evakravi 2d5f5ec
fix: s3 public url for china regions
evakravi 09c05f4
chore: use hosting_model_package_arns
evakravi 4913109
chore: improve EULA logging message
evakravi 19668b1
Merge remote-tracking branch 'origin' into feat/jumpstart-eula-models
evakravi 422e0ba
fix: unit test constant
evakravi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
"""This module contains functions for obtaining JumpStart model packages.""" | ||
from __future__ import absolute_import | ||
from typing import Optional | ||
from sagemaker.jumpstart.constants import ( | ||
JUMPSTART_DEFAULT_REGION_NAME, | ||
) | ||
from sagemaker.jumpstart.utils import ( | ||
verify_model_region_and_return_specs, | ||
) | ||
from sagemaker.jumpstart.enums import ( | ||
JumpStartScriptScope, | ||
) | ||
|
||
|
||
def _retrieve_model_package_arn( | ||
model_id: str, | ||
model_version: str, | ||
region: Optional[str], | ||
scope: Optional[str] = None, | ||
tolerate_vulnerable_model: bool = False, | ||
tolerate_deprecated_model: bool = False, | ||
) -> Optional[str]: | ||
"""Retrieves associated model pacakge arn for the model. | ||
|
||
Args: | ||
model_id (str): JumpStart model ID of the JumpStart model for which to | ||
retrieve the model package arn. | ||
model_version (str): Version of the JumpStart model for which to retrieve the | ||
model package arn. | ||
region (Optional[str]): Region for which to retrieve the model package arn. | ||
scope (Optional[str]): Scope for which to retrieve the model package arn. | ||
tolerate_vulnerable_model (bool): True if vulnerable versions of model | ||
specifications should be tolerated (exception not raised). If False, raises an | ||
exception if the script used by this version of the model has dependencies with known | ||
security vulnerabilities. (Default: False). | ||
tolerate_deprecated_model (bool): True if deprecated versions of model | ||
specifications should be tolerated (exception not raised). If False, raises | ||
an exception if the version of the model is deprecated. (Default: False). | ||
|
||
Returns: | ||
str: the model package arn to use for the model or None. | ||
""" | ||
|
||
if region is None: | ||
region = JUMPSTART_DEFAULT_REGION_NAME | ||
|
||
model_specs = verify_model_region_and_return_specs( | ||
model_id=model_id, | ||
version=model_version, | ||
scope=scope, | ||
region=region, | ||
tolerate_vulnerable_model=tolerate_vulnerable_model, | ||
tolerate_deprecated_model=tolerate_deprecated_model, | ||
) | ||
|
||
if scope == JumpStartScriptScope.INFERENCE: | ||
|
||
if model_specs.hosting_model_package_arns is None: | ||
return None | ||
|
||
regional_arn = model_specs.hosting_model_package_arns.get(region) | ||
|
||
return regional_arn | ||
|
||
raise NotImplementedError(f"Model Package ARN not supported for scope: '{scope}'") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -402,6 +402,17 @@ def verify_model_region_and_return_specs( | |
f"JumpStart model ID '{model_id}' and version '{version}' " "does not support training." | ||
) | ||
|
||
if model_specs.hosting_eula_key and scope == constants.JumpStartScriptScope.INFERENCE.value: | ||
LOGGER.info( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See prior comment, we can perhaps give them the ability to retrieve the EULA from our public bucket |
||
"Model '%s' requires accepting end-user license agreement (EULA). " | ||
"See https://%s.s3.%s.amazonaws.com%s/%s for terms of use.", | ||
model_id, | ||
get_jumpstart_content_bucket(region=region), | ||
region, | ||
".cn" if region.startswith("cn-") else "", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. callout: this may not work for gov-cloud. |
||
model_specs.hosting_eula_key, | ||
) | ||
|
||
if model_specs.deprecated: | ||
if not tolerate_deprecated_model: | ||
raise DeprecatedJumpStartModelError(model_id=model_id, version=version) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit^2: missing period
.
at the end of the docstring.