Repository navigation
Commit b56e329
fix: accept core shapes and omitted content types in ModelBuilder.register (#6489)
ModelBuilder.register() had two independent AttributeError defects on the
same registry/deploy-from-package workflow.
1. register() rejected the ModelMetrics type its own signature declares.
The signature types model_metrics (and metadata_properties,
drift_check_baselines, model_life_cycle) as sagemaker.core.shapes
classes, but get_model_package_args() converted them by calling
value._to_request_dict(). The core shapes are pydantic models that do
not implement that method, so the documented type raised
"AttributeError: 'ModelMetrics' object has no attribute
'_to_request_dict'". Only the older sagemaker.core.model_metrics
compatibility class, which is not the declared type, has the method.
get_model_package_args() now routes these four arguments through a
small _to_request_dict() helper that keeps using _to_request_dict()
when the value implements it and otherwise falls back to the core
serializer, sagemaker.core.utils.utils.serialize(). The compatibility
classes are unaffected, so they stay supported for the rest of their
deprecation period, and dicts already in request form pass through.
Replacing the call with serialize() unconditionally, as suggested on
the issue, was rejected: the compatibility classes carry flat fields
(model_statistics, model_constraints, ...) that serialize() renders as
ModelStatistics/ModelConstraints instead of the nested
ModelQuality.Statistics block the API expects, which would have broken
the path that works today.
2. register() failed when content_types and response_types were omitted.
Both are declared optional with None defaults, but the method only
assigned self.content_types / self.response_types when the arguments
were not None and then read those attributes unconditionally, raising
"AttributeError: 'ModelBuilder' object has no attribute
'content_types'" on a first registration that omits them.
The read now uses getattr(self, ..., None). This keeps the existing
behaviour of reusing values supplied to an earlier register() call,
and avoids adding new ModelBuilder dataclass fields next to the
unrelated, already-public content_type field.
Fixes #6479
Fixes #6480
Co-authored-by: Mohamed Zeidan <zeidmo@amazon.com>1 parent ec68770 commit b56e329
4 files changed
Lines changed: 353 additions & 8 deletions
File tree
- sagemaker-core
- src/sagemaker/core
- tests/unit
- sagemaker-serve
- src/sagemaker/serve
- tests/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
24 | 45 | | |
25 | 46 | | |
26 | 47 | | |
| |||
76 | 97 | | |
77 | 98 | | |
78 | 99 | | |
79 | | - | |
| 100 | + | |
80 | 101 | | |
81 | | - | |
| 102 | + | |
82 | 103 | | |
83 | | - | |
| 104 | + | |
84 | 105 | | |
85 | 106 | | |
86 | 107 | | |
| |||
102 | 123 | | |
103 | 124 | | |
104 | 125 | | |
105 | | - | |
| 126 | + | |
106 | 127 | | |
107 | 128 | | |
108 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
161 | 264 | | |
162 | 265 | | |
163 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6891 | 6891 | | |
6892 | 6892 | | |
6893 | 6893 | | |
6894 | | - | |
| 6894 | + | |
| 6895 | + | |
| 6896 | + | |
6895 | 6897 | | |
6896 | | - | |
| 6898 | + | |
| 6899 | + | |
| 6900 | + | |
6897 | 6901 | | |
6898 | 6902 | | |
6899 | 6903 | | |
| |||
7002 | 7006 | | |
7003 | 7007 | | |
7004 | 7008 | | |
7005 | | - | |
7006 | | - | |
| 7009 | + | |
| 7010 | + | |
7007 | 7011 | | |
7008 | 7012 | | |
7009 | 7013 | | |
| |||
0 commit comments