Skip to content

Commit 55a010d

Browse files
authored
Merge master into benchmark feature (#4652)
1 parent b33d6d2 commit 55a010d

File tree

12 files changed

+164
-167
lines changed

12 files changed

+164
-167
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## v2.218.1 (2024-05-03)
4+
5+
### Bug Fixes and Other Changes
6+
7+
* Fix UserAgent logging in Python SDK
8+
* chore: release tgi 2.0.1
9+
* chore: update skipped flaky tests
10+
311
## v2.218.0 (2024-05-01)
412

513
### Features

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.218.1.dev0
1+
2.218.2.dev0

src/sagemaker/image_uri_config/huggingface-llm.json

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"1.2": "1.2.0",
1313
"1.3": "1.3.3",
1414
"1.4": "1.4.5",
15-
"2.0": "2.0.0"
15+
"2.0": "2.0.1"
1616
},
1717
"versions": {
1818
"0.6.0": {
@@ -578,6 +578,53 @@
578578
"container_version": {
579579
"gpu": "cu121-ubuntu22.04"
580580
}
581+
},
582+
"2.0.1": {
583+
"py_versions": [
584+
"py310"
585+
],
586+
"registries": {
587+
"af-south-1": "626614931356",
588+
"il-central-1": "780543022126",
589+
"ap-east-1": "871362719292",
590+
"ap-northeast-1": "763104351884",
591+
"ap-northeast-2": "763104351884",
592+
"ap-northeast-3": "364406365360",
593+
"ap-south-1": "763104351884",
594+
"ap-south-2": "772153158452",
595+
"ap-southeast-1": "763104351884",
596+
"ap-southeast-2": "763104351884",
597+
"ap-southeast-3": "907027046896",
598+
"ap-southeast-4": "457447274322",
599+
"ca-central-1": "763104351884",
600+
"cn-north-1": "727897471807",
601+
"cn-northwest-1": "727897471807",
602+
"eu-central-1": "763104351884",
603+
"eu-central-2": "380420809688",
604+
"eu-north-1": "763104351884",
605+
"eu-west-1": "763104351884",
606+
"eu-west-2": "763104351884",
607+
"eu-west-3": "763104351884",
608+
"eu-south-1": "692866216735",
609+
"eu-south-2": "503227376785",
610+
"me-south-1": "217643126080",
611+
"me-central-1": "914824155844",
612+
"sa-east-1": "763104351884",
613+
"us-east-1": "763104351884",
614+
"us-east-2": "763104351884",
615+
"us-gov-east-1": "446045086412",
616+
"us-gov-west-1": "442386744353",
617+
"us-iso-east-1": "886529160074",
618+
"us-isob-east-1": "094389454867",
619+
"us-west-1": "763104351884",
620+
"us-west-2": "763104351884",
621+
"ca-west-1": "204538143572"
622+
},
623+
"tag_prefix": "2.1.1-tgi2.0.1",
624+
"repository": "huggingface-pytorch-tgi-inference",
625+
"container_version": {
626+
"gpu": "cu121-ubuntu22.04"
627+
}
581628
}
582629
}
583630
}

src/sagemaker/jumpstart/notebook_utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,12 @@ def list_jumpstart_models( # pylint: disable=redefined-builtin
329329
return sorted(list(model_id_version_dict.keys()))
330330

331331
if not list_old_models:
332-
model_id_version_dict = {
333-
model_id: set([max(versions)]) for model_id, versions in model_id_version_dict.items()
334-
}
332+
for model_id, versions in model_id_version_dict.items():
333+
try:
334+
model_id_version_dict.update({model_id: set([max(versions)])})
335+
except TypeError:
336+
versions = [str(v) for v in versions]
337+
model_id_version_dict.update({model_id: set([max(versions)])})
335338

336339
model_id_version_set: Set[Tuple[str, str]] = set()
337340
for model_id in model_id_version_dict:

src/sagemaker/jumpstart/payload_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from sagemaker.jumpstart.constants import (
2424
DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
2525
)
26-
from sagemaker.jumpstart.enums import MIMEType
26+
from sagemaker.jumpstart.enums import JumpStartModelType, MIMEType
2727
from sagemaker.jumpstart.types import JumpStartSerializablePayload
2828
from sagemaker.jumpstart.utils import (
2929
get_jumpstart_content_bucket,
@@ -61,6 +61,7 @@ def _construct_payload(
6161
tolerate_vulnerable_model: bool = False,
6262
tolerate_deprecated_model: bool = False,
6363
sagemaker_session: Session = DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
64+
model_type: JumpStartModelType = JumpStartModelType.OPEN_WEIGHTS,
6465
) -> Optional[JumpStartSerializablePayload]:
6566
"""Returns example payload from prompt.
6667
@@ -83,6 +84,8 @@ def _construct_payload(
8384
object, used for SageMaker interactions. If not
8485
specified, one is created using the default AWS configuration
8586
chain. (Default: sagemaker.jumpstart.constants.DEFAULT_JUMPSTART_SAGEMAKER_SESSION).
87+
model_type (JumpStartModelType): The type of the model, can be open weights model or
88+
proprietary model. (Default: JumpStartModelType.OPEN_WEIGHTS).
8689
Returns:
8790
Optional[JumpStartSerializablePayload]: serializable payload with prompt, or None if
8891
this feature is unavailable for the specified model.
@@ -94,6 +97,7 @@ def _construct_payload(
9497
tolerate_vulnerable_model=tolerate_vulnerable_model,
9598
tolerate_deprecated_model=tolerate_deprecated_model,
9699
sagemaker_session=sagemaker_session,
100+
model_type=model_type,
97101
)
98102
if payloads is None or len(payloads) == 0:
99103
return None

src/sagemaker/jumpstart/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ def __init__(
10971097
config (Dict[str, Any]):
10981098
Dictionary representation of the config.
10991099
base_fields (Dict[str, Any]):
1100-
The default base fields that are used to construct the final resolved config.
1100+
The default base fields that are used to construct the resolved config.
11011101
config_components (Dict[str, JumpStartConfigComponent]):
11021102
The list of components that are used to construct the resolved config.
11031103
"""

src/sagemaker/session.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
from sagemaker.deprecations import deprecated_class
122122
from sagemaker.enums import EndpointType
123123
from sagemaker.inputs import ShuffleConfig, TrainingInput, BatchDataCaptureConfig
124-
from sagemaker.user_agent import prepend_user_agent
124+
from sagemaker.user_agent import get_user_agent_extra_suffix
125125
from sagemaker.utils import (
126126
name_from_image,
127127
secondary_training_status_changed,
@@ -285,6 +285,7 @@ def _initialize(
285285
Creates or uses a boto_session, sagemaker_client and sagemaker_runtime_client.
286286
Sets the region_name.
287287
"""
288+
288289
self.boto_session = boto_session or boto3.DEFAULT_SESSION or boto3.Session()
289290

290291
self._region_name = self.boto_session.region_name
@@ -293,19 +294,30 @@ def _initialize(
293294
"Must setup local AWS configuration with a region supported by SageMaker."
294295
)
295296

296-
self.sagemaker_client = sagemaker_client or self.boto_session.client("sagemaker")
297-
prepend_user_agent(self.sagemaker_client)
297+
# Make use of user_agent_extra field of the botocore_config object
298+
# to append SageMaker Python SDK specific user_agent suffix
299+
# to the current User-Agent header value from boto3
300+
# This config will also make sure that user_agent never fails to log the User-Agent string
301+
# even if boto User-Agent header format is updated in the future
302+
# Ref: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html
303+
botocore_config = botocore.config.Config(user_agent_extra=get_user_agent_extra_suffix())
304+
305+
# Create sagemaker_client with the botocore_config object
306+
# This config is customized to append SageMaker Python SDK specific user_agent suffix
307+
self.sagemaker_client = sagemaker_client or self.boto_session.client(
308+
"sagemaker", config=botocore_config
309+
)
298310

299311
if sagemaker_runtime_client is not None:
300312
self.sagemaker_runtime_client = sagemaker_runtime_client
301313
else:
302-
config = botocore.config.Config(read_timeout=80)
314+
config = botocore.config.Config(
315+
read_timeout=80, user_agent_extra=get_user_agent_extra_suffix()
316+
)
303317
self.sagemaker_runtime_client = self.boto_session.client(
304318
"runtime.sagemaker", config=config
305319
)
306320

307-
prepend_user_agent(self.sagemaker_runtime_client)
308-
309321
if sagemaker_featurestore_runtime_client:
310322
self.sagemaker_featurestore_runtime_client = sagemaker_featurestore_runtime_client
311323
else:
@@ -316,8 +328,9 @@ def _initialize(
316328
if sagemaker_metrics_client:
317329
self.sagemaker_metrics_client = sagemaker_metrics_client
318330
else:
319-
self.sagemaker_metrics_client = self.boto_session.client("sagemaker-metrics")
320-
prepend_user_agent(self.sagemaker_metrics_client)
331+
self.sagemaker_metrics_client = self.boto_session.client(
332+
"sagemaker-metrics", config=botocore_config
333+
)
321334

322335
self.s3_client = self.boto_session.client("s3", region_name=self.boto_region_name)
323336
self.s3_resource = self.boto_session.resource("s3", region_name=self.boto_region_name)

src/sagemaker/user_agent.py

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
"""Placeholder docstring"""
1414
from __future__ import absolute_import
1515

16-
import platform
17-
import sys
1816
import json
1917
import os
2018

@@ -28,12 +26,6 @@
2826
STUDIO_METADATA_FILE = "/opt/ml/metadata/resource-metadata.json"
2927

3028
SDK_VERSION = importlib_metadata.version("sagemaker")
31-
OS_NAME = platform.system() or "UnresolvedOS"
32-
OS_VERSION = platform.release() or "UnresolvedOSVersion"
33-
OS_NAME_VERSION = "{}/{}".format(OS_NAME, OS_VERSION)
34-
PYTHON_VERSION = "Python/{}.{}.{}".format(
35-
sys.version_info.major, sys.version_info.minor, sys.version_info.micro
36-
)
3729

3830

3931
def process_notebook_metadata_file():
@@ -63,45 +55,24 @@ def process_studio_metadata_file():
6355
return None
6456

6557

66-
def determine_prefix(user_agent=""):
67-
"""Determines the prefix for the user agent string.
58+
def get_user_agent_extra_suffix():
59+
"""Get the user agent extra suffix string specific to SageMaker Python SDK
6860
69-
Args:
70-
user_agent (str): The user agent string to prepend the prefix to.
61+
Adhers to new boto recommended User-Agent 2.0 header format
7162
7263
Returns:
73-
str: The user agent string with the prefix prepended.
64+
str: The user agent extra suffix string to be appended
7465
"""
75-
prefix = "{}/{}".format(SDK_PREFIX, SDK_VERSION)
76-
77-
if PYTHON_VERSION not in user_agent:
78-
prefix = "{} {}".format(prefix, PYTHON_VERSION)
79-
80-
if OS_NAME_VERSION not in user_agent:
81-
prefix = "{} {}".format(prefix, OS_NAME_VERSION)
66+
suffix = "lib/{}#{}".format(SDK_PREFIX, SDK_VERSION)
8267

8368
# Get the notebook instance type and prepend it to the user agent string if exists
8469
notebook_instance_type = process_notebook_metadata_file()
8570
if notebook_instance_type:
86-
prefix = "{} {}/{}".format(prefix, NOTEBOOK_PREFIX, notebook_instance_type)
71+
suffix = "{} md/{}#{}".format(suffix, NOTEBOOK_PREFIX, notebook_instance_type)
8772

8873
# Get the studio app type and prepend it to the user agent string if exists
8974
studio_app_type = process_studio_metadata_file()
9075
if studio_app_type:
91-
prefix = "{} {}/{}".format(prefix, STUDIO_PREFIX, studio_app_type)
92-
93-
return prefix
94-
95-
96-
def prepend_user_agent(client):
97-
"""Prepends the user agent string with the SageMaker Python SDK version.
98-
99-
Args:
100-
client (botocore.client.BaseClient): The client to prepend the user agent string for.
101-
"""
102-
prefix = determine_prefix(client._client_config.user_agent)
76+
suffix = "{} md/{}#{}".format(suffix, STUDIO_PREFIX, studio_app_type)
10377

104-
if client._client_config.user_agent is None:
105-
client._client_config.user_agent = prefix
106-
else:
107-
client._client_config.user_agent = "{} {}".format(prefix, client._client_config.user_agent)
78+
return suffix

tests/unit/sagemaker/image_uris/test_huggingface_llm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"1.4.2": "2.1.1-tgi1.4.2-gpu-py310-cu121-ubuntu22.04",
3333
"1.4.5": "2.1.1-tgi1.4.5-gpu-py310-cu121-ubuntu22.04",
3434
"2.0.0": "2.1.1-tgi2.0.0-gpu-py310-cu121-ubuntu22.04",
35+
"2.0.1": "2.1.1-tgi2.0.1-gpu-py310-cu121-ubuntu22.04",
3536
},
3637
"inf2": {
3738
"0.0.16": "1.13.1-optimum0.0.16-neuronx-py310-ubuntu22.04",

0 commit comments

Comments
 (0)