Skip to content

Commit

Permalink
Merge pull request #715 from kevinlu1211/fix/add_region_to_s3
Browse files Browse the repository at this point in the history
fix: added region to S3
  • Loading branch information
kristinagrig06 committed Mar 25, 2021
2 parents 96a3e49 + ff283a5 commit 7b7af37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hub/store/s3_file_system_replacement.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ def get_mapper(self, root: str, check=False, create=False):
root = "s3://" + root
client_kwargs = self._kwargs.get("client_kwargs")
endpoint_url = client_kwargs and client_kwargs.get("endpoint_url") or None
aws_region = client_kwargs and client_kwargs.get("region_name") or None
return S3Storage(
self,
root,
aws_access_key_id=self._kwargs.get("key"),
aws_secret_access_key=self._kwargs.get("secret"),
aws_session_token=self._kwargs.get("token"),
aws_region=aws_region,
endpoint_url=endpoint_url,
)
4 changes: 4 additions & 0 deletions hub/store/s3_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ def __init__(
aws_session_token=None,
parallel=25,
endpoint_url=None,
aws_region=None,
):
self.s3fs = s3fs
self.root = {}
self.url = url
self.public = public
self.parallel = parallel
self.aws_region = aws_region
self.endpoint_url = endpoint_url
self.bucket = url.split("/")[2]
self.path = "/".join(url.split("/")[3:])
Expand All @@ -54,6 +56,7 @@ def __init__(
aws_session_token=aws_session_token,
config=client_config,
endpoint_url=endpoint_url,
region_name=aws_region,
)

self.resource = boto3.resource(
Expand All @@ -63,6 +66,7 @@ def __init__(
aws_session_token=aws_session_token,
config=client_config,
endpoint_url=endpoint_url,
region_name=aws_region,
)

def __setitem__(self, path, content):
Expand Down

0 comments on commit 7b7af37

Please sign in to comment.