Skip to content

Commit

Permalink
Fix: hub model reference arn enum bug when constructing from arn (#4972)
Browse files Browse the repository at this point in the history
* Fix hub model reference arn enum bug

* Add unit test for construct hub model reference arn util

* fix broken unit test

* formatting: add extra newline after unit test

* fix broken unit test

* fix formatting

* add more newlines around test

* codestyle: fix line too long

* Revert "codestyle: fix line too long"

This reverts commit 0b6867a.

* fix test

* add missing quote

---------

Co-authored-by: parknate@ <[email protected]>
  • Loading branch information
kc1998dp and sage-maker authored Dec 30, 2024
1 parent 8be4568 commit 2102bb7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sagemaker/jumpstart/hub/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def construct_hub_model_reference_arn_from_inputs(
info = get_info_from_hub_resource_arn(hub_arn)
arn = (
f"arn:{info.partition}:sagemaker:{info.region}:{info.account_id}:hub-content/"
f"{info.hub_name}/{HubContentType.MODEL_REFERENCE}/{model_name}/{version}"
f"{info.hub_name}/{HubContentType.MODEL_REFERENCE.value}/{model_name}/{version}"
)

return arn
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/sagemaker/jumpstart/hub/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ def test_construct_hub_model_arn_from_inputs():
)


def test_construct_hub_model_reference_arn_from_inputs():
model_name, version = "pytorch-ic-imagenet-v2", "1.0.2"
hub_arn = "arn:aws:sagemaker:us-west-2:123456789123:hub/my-mock-hub"
hub_content_arn_prefix = "arn:aws:sagemaker:us-west-2:123456789123:hub-content/my-mock-hub"

assert (
utils.construct_hub_model_reference_arn_from_inputs(hub_arn, model_name, version)
== hub_content_arn_prefix + "/ModelReference/pytorch-ic-imagenet-v2/1.0.2"
)

version = "*"
assert (
utils.construct_hub_model_reference_arn_from_inputs(hub_arn, model_name, version)
== hub_content_arn_prefix + "/ModelReference/pytorch-ic-imagenet-v2/*"
)


def test_generate_hub_arn_for_init_kwargs():
hub_name = "my-hub-name"
hub_arn = "arn:aws:sagemaker:us-west-2:12346789123:hub/my-awesome-hub"
Expand Down

0 comments on commit 2102bb7

Please sign in to comment.