universal_pathlib icon indicating copy to clipboard operation
universal_pathlib copied to clipboard

Reuse s3 boto client?

Open theogaraj opened this issue 2 years ago • 1 comments

I am starting to use upath a lot, it makes things so much easier! This is not an issue/bug, just a question (this github repo doesn't seem to have a "discussions" section).

I imagine that for S3 paths, somewhere under the hood upath is using boto3 and creating an S3 boto3 client.

If I create multiple UPaths, is each one creating a separate boto3 client? Or does it have a mechanism to reuse a client?

I am using both upath as well as smart_open, and the latter supports the ability to pass in your own boto3 client (described here). I couldn't find anything in the upath documentation, is this handled implicitly or just not supported?

theogaraj avatar Dec 22 '23 17:12 theogaraj

Hello @theogaraj,

universal_pathlib's s3 support depends on s3fs which in turn uses aiobotocore

You can pass keyword arguments down to aiobotocore via client_kwargs in s3fs: https://github.com/fsspec/s3fs/blob/34a32198188164fd48d4d1abcb267f033d1d1ce1/s3fs/core.py#L205

this would look like this:

aioboto_client_kwargs = {'somesetting': ...}

UPath("s3://mybucket/somefile.tar", client_kwargs=aioboto_client_kwargs)

Let me know if that helps, Andreas

ap-- avatar Jan 24 '24 15:01 ap--