Skip to content

Commit 4bb64d7

Browse files
committed
fix: adding Unit tests for resourcekey and tags for api in config for intelligent defaults
Added Unit tests to test the config injection for SAGEMAKER_CONFIG_ENDPOINT Fixed a couple of unit tests
1 parent 7720bc7 commit 4bb64d7

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

src/sagemaker/session.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
ENDPOINT_CONFIG,
8989
ENDPOINT_CONFIG_DATA_CAPTURE_PATH,
9090
ENDPOINT_CONFIG_ASYNC_INFERENCE_PATH,
91+
ENDPOINT,
9192
ENDPOINT_TAGS_PATH,
9293
SAGEMAKER,
9394
FEATURE_GROUP,
@@ -3968,7 +3969,7 @@ def create_endpoint(self, endpoint_name, config_name, tags=None, wait=True):
39683969
tags = tags or []
39693970
tags = _append_project_tags(tags)
39703971
tags = self._append_sagemaker_config_tags(
3971-
tags, "{}.{}.{}".format(SAGEMAKER, ENDPOINT_TAGS_PATH, TAGS)
3972+
tags, "{}.{}.{}".format(SAGEMAKER, ENDPOINT, TAGS)
39723973
)
39733974

39743975
self.sagemaker_client.create_endpoint(
@@ -4468,9 +4469,6 @@ def endpoint_from_model_data(
44684469
model_vpc_config = vpc_utils.sanitize(model_vpc_config)
44694470
endpoint_config_tags = _append_project_tags(tags)
44704471
endpoint_tags = _append_project_tags(tags)
4471-
endpoint_tags = self._append_sagemaker_config_tags(
4472-
endpoint_tags, "{}.{}.{}".format(SAGEMAKER, ENDPOINT_TAGS_PATH, TAGS)
4473-
)
44744472
endpoint_config_tags = self._append_sagemaker_config_tags(
44754473
endpoint_config_tags, "{}.{}.{}".format(SAGEMAKER, ENDPOINT_CONFIG, TAGS)
44764474
)
@@ -4571,9 +4569,6 @@ def endpoint_from_production_variants(
45714569
endpoint_config_tags = _append_project_tags(tags)
45724570
endpoint_tags = _append_project_tags(tags)
45734571

4574-
endpoint_tags = self._append_sagemaker_config_tags(
4575-
endpoint_tags, "{}.{}.{}".format(SAGEMAKER, ENDPOINT_TAGS_PATH, TAGS)
4576-
)
45774572
endpoint_config_tags = self._append_sagemaker_config_tags(
45784573
endpoint_config_tags, "{}.{}.{}".format(SAGEMAKER, ENDPOINT_CONFIG, TAGS)
45794574
)

tests/unit/test_session.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,7 +2552,7 @@ def test_create_edge_packaging_with_sagemaker_config_injection(sagemaker_session
25522552
"OutputConfig"
25532553
]["KmsKeyId"]
25542554
expected_tags = SAGEMAKER_CONFIG_EDGE_PACKAGING_JOB["SageMaker"]["EdgePackagingJob"]["Tags"]
2555-
expected_resource_key = SAGEMAKER_CONFIG_EDGE_PACKAGING_JOB["SageMaker"]["EdgePackagingJob"]["ResourceKey"]
2555+
expected_resource_key = (SAGEMAKER_CONFIG_EDGE_PACKAGING_JOB["SageMaker"]["EdgePackagingJob"]["ResourceKey"],)
25562556
sagemaker_session.sagemaker_client.create_edge_packaging_job.assert_called_with(
25572557
RoleArn=expected_role_arn, # provided from config
25582558
OutputConfig={
@@ -3058,7 +3058,7 @@ def test_endpoint_from_production_variants_with_sagemaker_config_injection(
30583058
sagemaker_session.sagemaker_client.create_endpoint.assert_called_with(
30593059
EndpointConfigName="some-endpoint",
30603060
EndpointName="some-endpoint",
3061-
Tags=expected_tags, # from config
3061+
Tags=[],
30623062
)
30633063

30643064

@@ -3126,7 +3126,7 @@ def test_endpoint_from_production_variants_with_sagemaker_config_injection_parti
31263126
sagemaker_session.sagemaker_client.create_endpoint.assert_called_with(
31273127
EndpointConfigName="some-endpoint",
31283128
EndpointName="some-endpoint",
3129-
Tags=expected_tags, # from config
3129+
Tags=[],
31303130
)
31313131

31323132

@@ -3187,7 +3187,7 @@ def test_endpoint_from_production_variants_with_sagemaker_config_injection_no_km
31873187
sagemaker_session.sagemaker_client.create_endpoint.assert_called_with(
31883188
EndpointConfigName="some-endpoint",
31893189
EndpointName="some-endpoint",
3190-
Tags=expected_tags, # from config
3190+
Tags=[],
31913191
)
31923192

31933193

@@ -3268,7 +3268,7 @@ def test_endpoint_from_production_variants_with_sagemaker_config_injection_tags(
32683268
EndpointConfigName="some-endpoint", EndpointName="some-endpoint", Tags=expected_tags
32693269
)
32703270
sagemaker_session.sagemaker_client.create_endpoint_config.assert_called_with(
3271-
EndpointConfigName="some-endpoint", ProductionVariants=pvs, Tags=[]
3271+
EndpointConfigName="some-endpoint", ProductionVariants=pvs
32723272
)
32733273

32743274

@@ -3319,11 +3319,12 @@ def test_endpoint_from_production_variants_with_accelerator_type_sagemaker_confi
33193319
)
33203320
ims.sagemaker_client.describe_endpoint_config = Mock(side_effect=ex)
33213321
expected_tags = SAGEMAKER_CONFIG_ENDPOINT["SageMaker"]["Endpoint"]["Tags"]
3322+
sagemaker_session.endpoint_from_production_variants("some-endpoint", pvs)
33223323
sagemaker_session.sagemaker_client.create_endpoint.assert_called_with(
33233324
EndpointConfigName="some-endpoint", EndpointName="some-endpoint", Tags=expected_tags
33243325
)
33253326
sagemaker_session.sagemaker_client.create_endpoint_config.assert_called_with(
3326-
EndpointConfigName="some-endpoint", ProductionVariants=pvs, Tags=[]
3327+
EndpointConfigName="some-endpoint", ProductionVariants=pvs
33273328
)
33283329

33293330

@@ -3395,7 +3396,7 @@ def test_endpoint_from_production_variants_with_serverless_inference_config_sage
33953396
EndpointConfigName="some-endpoint", EndpointName="some-endpoint", Tags=expected_tags
33963397
)
33973398
sagemaker_session.sagemaker_client.create_endpoint_config.assert_called_with(
3398-
EndpointConfigName="some-endpoint", ProductionVariants=pvs, Tags=[]
3399+
EndpointConfigName="some-endpoint", ProductionVariants=pvs
33993400
)
34003401

34013402

0 commit comments

Comments
 (0)