feat: set BentoML user agent on the S3 client used by import/export - #5680
Draft
goanpeca wants to merge 2 commits into
Draft
feat: set BentoML user agent on the S3 client used by import/export#5680goanpeca wants to merge 2 commits into
goanpeca wants to merge 2 commits into
Conversation
Signed-off-by: Gonzalo Peña-Castellanos <goanpeca@gmail.com>
Signed-off-by: Gonzalo Peña-Castellanos <goanpeca@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR address?
bentoml models export/import(and the Bento equivalents) build their fsspec filesystem without passing any client configuration, so requests tos3://targets go out with the default botocore user agent. Nothing in an access log or a support ticket identifies the traffic as coming from BentoML.This PR appends
BentoML/<version>to the user agent of the S3 client used by import/export, and documents how to point the Model Store at a non-AWS, S3-compatible endpoint.Changes
src/bentoml/_internal/exportable.py_s3_storage_options(protocol), which returns{"s3": {"config_kwargs": {"user_agent_extra": f"BentoML/{BENTOML_VERSION}"}}}when the protocol iss3, and{}otherwise.BENTOML_VERSIONis imported inside the helper so the module import stays unchanged.fsspec.url_to_fs()on the import path,fsspec.url_to_fs()on the export path, andtarget_options=forZipFileSystem/TarFileSystem, so archives read straight out of S3 are configured too.docs/source/build-with-bentoml/model-loading-and-management.rsts3://scheme works with Amazon S3 and with any S3-compatible object store (Backblaze B2, Cloudflare R2, MinIO), and that the standardAWS_ENDPOINT_URLenvironment variable selects a non-AWS endpoint. Includes a two-line example.Notes
user_agent_extrais botocore's documented hook for appending to the user agent string, so credentials,endpoint_url, region and any other storage option a user already passes are left untouched. Non-s3protocols (file,gs,abfs, ...) receive an empty dict and behave exactly as before.{"s3": {...}}is fsspec's protocol-keyed storage-option form, which bothurl_to_fs()and the chainedtarget_optionsunderstand, so the same helper works for the plain and archive code paths._s3_storage_options()if you would prefer one.Before submitting:
ruff-checkandruff-formatare clean on the changed file.