Skip to content

Commit

Permalink
πŸ›‚ Make get_stat_dir_s3 read from UPath credentials (#664)
Browse files Browse the repository at this point in the history
πŸ›‚ Make get_stat_dir_s3 read from UPath credentials
  • Loading branch information
bpenteado authored Mar 6, 2024
1 parent e9f2f89 commit 527d28d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lamindb_setup/core/upath.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,17 @@ def get_stat_file_cloud(stat: Dict) -> Tuple[int, str, str]:
def get_stat_dir_s3(path: UPath) -> Tuple[int, str, str, int]:
import boto3

if not AWS_CREDENTIALS_PRESENT:
if (
path.fs.key is not None
and path.fs.secret is not None
and path.fs.token is not None
):
s3 = boto3.session.Session(
aws_access_key_id=path.fs.key,
aws_secret_access_key=path.fs.secret,
aws_session_token=path.fs.token,
).resource("s3")
elif not AWS_CREDENTIALS_PRESENT:
# passing the following param directly to Session() doesn't
# work, unfortunately: botocore_session=path.fs.session
from botocore import UNSIGNED
Expand Down

0 comments on commit 527d28d

Please sign in to comment.