sagemaker.core.utils.user_agent#

Functions

get_user_agent_extra_suffix()

Get the user agent extra suffix string specific to SageMakerCore

process_notebook_metadata_file()

Check if the platform is SageMaker Notebook, if yes, return the InstanceType

process_studio_metadata_file()

Check if the platform is SageMaker Studio, if yes, return the AppType

sanitize_user_agent_string_component(raw_str)

Sanitize a User-Agent string component by replacing disallowed characters with '-'.

sagemaker.core.utils.user_agent.get_user_agent_extra_suffix() str[source]#

Get the user agent extra suffix string specific to SageMakerCore

Adhers to new boto recommended User-Agent 2.0 header format

Returns:

The user agent extra suffix string to be appended

Return type:

str

sagemaker.core.utils.user_agent.process_notebook_metadata_file() str[source]#

Check if the platform is SageMaker Notebook, if yes, return the InstanceType

Returns:

The InstanceType of the SageMaker Notebook if it exists, otherwise None

Return type:

str

sagemaker.core.utils.user_agent.process_studio_metadata_file() str[source]#

Check if the platform is SageMaker Studio, if yes, return the AppType

Returns:

The AppType of the SageMaker Studio if it exists, otherwise None

Return type:

str

sagemaker.core.utils.user_agent.sanitize_user_agent_string_component(raw_str, allow_hash=False)[source]#

Sanitize a User-Agent string component by replacing disallowed characters with ‘-‘.

Parameters:
  • raw_str (str) – The input string to sanitize.

  • allow_hash (bool) – Whether ‘#’ is considered an allowed character.

Returns:

The sanitized string.

Return type:

str