Skip to content

Commit

Permalink
Allow any AWS authentication method in studios (#19336)
Browse files Browse the repository at this point in the history
  • Loading branch information
andyland authored Jan 24, 2024
1 parent 71bfdc3 commit 577bd85
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
10 changes: 1 addition & 9 deletions src/lightning/data/streaming/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
if _BOTO3_AVAILABLE:
import boto3
import botocore
from botocore.credentials import InstanceMetadataProvider
from botocore.utils import InstanceMetadataFetcher


class S3Client:
Expand All @@ -31,14 +29,8 @@ def client(self) -> Any:

# Re-generate credentials for EC2
if self._last_time is None or (time() - self._last_time) > self._refetch_interval:
provider = InstanceMetadataProvider(iam_role_fetcher=InstanceMetadataFetcher(timeout=3600, num_attempts=5))
credentials = provider.load()
self._client = boto3.client(
"s3",
aws_access_key_id=credentials.access_key,
aws_secret_access_key=credentials.secret_key,
aws_session_token=credentials.token,
config=botocore.config.Config(retries={"max_attempts": 1000, "mode": "adaptive"}),
"s3", config=botocore.config.Config(retries={"max_attempts": 1000, "mode": "adaptive"})
)
self._last_time = time()

Expand Down
6 changes: 0 additions & 6 deletions tests/tests_data/streaming/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ def test_s3_client_with_cloud_space_id(monkeypatch):
botocore = mock.MagicMock()
monkeypatch.setattr(client, "botocore", botocore)

instance_metadata_provider = mock.MagicMock()
monkeypatch.setattr(client, "InstanceMetadataProvider", instance_metadata_provider)

instance_metadata_fetcher = mock.MagicMock()
monkeypatch.setattr(client, "InstanceMetadataFetcher", instance_metadata_fetcher)

monkeypatch.setenv("LIGHTNING_CLOUD_SPACE_ID", "dummy")

s3 = client.S3Client(1)
Expand Down

0 comments on commit 577bd85

Please sign in to comment.