-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] add session token as input to io config (#1224)
* Adds `session_token` field to `S3Config` allowing users to pass temp session tokens (like from sts)to daft. * Adds IO integration tests to ensure that we can use the IOConfig to access s3 with a signed request. * Closes: #1216
- Loading branch information
Showing
6 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
from botocore import session | ||
|
||
import daft | ||
from daft.io import IOConfig, S3Config | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def io_config() -> IOConfig: | ||
"""Create IOConfig with botocore's current session""" | ||
sess = session.Session() | ||
creds = sess.get_credentials() | ||
|
||
return IOConfig( | ||
s3=S3Config( | ||
key_id=creds.access_key, access_key=creds.secret_key, session_token=creds.token, region_name="us-west-2" | ||
) | ||
) | ||
|
||
|
||
@pytest.mark.integration() | ||
def test_url_download_aws_s3_public_bucket_with_creds(small_images_s3_paths, io_config): | ||
data = {"urls": small_images_s3_paths} | ||
df = daft.from_pydict(data) | ||
df = df.with_column("data", df["urls"].url.download(use_native_downloader=True, io_config=io_config)) | ||
|
||
data = df.to_pydict() | ||
assert len(data["data"]) == 6 | ||
for img_bytes in data["data"]: | ||
assert img_bytes is not None | ||
|
||
|
||
@pytest.mark.integration() | ||
def test_read_parquet_aws_s3_public_bucket_with_creds(io_config): | ||
filename = "s3://daft-public-data/test_fixtures/parquet-dev/mvp.parquet" | ||
df = daft.read_parquet(filename, io_config=io_config, use_native_downloader=True).collect() | ||
assert len(df) == 100 |
This file contains 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