Repository navigation
fix: accept CUSTOMIZATION capability in JumpStart hub documents - #6456
mohamedzeidan2021 merged 1 commit into
Conversation
e855705 to
4e97ddf
Compare
4e97ddf to
18c5947
Compare
CapabilityEnum was missing the CUSTOMIZATION member, so pydantic rejected the entire HubContentDocument for any JumpStart model whose Capabilities include CUSTOMIZATION. This broke every v3 training path that loads the document (ModelTrainer.from_jumpstart_config and the JumpStartTrainDefaults getters) for 42 of 754 public models in us-west-2, including three with TrainingSupported=true. Add CUSTOMIZATION to CapabilityEnum, and make Capabilities parsing forward-compatible: unknown values are kept as plain strings with a warning instead of failing validation, so a future service-side capability cannot break a pinned SDK version again. Applied to both the HubContentDocument field and the HostingComponentsModel base-class field.
18c5947 to
f7b7d84
Compare
There was a problem hiding this comment.
🤖 AI code review
This PR adds CUSTOMIZATION to CapabilityEnum and makes Capabilities parsing forward-compatible by widening the field type to List[Union[CapabilityEnum, str]] and adding mode="before" validators that coerce known values to enum members while retaining unknown values as strings with a warning. The change is well-scoped, backward compatible, and covered by regression tests. The duplicated validator across HostingComponentsModel and HubContentDocument is required by pydantic v2 (a redefined field needs its validator re-declared), so that duplication is appropriate. I found no blocking issues; one minor note on a weak test assertion.
Reviewed commit f7b7d84. Automated review; verify before acting.
|
|
||
| assert "SOME_FUTURE_CAPABILITY" in document.Capabilities | ||
| assert isinstance(document.Capabilities[-1], str) | ||
| assert CapabilityEnum.TRAINING in document.Capabilities |
There was a problem hiding this comment.
🟡 Low: isinstance(document.Capabilities[-1], str) is a tautology for distinguishing a raw string from an enum member: CapabilityEnum is a StrEnum (subclasses str), so coerced enum members are also str instances and would pass this assertion too. If the intent is to verify the unknown value is not coerced to a CapabilityEnum, assert not isinstance(document.Capabilities[-1], CapabilityEnum) (or type(document.Capabilities[-1]) is str). The in check above still gives real coverage, so this is minor.
CI status: the 4 red checks are pre-existing or infra, not caused by this changeThis PR only adds
Green checks that validate this change:
Reproduced locally with the CI pinned |
Issue
SageMaker Python SDK v3 (3.24.0) cannot parse the
HubContentDocumentof any JumpStart model whoseCapabilitiesincludeCUSTOMIZATION.CapabilityEnumdoes not list that value, so pydantic validation rejects the whole document.Because
HubContentDocument.Capabilitiesis typedList[CapabilityEnum], a single unrecognized value fails validation of the entire document atHubContentDocument(**document_json), breaking every v3 training path that loads the document before any training logic runs —ModelTrainer.from_jumpstart_configand theJumpStartTrainDefaultsgetters.In
us-west-2SageMakerPublicHub, 42 of 754 public models carryCUSTOMIZATION, including three withTrainingSupported=true:meta-textgeneration-llama-3-1-8b-instruct,meta-textgeneration-llama-3-2-1b-instruct,meta-textgeneration-llama-3-2-3b-instruct.CUSTOMIZATIONis a valid, documented capability (listed in the HubContentDocument model-properties reference alongsideBEDROCK_CONSOLE,TRAINING,FINE_TUNING,HYPERPOD_DEPLOYMENT).Reproduction
Description of changes
CUSTOMIZATIONtoCapabilityEnuminsagemaker-core/src/sagemaker/core/jumpstart/models.py.Capabilitiesparsing forward-compatible: the field type is widened toList[Union[CapabilityEnum, str]]and amode="before"validator coerces known values toCapabilityEnummembers while keeping unknown values as plain strings with a warning. This prevents a future service-side capability value from again failing validation of the entire document for a pinned SDK version. Applied to bothHubContentDocument.Capabilitiesand theHostingComponentsModel.Capabilitiesbase-class field it inherits from.Known values still deserialize to
CapabilityEnum; behavior is unchanged for documents that only use recognized capabilities. This is backwards compatible.Testing
Added regression tests in
sagemaker-core/tests/unit/jumpstart/test_models.py:CUSTOMIZATIONis a member ofCapabilityEnum.CUSTOMIZATIONparses.CapabilityEnumvalue parses.HubContentDocumentandHostingComponentsModel).All unit tests in
tests/unit/jumpstart/test_models.pyandtests/unit/jumpstart/test_document.pypass;black(line-length 100) andflake8are clean.Merge Checklist
Tests
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.