in src/fmeval/model_runners/util.py [0:0]
def get_user_agent_extra() -> str:
"""Return a string containing various user-agent headers to be passed to a botocore config.
This string will always contain SageMaker Python SDK headers obtained using the determine_prefix
utility function from sagemaker.user_agent. If fmeval telemetry is enabled, this string will
additionally contain an fmeval-specific header.
:return: A string to be used as the user_agent_extra parameter in a botocore config.
"""
# Obtain user-agent headers for information such as SageMaker notebook instance type and SageMaker Studio app type.
# We manually obtain these headers, so we can pass them in the user_agent_extra parameter of botocore.config.Config.
# We can't rely on sagemaker.session.Session's initializer to fill in these headers for us, since we want to pass
# our own sagemaker_client and sagemaker_runtime_client when creating a sagemaker.session.Session object.
# When you pass these to the initializer, the python SDK code for constructing a botocore config with the SDK
# headers won't get run.
sagemaker_python_sdk_headers = get_user_agent_extra_suffix()
return (
sagemaker_python_sdk_headers
if os.getenv(DISABLE_FMEVAL_TELEMETRY)
else f"{sagemaker_python_sdk_headers} lib/fmeval#{get_fmeval_package_version()}"
)