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