-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add credential provider utility classes for AWS, GCP (#19297)
- Loading branch information
1 parent
997ebb4
commit a3401dc
Showing
12 changed files
with
375 additions
and
28 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
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,15 @@ | ||
from polars.io.cloud.credential_provider import ( | ||
CredentialProvider, | ||
CredentialProviderAWS, | ||
CredentialProviderFunction, | ||
CredentialProviderFunctionReturn, | ||
CredentialProviderGCP, | ||
) | ||
|
||
__all__ = [ | ||
"CredentialProvider", | ||
"CredentialProviderAWS", | ||
"CredentialProviderFunction", | ||
"CredentialProviderFunctionReturn", | ||
"CredentialProviderGCP", | ||
] |
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,55 @@ | ||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
from typing import TYPE_CHECKING, Literal | ||
|
||
from polars._utils.various import is_path_or_str_sequence | ||
|
||
if TYPE_CHECKING: | ||
from polars._typing import ScanSource | ||
|
||
|
||
def _first_scan_path( | ||
source: ScanSource, | ||
) -> str | Path | None: | ||
if isinstance(source, (str, Path)): | ||
return source | ||
elif is_path_or_str_sequence(source) and source: | ||
return source[0] | ||
|
||
return None | ||
|
||
|
||
def _infer_cloud_type( | ||
source: ScanSource, | ||
) -> Literal["aws", "azure", "gcp", "file", "http", "hf"] | None: | ||
if (path := _first_scan_path(source)) is None: | ||
return None | ||
|
||
splitted = str(path).split("://", maxsplit=1) | ||
|
||
# Fast path - local file | ||
if not splitted: | ||
return None | ||
|
||
scheme = splitted[0] | ||
|
||
if scheme == "file": | ||
return "file" | ||
|
||
if any(scheme == x for x in ["s3", "s3a"]): | ||
return "aws" | ||
|
||
if any(scheme == x for x in ["az", "azure", "adl", "abfs", "abfss"]): | ||
return "azure" | ||
|
||
if any(scheme == x for x in ["gs", "gcp", "gcs"]): | ||
return "gcp" | ||
|
||
if any(scheme == x for x in ["http", "https"]): | ||
return "http" | ||
|
||
if scheme == "hf": | ||
return "hf" | ||
|
||
return None |
Oops, something went wrong.