From 0730ae1b94390c9d9f5602b199680a907aab331b Mon Sep 17 00:00:00 2001 From: Benjamin Crabtree Date: Thu, 20 Feb 2025 16:23:46 +0000 Subject: [PATCH 01/11] fix altconfig hubcontent and reenable integ test --- src/sagemaker/jumpstart/accessors.py | 26 ++++++++--- src/sagemaker/jumpstart/hub/hub.py | 46 ++++++++++++------- src/sagemaker/jumpstart/types.py | 4 +- .../model/test_jumpstart_private_hub_model.py | 1 - 4 files changed, 51 insertions(+), 26 deletions(-) diff --git a/src/sagemaker/jumpstart/accessors.py b/src/sagemaker/jumpstart/accessors.py index 20a2d16c15..e02f972ea0 100644 --- a/src/sagemaker/jumpstart/accessors.py +++ b/src/sagemaker/jumpstart/accessors.py @@ -287,8 +287,9 @@ def get_model_specs( {**JumpStartModelsAccessor._cache_kwargs, **additional_kwargs} ) JumpStartModelsAccessor._set_cache_and_region(region, cache_kwargs) - - if hub_arn: + + # Users only input model id, not contentType, so first try to describe with ModelReference, then with Model + if hub_arn: try: hub_model_arn = construct_hub_model_reference_arn_from_inputs( hub_arn=hub_arn, model_name=model_id, version=version @@ -308,11 +309,22 @@ def get_model_specs( hub_model_arn = construct_hub_model_arn_from_inputs( hub_arn=hub_arn, model_name=model_id, version=version ) - model_specs = JumpStartModelsAccessor._cache.get_hub_model( - hub_model_arn=hub_model_arn - ) - model_specs.set_hub_content_type(HubContentType.MODEL) - return model_specs + + # Failed to describe ModelReference, try with Model + try: + model_specs = JumpStartModelsAccessor._cache.get_hub_model( + hub_model_arn=hub_model_arn + ) + model_specs.set_hub_content_type(HubContentType.MODEL) + + return model_specs + except Exception as ex: + # Failed with both, throw a custom error message + raise Exception( + f"Cannot get details for {model_id} in Hub {hub_arn}. \ + {model_id} does not exist as a Model or ModelReference: \n" + + str(ex) + ) return JumpStartModelsAccessor._cache.get_specs( # type: ignore model_id=model_id, version_str=version, model_type=model_type diff --git a/src/sagemaker/jumpstart/hub/hub.py b/src/sagemaker/jumpstart/hub/hub.py index bc42eebea0..6d4c8e86b0 100644 --- a/src/sagemaker/jumpstart/hub/hub.py +++ b/src/sagemaker/jumpstart/hub/hub.py @@ -272,18 +272,21 @@ def delete_model_reference(self, model_name: str) -> None: def describe_model( self, model_name: str, hub_name: Optional[str] = None, model_version: Optional[str] = None ) -> DescribeHubContentResponse: - """Describe model in the SageMaker Hub.""" + """Describe Model or ModelReference in a Hub.""" + hub_name = self.hub_name if not hub_name else hub_name + + # Users only input model id, not contentType, so first try to describe with ModelReference, then with Model try: model_version = get_hub_model_version( hub_model_name=model_name, hub_model_type=HubContentType.MODEL_REFERENCE.value, - hub_name=self.hub_name if not hub_name else hub_name, + hub_name=hub_name, sagemaker_session=self._sagemaker_session, hub_model_version=model_version, ) hub_content_description: Dict[str, Any] = self._sagemaker_session.describe_hub_content( - hub_name=self.hub_name if not hub_name else hub_name, + hub_name=hub_name, hub_content_name=model_name, hub_content_version=model_version, hub_content_type=HubContentType.MODEL_REFERENCE.value, @@ -294,19 +297,30 @@ def describe_model( "Received exeption while calling APIs for ContentType ModelReference, retrying with ContentType Model: " + str(ex) ) - model_version = get_hub_model_version( - hub_model_name=model_name, - hub_model_type=HubContentType.MODEL.value, - hub_name=self.hub_name if not hub_name else hub_name, - sagemaker_session=self._sagemaker_session, - hub_model_version=model_version, - ) - hub_content_description: Dict[str, Any] = self._sagemaker_session.describe_hub_content( - hub_name=self.hub_name if not hub_name else hub_name, - hub_content_name=model_name, - hub_content_version=model_version, - hub_content_type=HubContentType.MODEL.value, - ) + # Failed to describe ModelReference, try with Model + try: + model_version = get_hub_model_version( + hub_model_name=model_name, + hub_model_type=HubContentType.MODEL.value, + hub_name=hub_name, + sagemaker_session=self._sagemaker_session, + hub_model_version=model_version, + ) + + hub_content_description: Dict[str, Any] = self._sagemaker_session.describe_hub_content( + hub_name=hub_name, + hub_content_name=model_name, + hub_content_version=model_version, + hub_content_type=HubContentType.MODEL.value, + ) + + except Exception as ex: + # Failed with both, throw a custom error message + raise Exception( + f"Cannot get details for {model_name} in Hub {hub_name}. \ + {model_name} does not exist as a Model or ModelReference in {hub_name}: \n" + + str(ex) + ) return DescribeHubContentResponse(hub_content_description) diff --git a/src/sagemaker/jumpstart/types.py b/src/sagemaker/jumpstart/types.py index 3dee2b3553..77a8d725a6 100644 --- a/src/sagemaker/jumpstart/types.py +++ b/src/sagemaker/jumpstart/types.py @@ -1363,9 +1363,9 @@ def from_json(self, json_obj: Dict[str, Any]) -> None: self.deploy_kwargs = deepcopy(json_obj.get("deploy_kwargs", {})) self.predictor_specs: Optional[JumpStartPredictorSpecs] = ( JumpStartPredictorSpecs( - json_obj["predictor_specs"], is_hub_content=self._is_hub_content + json_obj.get("predictor_specs"), is_hub_content=self._is_hub_content ) - if "predictor_specs" in json_obj + if json_obj.get("predictor_specs") else None ) self.default_payloads: Optional[Dict[str, JumpStartSerializablePayload]] = ( diff --git a/tests/integ/sagemaker/jumpstart/private_hub/model/test_jumpstart_private_hub_model.py b/tests/integ/sagemaker/jumpstart/private_hub/model/test_jumpstart_private_hub_model.py index c378520196..e8e5cc0942 100644 --- a/tests/integ/sagemaker/jumpstart/private_hub/model/test_jumpstart_private_hub_model.py +++ b/tests/integ/sagemaker/jumpstart/private_hub/model/test_jumpstart_private_hub_model.py @@ -122,7 +122,6 @@ def test_jumpstart_hub_gated_model(setup, add_model_references): assert response is not None -@pytest.mark.skip(reason="blocking PR checks and release pipeline.") def test_jumpstart_gated_model_inference_component_enabled(setup, add_model_references): model_id = "meta-textgeneration-llama-2-7b" From ce7a99b57b500d9dd98c8588986c8488755502bc Mon Sep 17 00:00:00 2001 From: Benjamin Crabtree Date: Thu, 20 Feb 2025 16:32:02 +0000 Subject: [PATCH 02/11] linting --- src/sagemaker/jumpstart/accessors.py | 4 ++-- src/sagemaker/jumpstart/hub/hub.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/sagemaker/jumpstart/accessors.py b/src/sagemaker/jumpstart/accessors.py index e02f972ea0..f045b0efce 100644 --- a/src/sagemaker/jumpstart/accessors.py +++ b/src/sagemaker/jumpstart/accessors.py @@ -287,9 +287,9 @@ def get_model_specs( {**JumpStartModelsAccessor._cache_kwargs, **additional_kwargs} ) JumpStartModelsAccessor._set_cache_and_region(region, cache_kwargs) - + # Users only input model id, not contentType, so first try to describe with ModelReference, then with Model - if hub_arn: + if hub_arn: try: hub_model_arn = construct_hub_model_reference_arn_from_inputs( hub_arn=hub_arn, model_name=model_id, version=version diff --git a/src/sagemaker/jumpstart/hub/hub.py b/src/sagemaker/jumpstart/hub/hub.py index 6d4c8e86b0..12cb877dd9 100644 --- a/src/sagemaker/jumpstart/hub/hub.py +++ b/src/sagemaker/jumpstart/hub/hub.py @@ -308,13 +308,15 @@ def describe_model( hub_model_version=model_version, ) - hub_content_description: Dict[str, Any] = self._sagemaker_session.describe_hub_content( - hub_name=hub_name, - hub_content_name=model_name, - hub_content_version=model_version, - hub_content_type=HubContentType.MODEL.value, + hub_content_description: Dict[str, Any] = ( + self._sagemaker_session.describe_hub_content( + hub_name=hub_name, + hub_content_name=model_name, + hub_content_version=model_version, + hub_content_type=HubContentType.MODEL.value, + ) ) - + except Exception as ex: # Failed with both, throw a custom error message raise Exception( From 3fa5054ec1d09cf3f4c470957d1034aa5e094cda Mon Sep 17 00:00:00 2001 From: Benjamin Crabtree Date: Thu, 20 Feb 2025 17:06:02 +0000 Subject: [PATCH 03/11] update exception thrown --- src/sagemaker/jumpstart/accessors.py | 2 +- src/sagemaker/jumpstart/hub/hub.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sagemaker/jumpstart/accessors.py b/src/sagemaker/jumpstart/accessors.py index f045b0efce..2ed2deb803 100644 --- a/src/sagemaker/jumpstart/accessors.py +++ b/src/sagemaker/jumpstart/accessors.py @@ -320,7 +320,7 @@ def get_model_specs( return model_specs except Exception as ex: # Failed with both, throw a custom error message - raise Exception( + raise RuntimeError( f"Cannot get details for {model_id} in Hub {hub_arn}. \ {model_id} does not exist as a Model or ModelReference: \n" + str(ex) diff --git a/src/sagemaker/jumpstart/hub/hub.py b/src/sagemaker/jumpstart/hub/hub.py index 12cb877dd9..402b2ce534 100644 --- a/src/sagemaker/jumpstart/hub/hub.py +++ b/src/sagemaker/jumpstart/hub/hub.py @@ -273,7 +273,7 @@ def describe_model( self, model_name: str, hub_name: Optional[str] = None, model_version: Optional[str] = None ) -> DescribeHubContentResponse: """Describe Model or ModelReference in a Hub.""" - hub_name = self.hub_name if not hub_name else hub_name + hub_name = hub_name or self.hub_name # Users only input model id, not contentType, so first try to describe with ModelReference, then with Model try: @@ -319,7 +319,7 @@ def describe_model( except Exception as ex: # Failed with both, throw a custom error message - raise Exception( + raise RuntimeError( f"Cannot get details for {model_name} in Hub {hub_name}. \ {model_name} does not exist as a Model or ModelReference in {hub_name}: \n" + str(ex) From 32b71ec6401be11918e5e387d1157c0547aca41c Mon Sep 17 00:00:00 2001 From: Malav Shastri <57682969+malav-shastri@users.noreply.github.com> Date: Thu, 20 Feb 2025 12:03:37 -0500 Subject: [PATCH 04/11] feat: Add support for TGI Neuronx 0.0.27 and HF PT 2.3.0 image in PySDK (#5050) Co-authored-by: malavhs --- .../huggingface-llm-neuronx.json | 36 ++++++++++++- .../image_uri_config/huggingface.json | 52 +++++++++++++++++++ .../image_uris/test_huggingface_llm.py | 1 + 3 files changed, 88 insertions(+), 1 deletion(-) diff --git a/src/sagemaker/image_uri_config/huggingface-llm-neuronx.json b/src/sagemaker/image_uri_config/huggingface-llm-neuronx.json index f9df983433..478d6ff597 100644 --- a/src/sagemaker/image_uri_config/huggingface-llm-neuronx.json +++ b/src/sagemaker/image_uri_config/huggingface-llm-neuronx.json @@ -4,7 +4,7 @@ "inf2" ], "version_aliases": { - "0.0": "0.0.25" + "0.0": "0.0.27" }, "versions": { "0.0.16": { @@ -364,6 +364,40 @@ "container_version": { "inf2": "ubuntu22.04" } + }, + "0.0.27": { + "py_versions": [ + "py310" + ], + "registries": { + "ap-northeast-1": "763104351884", + "ap-south-1": "763104351884", + "ap-south-2": "772153158452", + "ap-southeast-1": "763104351884", + "ap-southeast-2": "763104351884", + "ap-southeast-4": "457447274322", + "ap-southeast-5": "550225433462", + "cn-north-1": "727897471807", + "cn-northwest-1": "727897471807", + "eu-central-1": "763104351884", + "eu-central-2": "380420809688", + "eu-south-2": "503227376785", + "eu-west-1": "763104351884", + "eu-west-3": "763104351884", + "il-central-1": "780543022126", + "sa-east-1": "763104351884", + "us-east-1": "763104351884", + "us-east-2": "763104351884", + "us-gov-east-1": "446045086412", + "us-gov-west-1": "442386744353", + "us-west-2": "763104351884", + "ca-west-1": "204538143572" + }, + "tag_prefix": "2.1.2-optimum0.0.27", + "repository": "huggingface-pytorch-tgi-inference", + "container_version": { + "inf2": "ubuntu22.04" + } } } } diff --git a/src/sagemaker/image_uri_config/huggingface.json b/src/sagemaker/image_uri_config/huggingface.json index 86d9d591d0..c314436346 100644 --- a/src/sagemaker/image_uri_config/huggingface.json +++ b/src/sagemaker/image_uri_config/huggingface.json @@ -1931,6 +1931,58 @@ "cpu": "ubuntu22.04" } } + }, + "4.48.0": { + "version_aliases": { + "pytorch2.3": "pytorch2.3.0" + }, + "pytorch2.3.0": { + "py_versions": [ + "py311" + ], + "registries": { + "af-south-1": "626614931356", + "il-central-1": "780543022126", + "ap-east-1": "871362719292", + "ap-northeast-1": "763104351884", + "ap-northeast-2": "763104351884", + "ap-northeast-3": "364406365360", + "ap-south-1": "763104351884", + "ap-south-2": "772153158452", + "ap-southeast-1": "763104351884", + "ap-southeast-2": "763104351884", + "ap-southeast-3": "907027046896", + "ap-southeast-4": "457447274322", + "ca-central-1": "763104351884", + "cn-north-1": "727897471807", + "cn-northwest-1": "727897471807", + "eu-central-1": "763104351884", + "eu-central-2": "380420809688", + "eu-north-1": "763104351884", + "eu-west-1": "763104351884", + "eu-west-2": "763104351884", + "eu-west-3": "763104351884", + "eu-south-1": "692866216735", + "eu-south-2": "503227376785", + "me-south-1": "217643126080", + "me-central-1": "914824155844", + "sa-east-1": "763104351884", + "us-east-1": "763104351884", + "us-east-2": "763104351884", + "us-gov-east-1": "446045086412", + "us-gov-west-1": "442386744353", + "us-iso-east-1": "886529160074", + "us-isob-east-1": "094389454867", + "us-west-1": "763104351884", + "us-west-2": "763104351884", + "ca-west-1": "204538143572" + }, + "repository": "huggingface-pytorch-inference", + "container_version": { + "gpu": "cu121-ubuntu22.04", + "cpu": "ubuntu22.04" + } + } } } } diff --git a/tests/unit/sagemaker/image_uris/test_huggingface_llm.py b/tests/unit/sagemaker/image_uris/test_huggingface_llm.py index c626e935ab..0d96417e9f 100644 --- a/tests/unit/sagemaker/image_uris/test_huggingface_llm.py +++ b/tests/unit/sagemaker/image_uris/test_huggingface_llm.py @@ -60,6 +60,7 @@ "0.0.23": "2.1.2-optimum0.0.23-neuronx-py310-ubuntu22.04", "0.0.24": "2.1.2-optimum0.0.24-neuronx-py310-ubuntu22.04", "0.0.25": "2.1.2-optimum0.0.25-neuronx-py310-ubuntu22.04", + "0.0.27": "2.1.2-optimum0.0.27-neuronx-py310-ubuntu22.04", }, } From 240146b4e61cb9023350e24fdcce0290e7205b07 Mon Sep 17 00:00:00 2001 From: Benjamin Crabtree Date: Thu, 20 Feb 2025 19:12:36 +0000 Subject: [PATCH 05/11] add test --- .../unit/sagemaker/jumpstart/hub/test_hub.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/unit/sagemaker/jumpstart/hub/test_hub.py b/tests/unit/sagemaker/jumpstart/hub/test_hub.py index 8522b33bc3..4e4b4e2886 100644 --- a/tests/unit/sagemaker/jumpstart/hub/test_hub.py +++ b/tests/unit/sagemaker/jumpstart/hub/test_hub.py @@ -192,6 +192,36 @@ def test_describe_model_success(mock_describe_hub_content_response, sagemaker_se ) +@patch("sagemaker.jumpstart.hub.interfaces.DescribeHubContentResponse.from_json") +def test_describe_model_one_thrown_error(mock_describe_hub_content_response, sagemaker_session): + mock_describe_hub_content_response.return_value = Mock() + mock_list_hub_content_versions = sagemaker_session.list_hub_content_versions + mock_list_hub_content_versions.return_value = { + "HubContentSummaries": [ + {"HubContentVersion": "1.0"}, + {"HubContentVersion": "2.0"}, + {"HubContentVersion": "3.0"}, + ] + } + mock_describe_hub_content = sagemaker_session.describe_hub_content + mock_describe_hub_content.side_effect = [ + Exception("Some exception"), + {"HubContentName": "test-model", "HubContentVersion": "3.0"}, + ] + + hub = Hub(hub_name=HUB_NAME, sagemaker_session=sagemaker_session) + + with patch("sagemaker.jumpstart.hub.utils.get_hub_model_version") as mock_get_hub_model_version: + mock_get_hub_model_version.return_value = "3.0" + + hub.describe_model("test-model") + + mock_describe_hub_content.asssert_called_times(2) + mock_describe_hub_content.assert_called_with( + hub_name=HUB_NAME, hub_content_name="test-model", hub_content_version="3.0", hub_content_type="Model" + ) + + def test_create_hub_content_reference(sagemaker_session): hub = Hub(hub_name=HUB_NAME, sagemaker_session=sagemaker_session) model_name = "mock-model-one-huggingface" From d74c852045af7c3a4c840677940399fb1c437757 Mon Sep 17 00:00:00 2001 From: Benjamin Crabtree Date: Thu, 20 Feb 2025 22:42:00 +0000 Subject: [PATCH 06/11] update predictor spec accessor --- src/sagemaker/jumpstart/types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sagemaker/jumpstart/types.py b/src/sagemaker/jumpstart/types.py index 77a8d725a6..4248493c2e 100644 --- a/src/sagemaker/jumpstart/types.py +++ b/src/sagemaker/jumpstart/types.py @@ -1363,9 +1363,9 @@ def from_json(self, json_obj: Dict[str, Any]) -> None: self.deploy_kwargs = deepcopy(json_obj.get("deploy_kwargs", {})) self.predictor_specs: Optional[JumpStartPredictorSpecs] = ( JumpStartPredictorSpecs( - json_obj.get("predictor_specs"), is_hub_content=self._is_hub_content + json_obj.get("sage_maker_sdk_predictor_specifications"), is_hub_content=self._is_hub_content ) - if json_obj.get("predictor_specs") + if json_obj.get("sage_maker_sdk_predictor_specifications") else None ) self.default_payloads: Optional[Dict[str, JumpStartSerializablePayload]] = ( From 97990c697d31f2d80eadfd33c68287ffe8217291 Mon Sep 17 00:00:00 2001 From: Benjamin Crabtree Date: Thu, 20 Feb 2025 22:53:51 +0000 Subject: [PATCH 07/11] lint --- src/sagemaker/jumpstart/types.py | 3 ++- tests/unit/sagemaker/jumpstart/hub/test_hub.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sagemaker/jumpstart/types.py b/src/sagemaker/jumpstart/types.py index 4248493c2e..a96162d8c9 100644 --- a/src/sagemaker/jumpstart/types.py +++ b/src/sagemaker/jumpstart/types.py @@ -1363,7 +1363,8 @@ def from_json(self, json_obj: Dict[str, Any]) -> None: self.deploy_kwargs = deepcopy(json_obj.get("deploy_kwargs", {})) self.predictor_specs: Optional[JumpStartPredictorSpecs] = ( JumpStartPredictorSpecs( - json_obj.get("sage_maker_sdk_predictor_specifications"), is_hub_content=self._is_hub_content + json_obj.get("sage_maker_sdk_predictor_specifications"), + is_hub_content=self._is_hub_content, ) if json_obj.get("sage_maker_sdk_predictor_specifications") else None diff --git a/tests/unit/sagemaker/jumpstart/hub/test_hub.py b/tests/unit/sagemaker/jumpstart/hub/test_hub.py index 4e4b4e2886..06f5473322 100644 --- a/tests/unit/sagemaker/jumpstart/hub/test_hub.py +++ b/tests/unit/sagemaker/jumpstart/hub/test_hub.py @@ -218,7 +218,10 @@ def test_describe_model_one_thrown_error(mock_describe_hub_content_response, sag mock_describe_hub_content.asssert_called_times(2) mock_describe_hub_content.assert_called_with( - hub_name=HUB_NAME, hub_content_name="test-model", hub_content_version="3.0", hub_content_type="Model" + hub_name=HUB_NAME, + hub_content_name="test-model", + hub_content_version="3.0", + hub_content_type="Model", ) From 761fa1ddbc2d0109c0ddfbb02d85dfd728c89e7c Mon Sep 17 00:00:00 2001 From: Benjamin Crabtree Date: Fri, 21 Feb 2025 19:26:50 +0000 Subject: [PATCH 08/11] set custom field from HCD config to model spec data class --- src/sagemaker/jumpstart/types.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/sagemaker/jumpstart/types.py b/src/sagemaker/jumpstart/types.py index a96162d8c9..b52cddcd62 100644 --- a/src/sagemaker/jumpstart/types.py +++ b/src/sagemaker/jumpstart/types.py @@ -1363,10 +1363,10 @@ def from_json(self, json_obj: Dict[str, Any]) -> None: self.deploy_kwargs = deepcopy(json_obj.get("deploy_kwargs", {})) self.predictor_specs: Optional[JumpStartPredictorSpecs] = ( JumpStartPredictorSpecs( - json_obj.get("sage_maker_sdk_predictor_specifications"), + json_obj.get("predictor_specs"), is_hub_content=self._is_hub_content, ) - if json_obj.get("sage_maker_sdk_predictor_specifications") + if json_obj.get("predictor_specs") else None ) self.default_payloads: Optional[Dict[str, JumpStartSerializablePayload]] = ( @@ -1502,6 +1502,9 @@ class JumpStartConfigComponent(JumpStartMetadataBaseFields): "incremental_training_supported", ] + # Map of HubContent fields that map to custom names in MetadataBaseFields + CUSTOM_FIELD_MAP = {"sage_maker_sdk_predictor_specifications": "predictor_specs"} + __slots__ = slots + JumpStartMetadataBaseFields.__slots__ def __init__( @@ -1532,6 +1535,11 @@ def from_json(self, json_obj: Dict[str, Any]) -> None: for field in json_obj.keys(): if field in self.__slots__: setattr(self, field, json_obj[field]) + + # Handle custom fields + for field, custom_field in self.CUSTOM_FIELD_MAP.items(): + if field in json_obj: + setattr(self, custom_field, json_obj[field]) class JumpStartMetadataConfig(JumpStartDataHolderType): From 3f0945553a798e97c1f121742e2d0ad227d01645 Mon Sep 17 00:00:00 2001 From: Benjamin Crabtree Date: Fri, 21 Feb 2025 19:37:06 +0000 Subject: [PATCH 09/11] lint --- src/sagemaker/jumpstart/types.py | 10 +++++++--- tests/unit/sagemaker/jumpstart/utils.py | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/sagemaker/jumpstart/types.py b/src/sagemaker/jumpstart/types.py index b52cddcd62..607a1d2dc2 100644 --- a/src/sagemaker/jumpstart/types.py +++ b/src/sagemaker/jumpstart/types.py @@ -1285,6 +1285,7 @@ def from_json(self, json_obj: Dict[str, Any]) -> None: Args: json_obj (Dict[str, Any]): Dictionary representation of spec. """ + print("HEYHEYHEY") if self._is_hub_content: json_obj = walk_and_apply_json(json_obj, camel_to_snake) self.model_id: str = json_obj.get("model_id") @@ -1361,6 +1362,7 @@ def from_json(self, json_obj: Dict[str, Any]) -> None: ) self.model_kwargs = deepcopy(json_obj.get("model_kwargs", {})) self.deploy_kwargs = deepcopy(json_obj.get("deploy_kwargs", {})) + print(f'HUH {json_obj.get("predictor_specs")}') self.predictor_specs: Optional[JumpStartPredictorSpecs] = ( JumpStartPredictorSpecs( json_obj.get("predictor_specs"), @@ -1535,11 +1537,11 @@ def from_json(self, json_obj: Dict[str, Any]) -> None: for field in json_obj.keys(): if field in self.__slots__: setattr(self, field, json_obj[field]) - + # Handle custom fields - for field, custom_field in self.CUSTOM_FIELD_MAP.items(): + for custom_field, field in self.CUSTOM_FIELD_MAP.items(): if field in json_obj: - setattr(self, custom_field, json_obj[field]) + setattr(self, field, json_obj[custom_field]) class JumpStartMetadataConfig(JumpStartDataHolderType): @@ -1732,7 +1734,9 @@ def __init__(self, spec: Dict[str, Any], is_hub_content: Optional[bool] = False) spec (Dict[str, Any]): Dictionary representation of spec. is_hub_content (Optional[bool]): Whether the model is from a private hub. """ + print("here?") super().__init__(spec, is_hub_content) + print("hi") self.from_json(spec) if self.inference_configs and self.inference_configs.get_top_config_from_ranking(): super().from_json(self.inference_configs.get_top_config_from_ranking().resolved_config) diff --git a/tests/unit/sagemaker/jumpstart/utils.py b/tests/unit/sagemaker/jumpstart/utils.py index bd870dc461..011005b95b 100644 --- a/tests/unit/sagemaker/jumpstart/utils.py +++ b/tests/unit/sagemaker/jumpstart/utils.py @@ -144,6 +144,7 @@ def get_special_model_spec( """ specs = JumpStartModelSpecs(SPECIAL_MODEL_SPECS_DICT[model_id]) + print(f"HERE {specs.predictor_specs}") return specs From 3e1ab00bd0c5351bf9e3c6b8bd205649fdff516b Mon Sep 17 00:00:00 2001 From: Benjamin Crabtree Date: Fri, 21 Feb 2025 21:10:42 +0000 Subject: [PATCH 10/11] remove logs --- src/sagemaker/jumpstart/types.py | 6 +----- tests/unit/sagemaker/jumpstart/utils.py | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/sagemaker/jumpstart/types.py b/src/sagemaker/jumpstart/types.py index 607a1d2dc2..f5c34d001b 100644 --- a/src/sagemaker/jumpstart/types.py +++ b/src/sagemaker/jumpstart/types.py @@ -1285,7 +1285,6 @@ def from_json(self, json_obj: Dict[str, Any]) -> None: Args: json_obj (Dict[str, Any]): Dictionary representation of spec. """ - print("HEYHEYHEY") if self._is_hub_content: json_obj = walk_and_apply_json(json_obj, camel_to_snake) self.model_id: str = json_obj.get("model_id") @@ -1362,7 +1361,6 @@ def from_json(self, json_obj: Dict[str, Any]) -> None: ) self.model_kwargs = deepcopy(json_obj.get("model_kwargs", {})) self.deploy_kwargs = deepcopy(json_obj.get("deploy_kwargs", {})) - print(f'HUH {json_obj.get("predictor_specs")}') self.predictor_specs: Optional[JumpStartPredictorSpecs] = ( JumpStartPredictorSpecs( json_obj.get("predictor_specs"), @@ -1541,7 +1539,7 @@ def from_json(self, json_obj: Dict[str, Any]) -> None: # Handle custom fields for custom_field, field in self.CUSTOM_FIELD_MAP.items(): if field in json_obj: - setattr(self, field, json_obj[custom_field]) + setattr(self, field, json_obj.get(custom_field)) class JumpStartMetadataConfig(JumpStartDataHolderType): @@ -1734,9 +1732,7 @@ def __init__(self, spec: Dict[str, Any], is_hub_content: Optional[bool] = False) spec (Dict[str, Any]): Dictionary representation of spec. is_hub_content (Optional[bool]): Whether the model is from a private hub. """ - print("here?") super().__init__(spec, is_hub_content) - print("hi") self.from_json(spec) if self.inference_configs and self.inference_configs.get_top_config_from_ranking(): super().from_json(self.inference_configs.get_top_config_from_ranking().resolved_config) diff --git a/tests/unit/sagemaker/jumpstart/utils.py b/tests/unit/sagemaker/jumpstart/utils.py index 011005b95b..bd870dc461 100644 --- a/tests/unit/sagemaker/jumpstart/utils.py +++ b/tests/unit/sagemaker/jumpstart/utils.py @@ -144,7 +144,6 @@ def get_special_model_spec( """ specs = JumpStartModelSpecs(SPECIAL_MODEL_SPECS_DICT[model_id]) - print(f"HERE {specs.predictor_specs}") return specs From b409c62911769670e4af0287bd7e66f37097cd93 Mon Sep 17 00:00:00 2001 From: Benjamin Crabtree Date: Fri, 21 Feb 2025 22:49:44 +0000 Subject: [PATCH 11/11] last update --- src/sagemaker/jumpstart/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sagemaker/jumpstart/types.py b/src/sagemaker/jumpstart/types.py index f5c34d001b..908241812e 100644 --- a/src/sagemaker/jumpstart/types.py +++ b/src/sagemaker/jumpstart/types.py @@ -1538,7 +1538,7 @@ def from_json(self, json_obj: Dict[str, Any]) -> None: # Handle custom fields for custom_field, field in self.CUSTOM_FIELD_MAP.items(): - if field in json_obj: + if custom_field in json_obj: setattr(self, field, json_obj.get(custom_field))