Skip to content

fix: advanced inference recommendation jobs parameters check #3644

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 4 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/sagemaker/inference_recommender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
# language governing permissions and limitations under the License.
"""Classes for using Inference Recommender with Amazon SageMaker."""
from __future__ import absolute_import
from sagemaker.inference_recommender.inference_recommender_mixin import ( # noqa: F401
Phase,
ModelLatencyThreshold,
)
Original file line number Diff line number Diff line change
Expand Up @@ -464,18 +464,24 @@ def _convert_to_resource_limit_json(self, max_tests: int, max_parallel_tests: in
"""Bundle right_size() parameters into a resource limit for Advanced job"""
if not max_tests and not max_parallel_tests:
return None
return {
"MaxNumberOfTests": max_tests,
"MaxParallelOfTests": max_parallel_tests,
}
resource_limit = {}
if max_tests:
resource_limit["MaxNumberOfTests"] = max_tests
if max_parallel_tests:
resource_limit["MaxParallelOfTests"] = max_parallel_tests
return resource_limit

def _convert_to_stopping_conditions_json(
self, max_invocations: int, model_latency_thresholds: List[ModelLatencyThreshold]
):
"""Bundle right_size() parameters into stopping conditions for Advanced job"""
if not max_invocations and not model_latency_thresholds:
return None
return {
"MaxInvocations": max_invocations,
"ModelLatencyThresholds": [threshold.to_json for threshold in model_latency_thresholds],
}
stopping_conditions = {}
if max_invocations:
stopping_conditions["MaxInvocations"] = max_invocations
if model_latency_thresholds:
stopping_conditions["ModelLatencyThresholds"] = [
threshold.to_json for threshold in model_latency_thresholds
]
return stopping_conditions