Skip to content

Commit 5f7e955

Browse files
author
Malav Shastri
committed
Address codestyledoc issues
1 parent 7e307bf commit 5f7e955

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

src/sagemaker/jumpstart/accessors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ def get_model_specs(
301301

302302
except Exception as ex:
303303
logging.info(
304-
"Recieved exeption while calling APIs for ContentType Model, retrying with ContentType ModelReference: "
304+
"Recieved exeption while calling APIs for ContentType Model, \
305+
retrying with ContentType ModelReference: "
305306
+ str(ex)
306307
)
307308
hub_model_arn = construct_hub_model_arn_from_inputs(

src/sagemaker/jumpstart/utils.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,25 +1012,37 @@ def get_jumpstart_configs(
10121012
)
10131013

10141014

1015-
def get_jumpstart_user_agent_extra_suffix(model_id: Optional[str], model_version: Optional[str], is_hub_content: Optional[bool]) -> str:
1015+
def get_jumpstart_user_agent_extra_suffix(
1016+
model_id: Optional[str], model_version: Optional[str], is_hub_content: Optional[bool]
1017+
) -> str:
10161018
"""Returns the model-specific user agent string to be added to requests."""
10171019
sagemaker_python_sdk_headers = get_user_agent_extra_suffix()
10181020
jumpstart_specific_suffix = f"md/js_model_id#{model_id} md/js_model_ver#{model_version}"
10191021
hub_specific_suffix = f"md/js_is_hub_content#{is_hub_content}"
1020-
return (
1021-
sagemaker_python_sdk_headers
1022-
if os.getenv(constants.ENV_VARIABLE_DISABLE_JUMPSTART_TELEMETRY, None)
1023-
else f"{sagemaker_python_sdk_headers} {jumpstart_specific_suffix} {hub_specific_suffix}"
1024-
)
1022+
1023+
if os.getenv(constants.ENV_VARIABLE_DISABLE_JUMPSTART_TELEMETRY, None):
1024+
headers = sagemaker_python_sdk_headers
1025+
elif model_id is None and model_version is None:
1026+
headers = f"{sagemaker_python_sdk_headers} {hub_specific_suffix}"
1027+
else:
1028+
headers = (
1029+
f"{sagemaker_python_sdk_headers} {jumpstart_specific_suffix} {hub_specific_suffix}"
1030+
)
1031+
1032+
return headers
10251033

10261034

10271035
def get_default_jumpstart_session_with_user_agent_suffix(
1028-
model_id: Optional[str] = None, model_version: Optional[str] = None, is_hub_content: Optional[bool] = False
1036+
model_id: Optional[str] = None,
1037+
model_version: Optional[str] = None,
1038+
is_hub_content: Optional[bool] = False,
10291039
) -> Session:
10301040
"""Returns default JumpStart SageMaker Session with model-specific user agent suffix."""
10311041
botocore_session = botocore.session.get_session()
10321042
botocore_config = botocore.config.Config(
1033-
user_agent_extra=get_jumpstart_user_agent_extra_suffix(model_id, model_version, is_hub_content),
1043+
user_agent_extra=get_jumpstart_user_agent_extra_suffix(
1044+
model_id, model_version, is_hub_content
1045+
),
10341046
)
10351047
botocore_session.set_default_client_config(botocore_config)
10361048
# shallow copy to not affect default session constant

0 commit comments

Comments
 (0)