-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Curated hub improvements #4760
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
Aditi2424
merged 28 commits into
aws:master
from
malav-shastri:curated_hub_improvements
Jul 10, 2024
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
b1f5cd8
fix: list_models() for python3.8
6b9f390
fix linting
cb66608
fix: Address nits and improvements
964de22
Merge branch 'aws:master' into curated_hub_improvements
malav-shastri 5392504
fix codestyle issues
269dc08
fix: don't force automatic bucket creation if user don't specify it
502063f
fix formatting
f553357
fix flake8
7571a55
Merge branch 'aws:master' into curated_hub_improvements
malav-shastri 5ab02e4
address nits
37a36c8
revert HUB_ARN_REGEX and HUB_CONTENT_ARN_REGEX constants from types.p…
3fe2774
revert: don't force automatic bucket creation if user don't specify it
10dba2c
fix: fix _add_tags_to_kwargs to use hub_content_arn instead of hub_arn
5449eb5
fix codestyle issues
559ef2e
feat: Add support for Hub in model attach functionality
7e307bf
feat: Add curatedHub telemetry support
5f7e955
Address codestyledoc issues
38495dc
fix failing unit tests
90006f6
fix failing tests
c331b0c
change default session object in hub class to one with user agent string
ac45eea
fix flake8
2f07130
address comments: moving get default JS session to constructor body
6fb3223
Address comments: only add is_hub_content to user aggent suffix if it…
0f3f434
try with ModelReference first then with Model type
65b61a6
fix: describe_model if hub_name has been explicitly provided
d8b173d
Address comments
ccb640c
Merge branch 'master' into curated_hub_improvements
malav-shastri 2f5f29b
Address merge conflicts
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
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 |
---|---|---|
|
@@ -23,7 +23,6 @@ | |
from sagemaker.session import Session | ||
|
||
from sagemaker.jumpstart.constants import ( | ||
DEFAULT_JUMPSTART_SAGEMAKER_SESSION, | ||
JUMPSTART_LOGGER, | ||
) | ||
from sagemaker.jumpstart.types import ( | ||
|
@@ -68,7 +67,7 @@ def __init__( | |
self, | ||
hub_name: str, | ||
bucket_name: Optional[str] = None, | ||
sagemaker_session: Optional[Session] = DEFAULT_JUMPSTART_SAGEMAKER_SESSION, | ||
sagemaker_session: Optional[Session] = None, | ||
) -> None: | ||
"""Instantiates a SageMaker ``Hub``. | ||
|
||
|
@@ -79,7 +78,10 @@ def __init__( | |
""" | ||
self.hub_name = hub_name | ||
self.region = sagemaker_session.boto_region_name | ||
self._sagemaker_session = sagemaker_session | ||
self._sagemaker_session = ( | ||
sagemaker_session | ||
or utils.get_default_jumpstart_session_with_user_agent_suffix(is_hub_content=True) | ||
) | ||
self.hub_storage_location = self._generate_hub_storage_location(bucket_name) | ||
|
||
def _fetch_hub_bucket_name(self) -> str: | ||
|
@@ -274,8 +276,8 @@ def describe_model( | |
try: | ||
model_version = get_hub_model_version( | ||
hub_model_name=model_name, | ||
hub_model_type=HubContentType.MODEL.value, | ||
hub_name=self.hub_name, | ||
hub_model_type=HubContentType.MODEL_REFERENCE.value, | ||
hub_name=self.hub_name if not hub_name else hub_name, | ||
sagemaker_session=self._sagemaker_session, | ||
hub_model_version=model_version, | ||
) | ||
|
@@ -284,24 +286,27 @@ def describe_model( | |
hub_name=self.hub_name if not hub_name else hub_name, | ||
hub_content_name=model_name, | ||
hub_content_version=model_version, | ||
hub_content_type=HubContentType.MODEL.value, | ||
hub_content_type=HubContentType.MODEL_REFERENCE.value, | ||
) | ||
|
||
except Exception as ex: | ||
logging.info("Recieved expection while calling APIs for ContentType Model: " + str(ex)) | ||
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. typo |
||
logging.info( | ||
"Received exeption while calling APIs for ContentType ModelReference, retrying with ContentType Model: " | ||
+ str(ex) | ||
) | ||
model_version = get_hub_model_version( | ||
hub_model_name=model_name, | ||
hub_model_type=HubContentType.MODEL_REFERENCE.value, | ||
hub_name=self.hub_name, | ||
hub_model_type=HubContentType.MODEL.value, | ||
hub_name=self.hub_name if not hub_name else hub_name, | ||
sagemaker_session=self._sagemaker_session, | ||
hub_model_version=model_version, | ||
) | ||
|
||
hub_content_description: Dict[str, Any] = self._sagemaker_session.describe_hub_content( | ||
hub_name=self.hub_name, | ||
hub_name=self.hub_name if not hub_name else hub_name, | ||
hub_content_name=model_name, | ||
hub_content_version=model_version, | ||
hub_content_type=HubContentType.MODEL_REFERENCE.value, | ||
hub_content_type=HubContentType.MODEL.value, | ||
) | ||
|
||
return DescribeHubContentResponse(hub_content_description) |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.