Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for get_credentials callable in gcs_storage #774

Merged
merged 6 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions icechunk-python/python/icechunk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ConflictType,
Credentials,
Diff,
GcsBearerCredential,
GcsCredentials,
GcsStaticCredentials,
GCSummary,
Expand Down Expand Up @@ -95,6 +96,7 @@
"Credentials",
"Diff",
"GCSummary",
"GcsBearerCredential",
"GcsCredentials",
"GcsStaticCredentials",
"IcechunkError",
Expand Down
5 changes: 5 additions & 0 deletions icechunk-python/python/icechunk/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from datetime import datetime

from icechunk._icechunk_python import (
GcsBearerCredential,
ObjectStoreConfig,
S3Options,
S3StaticCredentials,
Expand Down Expand Up @@ -222,6 +223,7 @@ def gcs_storage(
bearer_token: str | None = None,
from_env: bool | None = None,
config: dict[str, str] | None = None,
get_credentials: Callable[[], GcsBearerCredential] | None = None,
) -> Storage:
"""Create a Storage instance that saves data in Google Cloud Storage object store.

Expand All @@ -235,13 +237,16 @@ def gcs_storage(
Fetch credentials from the operative system environment
bearer_token: str | None
The bearer token to use for the object store
get_credentials: Callable[[], GcsBearerCredential] | None
Use this function to get and refresh object store credentials
"""
credentials = gcs_credentials(
service_account_file=service_account_file,
service_account_key=service_account_key,
application_credentials=application_credentials,
bearer_token=bearer_token,
from_env=from_env,
get_credentials=get_credentials,
)
return Storage.new_gcs(
bucket=bucket,
Expand Down
2 changes: 1 addition & 1 deletion icechunk-python/tests/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __call__(self) -> S3StaticCredentials:
)


def test_refreshable_credentials_refresh(tmp_path: Path) -> None:
def test_s3_refreshable_credentials_refresh(tmp_path: Path) -> None:
path = tmp_path / "calls.txt"
creds_obj = ExpirableCredentials(path)

Expand Down