-
Notifications
You must be signed in to change notification settings - Fork 1.2k
chore: telemetry for deployment configs #4806
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
chore: telemetry for deployment configs #4806
Conversation
@@ -903,20 +911,16 @@ def _add_config_name_to_kwargs( | |||
) -> JumpStartEstimatorInitKwargs: | |||
"""Sets tags in kwargs based on default or override, returns full kwargs.""" | |||
|
|||
specs = verify_model_region_and_return_specs( | |||
kwargs.config_name = kwargs.config_name or get_top_ranked_config_name( |
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.
Thanks for refactoring this!
) | ||
# we need to create a default JS session (without custom user agent) | ||
# in order to retrieve config name info | ||
temp_session = kwargs.sagemaker_session or DEFAULT_JUMPSTART_SAGEMAKER_SESSION |
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.
Not sure if I follow this, if kwargs.sagemaker_session is None, don't we fallback to the default session here?
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.
yes, but the problem is we need a session in order to derive what the config name is.
For the session to get the config name, we use the DEFAULT_JUMPSTART_SAGEMAKER_SESSION
without any special user agent, unless a custom session is provided
@@ -150,6 +150,7 @@ def __init__( | |||
model. (Default: None). | |||
|
|||
""" | |||
version = version or "*" |
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.
sanity check: this would change the behavior on line 157 right? Is that intentional?
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.
This was intentional since version
was being supplied as None
, not being omitted.
I'm going to try removing this tho
return headers | ||
|
||
|
||
def get_top_ranked_config_name( |
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.
non-blocking: are we assuming overall
ranking in this method? Wouldn't we need to be provided which ranking array to use?
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.
That's an excellent point. How about I make it an optional argument, the ranking name, with the default value being overall?
scope=JumpStartScriptScope.TRAINING, | ||
region=kwargs.region, | ||
tolerate_vulnerable_model=kwargs.tolerate_vulnerable_model, | ||
model_type=kwargs.model_type[0], |
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.
sanity-check: any risk of getting an IndexError
here?
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.
Actually, i did this cause the typing said it was a tuple, but looking at other places of the code, we do kwargs.model_type
.
@malav-shastri -- any idea what to do here?
kwargs: Union[JumpStartModelInitKwargs, JumpStartModelDeployKwargs] | ||
) -> JumpStartModelInitKwargs: | ||
"""Sets session in kwargs based on default or override, returns full kwargs.""" | ||
|
||
kwargs.sagemaker_session = ( | ||
kwargs.sagemaker_session | ||
or get_default_jumpstart_session_with_user_agent_suffix( | ||
kwargs.model_id, kwargs.model_version, kwargs.hub_arn | ||
kwargs.model_id, kwargs.model_version, kwargs.config_name, kwargs.hub_arn |
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.
consider using named args here to avoid the risk of mixing them up.
return kwargs | ||
supported_instance_types = resolved_config.get("supported_inference_instance_types", []) | ||
if kwargs.instance_type not in supported_instance_types: | ||
JUMPSTART_LOGGER.warning("Overriding instance type to %s", kwargs.instance_type) |
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 (I know it isn't from this PR): could we use f-string please, also update to Overriding instance type to %s even though it is not in the list of supported instances.
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.
i think we did this cause there's some linters that complain
src/sagemaker/jumpstart/utils.py
Outdated
is_hub_content: Optional[bool] = False, | ||
) -> Session: | ||
"""Returns default JumpStart SageMaker Session with model-specific user agent suffix.""" | ||
botocore_session = botocore.session.get_session() | ||
botocore_config = botocore.config.Config( | ||
user_agent_extra=get_jumpstart_user_agent_extra_suffix( | ||
model_id, model_version, is_hub_content | ||
model_id, model_version, config_name, is_hub_content |
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.
consider using named args here.
session = model.sagemaker_session | ||
|
||
with mock.patch("botocore.client.BaseClient._make_request") as mock_make_request: | ||
try: |
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.
Just for my understanding, what is this try
/except
?
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.
basically im trying to intercept the network call to make sure the user agent has the right tags applied
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.
still, I'm not sure why you need a try
/ except
, particularly since you are mocking this.
Consider either removing or adding an inline comment to explain that.
session = model.sagemaker_session | ||
|
||
with mock.patch("botocore.client.BaseClient._make_request") as mock_make_request: | ||
try: |
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.
still, I'm not sure why you need a try
/ except
, particularly since you are mocking this.
Consider either removing or adding an inline comment to explain that.
Issue #, if available:
Description of changes:
No telemetry (user agent metadata) was being recorded for deployment configuration information for JumpStart models. This adds recording of deployment configuration information.
Testing done:
added tests
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
Tests
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.