From 296746de04812d405ddcf8470478d814086f4a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Pe=C3=B1a-Castellanos?= Date: Thu, 30 Jul 2026 08:30:16 -0500 Subject: [PATCH] feat: tag S3 client with metaflow user agent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gonzalo Peña-Castellanos --- metaflow/plugins/aws/aws_client.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/metaflow/plugins/aws/aws_client.py b/metaflow/plugins/aws/aws_client.py index 71479b52ce1..ff888b49234 100644 --- a/metaflow/plugins/aws/aws_client.py +++ b/metaflow/plugins/aws/aws_client.py @@ -35,6 +35,8 @@ def get_client( "Could not import module 'boto3'. Install boto3 first." ) + from metaflow.version import metaflow_version + # Convert dictionary config to Config object if needed if "config" in client_params and not isinstance( client_params["config"], Config @@ -49,6 +51,18 @@ def get_client( config.retries = S3_CLIENT_RETRY_CONFIG client_params["config"] = config + if module == "s3": + # Identify Metaflow to any S3-compatible endpoint, appending to (not + # replacing) any user agent the caller already configured. + config = client_params.get("config", Config()) + ua = "metaflow/%s" % metaflow_version + existing_ua = config.user_agent_extra + if not existing_ua: + config.user_agent_extra = ua + elif ua not in existing_ua.split(): + config.user_agent_extra = "%s %s" % (existing_ua, ua) + client_params["config"] = config + if AWS_SANDBOX_ENABLED: # role is ignored in the sandbox global cached_aws_sandbox_creds