-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: jumpstart model package arn instance type variants #4186
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,18 @@ | |
# language governing permissions and limitations under the License. | ||
from __future__ import absolute_import | ||
import unittest | ||
from unittest.mock import Mock | ||
|
||
|
||
from mock.mock import patch | ||
import pytest | ||
|
||
from sagemaker.jumpstart import artifacts | ||
from sagemaker.jumpstart.artifacts.model_packages import _retrieve_model_package_arn | ||
from sagemaker.jumpstart.enums import JumpStartScriptScope | ||
|
||
from tests.unit.sagemaker.jumpstart.utils import get_spec_from_base_spec | ||
from tests.unit.sagemaker.jumpstart.utils import get_spec_from_base_spec, get_special_model_spec | ||
from tests.unit.sagemaker.workflow.conftest import mock_client | ||
|
||
|
||
@patch("sagemaker.jumpstart.accessors.JumpStartModelsAccessor.get_model_specs") | ||
|
@@ -129,3 +134,109 @@ def test_estimator_fit_kwargs(self, patched_get_model_specs): | |
) | ||
|
||
assert kwargs == {"some-estimator-fit-key": "some-estimator-fit-value"} | ||
|
||
|
||
class RetrieveModelPackageArnTest(unittest.TestCase): | ||
|
||
mock_session = Mock(s3_client=mock_client) | ||
|
||
@patch("sagemaker.jumpstart.accessors.JumpStartModelsAccessor.get_model_specs") | ||
def test_retrieve_model_package_arn(self, patched_get_model_specs): | ||
patched_get_model_specs.side_effect = get_special_model_spec | ||
|
||
model_id = "variant-model" | ||
region = "us-west-2" | ||
|
||
assert ( | ||
_retrieve_model_package_arn( | ||
region=region, | ||
model_id=model_id, | ||
scope=JumpStartScriptScope.INFERENCE, | ||
model_version="*", | ||
sagemaker_session=self.mock_session, | ||
instance_type="ml.p2.48xlarge", | ||
) | ||
== "us-west-2/blah/blah/blah/gpu" | ||
) | ||
|
||
assert ( | ||
_retrieve_model_package_arn( | ||
region=region, | ||
model_id=model_id, | ||
scope=JumpStartScriptScope.INFERENCE, | ||
model_version="*", | ||
sagemaker_session=self.mock_session, | ||
instance_type="ml.p4.2xlarge", | ||
) | ||
== "us-west-2/blah/blah/blah/gpu" | ||
) | ||
|
||
assert ( | ||
_retrieve_model_package_arn( | ||
region=region, | ||
model_id=model_id, | ||
scope=JumpStartScriptScope.INFERENCE, | ||
model_version="*", | ||
sagemaker_session=self.mock_session, | ||
instance_type="ml.inf1.2xlarge", | ||
) | ||
== "us-west-2/blah/blah/blah/inf" | ||
) | ||
|
||
assert ( | ||
_retrieve_model_package_arn( | ||
region=region, | ||
model_id=model_id, | ||
scope=JumpStartScriptScope.INFERENCE, | ||
model_version="*", | ||
sagemaker_session=self.mock_session, | ||
instance_type="ml.inf2.12xlarge", | ||
) | ||
== "us-west-2/blah/blah/blah/inf" | ||
) | ||
|
||
assert ( | ||
_retrieve_model_package_arn( | ||
region=region, | ||
model_id=model_id, | ||
scope=JumpStartScriptScope.INFERENCE, | ||
model_version="*", | ||
sagemaker_session=self.mock_session, | ||
instance_type="ml.afasfasf.12xlarge", | ||
) | ||
== "arn:aws:sagemaker:us-west-2:594846645681:model-package/llama2-7b-v3-740347e540da35b4ab9f6fc0ab3fed2c" | ||
) | ||
|
||
assert ( | ||
_retrieve_model_package_arn( | ||
region=region, | ||
model_id=model_id, | ||
scope=JumpStartScriptScope.INFERENCE, | ||
model_version="*", | ||
sagemaker_session=self.mock_session, | ||
instance_type="ml.m2.12xlarge", | ||
) | ||
== "arn:aws:sagemaker:us-west-2:594846645681:model-package/llama2-7b-v3-740347e540da35b4ab9f6fc0ab3fed2c" | ||
) | ||
|
||
assert ( | ||
_retrieve_model_package_arn( | ||
region=region, | ||
model_id=model_id, | ||
scope=JumpStartScriptScope.INFERENCE, | ||
model_version="*", | ||
sagemaker_session=self.mock_session, | ||
instance_type="nobodycares", | ||
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. that's tough :( 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. wait till you receive the bill :) |
||
) | ||
== "arn:aws:sagemaker:us-west-2:594846645681:model-package/llama2-7b-v3-740347e540da35b4ab9f6fc0ab3fed2c" | ||
) | ||
|
||
with pytest.raises(ValueError): | ||
_retrieve_model_package_arn( | ||
region="cn-north-1", | ||
model_id=model_id, | ||
scope=JumpStartScriptScope.INFERENCE, | ||
model_version="*", | ||
sagemaker_session=self.mock_session, | ||
instance_type="ml.p2.12xlarge", | ||
) | ||
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. Just confirming, we are going to release this in the SDK and bump SE version before 10/18 to make the last Studio cutoff before ReInvent right? 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. i believe so |
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.
Don't we need to do the same for
_retrieve_model_package_model_artifact_s3_uri()
?