Skip to content

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
merged 28 commits into from
Jul 10, 2024

Conversation

malav-shastri
Copy link
Collaborator

@malav-shastri malav-shastri commented Jun 27, 2024

Issue #, if available:

Description of changes:

  • Adding support for private hubs in model attach functionality
  • Jumpstart PySDK telemetry support
  • adding hub_content_arn instead of hub_arn for adding the tags for training and inference jobs
  • Fixes and improvements

Testing done:

  • python3.10 -m pytest tests/unit/**/jumpstart/
  • end to end test, using notebook

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

  • I have read the CONTRIBUTING doc
  • I certify that the changes I am introducing will be backward compatible, and I have discussed concerns about this, if any, with the Python SDK team
  • I used the commit message format described in CONTRIBUTING
  • I have passed the region in to all S3 and STS clients that I've initialized as part of this change.
  • I have updated any necessary documentation, including READMEs and API docs (if appropriate)

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added unit and/or integration tests as appropriate to ensure backward compatibility of the changes
  • I have checked that my tests are not configured for a specific region or account (if appropriate)
  • I have used unique_name_from_base to create resource names in integ tests (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -68,7 +67,9 @@ def __init__(
self,
hub_name: str,
bucket_name: Optional[str] = None,
sagemaker_session: Optional[Session] = DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
sagemaker_session: Optional[
Copy link
Member

Choose a reason for hiding this comment

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

i wouldn't set this as a default argument since this function will get invoked whenever the module is imported, which may cause slow latency or errors on some systems. can you set in constructor body instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks changed it in the new revision


if os.getenv(constants.ENV_VARIABLE_DISABLE_JUMPSTART_TELEMETRY, None):
headers = sagemaker_python_sdk_headers
elif model_id is None and model_version is None:
Copy link
Member

Choose a reason for hiding this comment

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

can we only add the tag md/js_is_hub_content if it is a hub content? we don't want to add unnecessary characters to the user agent, there's a char limit

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks changed it in the new revision

Copy link
Contributor

@AWS-pratab AWS-pratab left a comment

Choose a reason for hiding this comment

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

Looks good over all

Comment on lines 304 to 305
"Recieved exeption while calling APIs for ContentType Model, \
retrying with ContentType ModelReference: "
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually it other way around. The code is first attempting using ModelReference and then as Model.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ohh yeah I forgot I changed it recently, let me correct this. Thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

also identified one more place where we were trying with Model first and then ModelRef. Changed that as well, in the Hub class. Thanks

Copy link
Contributor

@JGuinegagne JGuinegagne left a comment

Choose a reason for hiding this comment

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

Careful with backward compatibility

@@ -307,6 +299,21 @@ def get_model_specs(
model_specs.set_hub_content_type(HubContentType.MODEL_REFERENCE)
return model_specs

except Exception as ex:
logging.info(
"Recieved exeption while calling APIs for ContentType ModelReference, \
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: Recieved - please also check error message with @judyheflin

Copy link
Contributor

Choose a reason for hiding this comment

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

also, high-level question for future PRs: shall we retry on all types of error? As in, if retry throttling as well?

That may be fine, but just want to make sure that's a conscious decision.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah I think its fine to retry on all error types but now that I am thinking about it I feel like I can just restrict retry with a different contentType only in the case of ResourceNotFound errors

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

regardless engaging with @judyheflin for the error message

)

except Exception as ex:
logging.info("Recieved expection while calling APIs for ContentType Model: " + str(ex))
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

)

except Exception as ex:
logging.info("Recieved expection while calling APIs for ContentType Model: " + str(ex))
logging.info(
"Recieved exeption while calling APIs for ContentType ModelReference, retrying with ContentType Model: "
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

"""Returns available Jumpstart hub model version

Raises:
ResourceNotFound: If the specified model is not found in the hub.
Copy link
Contributor

Choose a reason for hiding this comment

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

the exception type should be a Python class, not the error returned by the API.
Doesn't this method raise or Exception, KeyError or potentially a ClientException on line 203?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes my bad, updated it to ClientError exception instead

@@ -429,6 +429,7 @@ def attach(
cls,
endpoint_name: str,
inference_component_name: Optional[str] = None,
hub_name: Optional[str] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

backward-incompatible change, please add arg to the end of the list.

@malav-shastri malav-shastri requested a review from judyheflin July 9, 2024 20:49
JGuinegagne
JGuinegagne previously approved these changes Jul 9, 2024
@Aditi2424 Aditi2424 merged commit 4c5dd1f into aws:master Jul 10, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants