-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: intelligent defaults for volume size, JS Estimator image uri region, Predictor str method #3870
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
fix: intelligent defaults for volume size, JS Estimator image uri region, Predictor str method #3870
Conversation
…ion, Predictor str method
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
@@ -75,6 +75,10 @@ def content_type(self) -> str: | |||
def accept(self) -> Tuple[str]: | |||
"""The content type(s) that are expected from the inference server.""" | |||
|
|||
def __str__(self) -> str: | |||
"""Overriding str(*) method to make more human-readable.""" | |||
return stringify_object(self) |
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 looks to me like a good improvement, but please double check with SDK team if that's considered backward incompatible please. The alternative to be to write a different serialization function.
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.
Agree this would be a good improvement, I dont see any negative implications of this.
for instance_group in instance_groups | ||
] | ||
) | ||
else volume_kms_key | ||
) |
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 find ternary hard to read in this context, could you do:
if <condition>:
self.volume_kms_key = resolve_value_from_config(...)
else:
self.volume_kms_key = volume_kms_key
More importantly, from a security/reasonable expection POV: should we let this code throw if any of the instance in the group does support KMS, but some do not?
If we silently remove it as you do here, the result is that there will be instances with EBS volumes out there that aren't encrypted with the default KMS key provided by admins. I don't think that's desirable.
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 this is a valid concern with respect to instance_groups, lets involve the instance_groups feature team to weigh in on this.
src/sagemaker/session.py
Outdated
@@ -3850,7 +3861,16 @@ def create_endpoint_config_from_existing( | |||
|
|||
if new_kms_key is not None or existing_endpoint_config_desc.get("KmsKeyId") is not None: | |||
request["KmsKeyId"] = new_kms_key or existing_endpoint_config_desc.get("KmsKeyId") | |||
if KMS_KEY_ID not in request: | |||
|
|||
supports_kms = all( |
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.
same comment here please, I would vote for letting it fail in that case.
src/sagemaker/session.py
Outdated
@@ -4471,15 +4491,28 @@ def endpoint_from_production_variants( | |||
Returns: | |||
str: The name of the created ``Endpoint``. | |||
""" | |||
|
|||
supports_kms = all( |
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.
same comment here please
assert estimator.output_kms_key == expected_kms_key_id | ||
assert estimator.volume_kms_key is None | ||
assert estimator.security_group_ids == expected_security_groups | ||
assert estimator.subnets == expected_subnets |
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.
please add a test case where the instance group has types that support attaching a volume and types that do not support it.
assert actual_train_args["OutputDataConfig"] == { | ||
"S3OutputPath": S3_OUTPUT, | ||
"KmsKeyId": expected_kms_key_id, | ||
} |
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.
same comment here please
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Codecov Report
@@ Coverage Diff @@
## master #3870 +/- ##
==========================================
- Coverage 90.08% 89.37% -0.71%
==========================================
Files 1148 269 -879
Lines 106048 26234 -79814
==========================================
- Hits 95534 23447 -72087
+ Misses 10514 2787 -7727
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
src/sagemaker/estimator.py
Outdated
if ( | ||
instance_type_for_volume_kms and instance_supports_kms(instance_type_for_volume_kms) | ||
) | ||
use_config_condition = ( |
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 making the change, could you add an inline comment here to explain what you are doing?
Most readers won't be familiar with instance_group
and the details of which hardware supports attaching an EBS volume that can be encrypted and which do not.
Also nit: could you rename the variable use_volume_kms_config
please?
tests/unit/test_session.py
Outdated
expected_inference_kms_key_id = SAGEMAKER_CONFIG_ENDPOINT_CONFIG["SageMaker"]["EndpointConfig"][ | ||
"AsyncInferenceConfig" | ||
]["OutputConfig"]["KmsKeyId"] | ||
expected_kms_key_id = SAGEMAKER_CONFIG_ENDPOINT_CONFIG["SageMaker"]["EndpointConfig"][ |
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.
optional: how about renaming this variable expected_volume_kms_key_id
for better readability?
sagemaker.production_variant("C", "ml.p2.xlarge"), | ||
] | ||
# Add DestinationS3Uri, KmsKeyId to only one production variant | ||
expected_production_variant_0_kms_key_id = SAGEMAKER_CONFIG_ENDPOINT_CONFIG["SageMaker"][ |
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.
same comment please
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
/bot run slow-tests, notebook-tests
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
try: | ||
|
||
# local mode does not support volume size | ||
if instance_type.startswith("local"): |
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.
will need to add another check or is_pipeline_variable(instance_type)
, otherwise, this breaks pipeline cx.
Description of changes:
JumpStartEstimator
where the region wasn't being used with the image_uri__str__
method to basePredictor
classvolume_size_supported
for local modeignore_intelligent_defaults
toSessionSettings
Testing done:
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.