Skip to content

Commit a31427d

Browse files
author
Roja Reddy Sareddy
committed
update codegen to mark MinMemoryRequiredInMb as optional
DescribeInferenceComponent returns empty ComputeResourceRequirements for adapter ICs (created with BaseInferenceComponentName), but the service model still marks MinMemoryRequiredInMb as required. Add a REQUIRED_TO_OPTIONAL_OVERRIDES config in the codegen so re-running shapes generation produces the correct Optional field.
1 parent 54acad2 commit a31427d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

sagemaker-core/src/sagemaker/core/tools/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,9 @@
107107
CONFIG_SCHEMA_FILE_NAME = "config_schema.py"
108108

109109
API_COVERAGE_JSON_FILE_PATH = os.getcwd() + "/src/sagemaker/core/tools/api_coverage.json"
110+
111+
# Members that the service model marks as required but the API returns as optional.
112+
# E.g. DescribeInferenceComponent returns empty ComputeResourceRequirements for adapter ICs.
113+
REQUIRED_TO_OPTIONAL_OVERRIDES = {
114+
"InferenceComponentComputeResourceRequirements": ["MinMemoryRequiredInMb"],
115+
}

sagemaker-core/src/sagemaker/core/tools/shapes_extractor.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
from functools import lru_cache
1717
from typing import Optional, Any
1818

19-
from sagemaker.core.tools.constants import BASIC_JSON_TYPES_TO_PYTHON_TYPES, SHAPE_DAG_FILE_PATH
19+
from sagemaker.core.tools.constants import (
20+
BASIC_JSON_TYPES_TO_PYTHON_TYPES,
21+
REQUIRED_TO_OPTIONAL_OVERRIDES,
22+
SHAPE_DAG_FILE_PATH,
23+
)
2024
from sagemaker.core.utils.utils import (
2125
reformat_file_with_black,
2226
convert_to_snake_case,
@@ -216,6 +220,11 @@ def generate_shape_members(self, shape, required_override=()):
216220
shape_dict = self.combined_shapes[shape]
217221
members = shape_dict["members"]
218222
required_args = list(required_override) or shape_dict.get("required", [])
223+
# Remove members that are known to be optional despite the service model
224+
required_args = [
225+
r for r in required_args
226+
if r not in REQUIRED_TO_OPTIONAL_OVERRIDES.get(shape, [])
227+
]
219228
init_data_body = {}
220229
# bring the required members in front
221230
ordered_members = {key: members[key] for key in required_args if key in members}

0 commit comments

Comments
 (0)