Eventual-Inc / Daft

Distributed DataFrame for Python designed for the cloud, powered by Rust
https://getdaft.io
Apache License 2.0
1.82k stars 113 forks source link

[FEAT] Custom S3 Credentials Provider #2233

Closed kevinzwang closed 2 weeks ago

kevinzwang commented 1 month ago

This PR allows the user to provide their own S3 credentials provider as a function that returns S3 credentials. If provided, static credentials are ignored and the function is called at the start and every time S3 credentials are used and the provided credential expiry has passed.

import daft

def get_creds() -> daft.io.S3Credentials:
    ...
    return daft.io.S3Credentials(
        key_id="[KEY_ID]"
        access_key="[ACCES KEY]"
        session_token="[SESSIONT_TOKEN]"
        expiry=int(expire_time.timestamp())
    )

io_config = daft.io.IOConfig(s3=daft.io.S3Config(credentials_provider=get_creds, ...)

df = daft.read_parquet("s3://path/to/file.parquet", io_config=io_config)
codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Please upload report for BASE (main@df9aa15). Learn more about missing BASE report. Report is 14 commits behind head on main.

:exclamation: Current head 5e0552f differs from pull request most recent head 56a5088

Please upload reports for the commit 56a5088 to get more accurate results.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/Eventual-Inc/Daft/pull/2233/graphs/tree.svg?width=650&height=150&src=pr&token=J430QVFE89&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Eventual-Inc)](https://app.codecov.io/gh/Eventual-Inc/Daft/pull/2233?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Eventual-Inc) ```diff @@ Coverage Diff @@ ## main #2233 +/- ## ======================================= Coverage ? 85.31% ======================================= Files ? 71 Lines ? 7722 Branches ? 0 ======================================= Hits ? 6588 Misses ? 1134 Partials ? 0 ``` | [Files](https://app.codecov.io/gh/Eventual-Inc/Daft/pull/2233?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Eventual-Inc) | Coverage Δ | | |---|---|---| | [daft/io/\_\_init\_\_.py](https://app.codecov.io/gh/Eventual-Inc/Daft/pull/2233?src=pr&el=tree&filepath=daft%2Fio%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Eventual-Inc#diff-ZGFmdC9pby9fX2luaXRfXy5weQ==) | `95.83% <ø> (ø)` | |