Skip to content

Commit 0f5b7fd

Browse files
authored
config homogenization (#323)
* config homogenization * Update azure docs * fix docs ref * Update s3 config * gcs config * update fsspec doc image
1 parent e3f5937 commit 0f5b7fd

File tree

18 files changed

+361
-907
lines changed

18 files changed

+361
-907
lines changed

docs/api/store/aws.md

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# AWS S3
22

33
::: obstore.store.S3Store
4-
::: obstore.store.S3ConfigInput
5-
options:
6-
show_if_no_docstring: true
74
::: obstore.store.S3Config
85
options:
96
show_if_no_docstring: true

docs/api/store/azure.md

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Microsoft Azure
22

33
::: obstore.store.AzureStore
4-
::: obstore.store.AzureConfigInput
5-
options:
6-
show_if_no_docstring: true
74
::: obstore.store.AzureConfig
85
options:
96
show_if_no_docstring: true

docs/api/store/gcs.md

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Google Cloud Storage
22

33
::: obstore.store.GCSStore
4-
::: obstore.store.GCSConfigInput
5-
options:
6-
show_if_no_docstring: true
74
::: obstore.store.GCSConfig
85
options:
96
show_if_no_docstring: true

docs/assets/fsspec-type-hinting.jpg

-84.4 KB
Binary file not shown.

docs/assets/fsspec-type-hinting.png

85.2 KB
Loading

docs/authentication.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Note that many authentication variants are already supported natively.
2525

2626
- Basic authentication, where an access key ID, secret access key, and optionally token are passed in via environment variables or configuration parameters.
2727
- [WebIdentity](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html). This requires the `AWS_WEB_IDENTITY_TOKEN_FILE` and `AWS_ROLE_ARN` environment variables to be set. Additionally, `AWS_ROLE_SESSION_NAME` can be set to specify a session name.
28-
- [Container credentials](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html). Ensure you pass [`aws_container_credentials_relative_uri`][obstore.store.S3ConfigInput.aws_container_credentials_relative_uri] to the `S3Store`.
28+
- [Container credentials](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html). Ensure you pass [`container_credentials_relative_uri`][obstore.store.S3Config.container_credentials_relative_uri] to the `S3Store`.
2929
- [Instance credentials](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html).
3030

3131
(A transcription of [this underlying code](https://github.com/apache/arrow-rs/blob/a00f9f43a0530b9255e4f9940e43121deedb0cc7/object_store/src/aws/builder.rs#L900-L970)).
@@ -44,7 +44,7 @@ Note that many authentication variants are already supported natively.
4444
- Workload identity OAuth2, using a `client_id`, `tenant_id`, and `federated_token_file` passed in by the user
4545
- OAuth2, using a `client_id`, `client_secret`, and `tenant_id` passed in by the user
4646
- A SAS key passed in by the user.
47-
- Azure CLI. (If you want to ensure the IMDS authentication is used below, pass [`use_azure_cli=False`][obstore.store.AzureConfigInput.use_azure_cli] to `AzureStore`.)
47+
- Azure CLI. (If you want to ensure the IMDS authentication is used below, pass [`use_azure_cli=False`][obstore.store.AzureConfig.use_azure_cli] to `AzureStore`.)
4848
- IMDS Managed Identity Provider.
4949

5050
(A transcription of [this underlying code](https://github.com/apache/arrow-rs/blob/a00f9f43a0530b9255e4f9940e43121deedb0cc7/object_store/src/azure/builder.rs#L942-L1019)).

docs/fsspec.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,18 @@ import fsspec
114114
from obstore.fsspec import register
115115

116116
if TYPE_CHECKING:
117-
from obstore.store import S3ConfigInput
117+
from obstore.store import S3Config
118118

119119
register("s3")
120120

121-
config: S3ConfigInput = {"region": "us-west-2", "skip_signature": True}
121+
config: S3Config = {"region": "us-west-2", "skip_signature": True}
122122
fs = fsspec.filesystem("s3", config=config)
123123
```
124124

125-
Then your type checker will validate that the `config` dictionary is compatible with [`S3ConfigInput`][obstore.store.S3ConfigInput]. VSCode also provides auto suggestions for parameters:
125+
Then your type checker will validate that the `config` dictionary is compatible with [`S3Config`][obstore.store.S3Config]. VSCode also provides auto suggestions for parameters:
126126

127-
![](./assets/fsspec-type-hinting.jpg)
127+
![](./assets/fsspec-type-hinting.png)
128128

129129
!!! note
130130

131-
`S3ConfigInput` is a "type-only" construct, and so it needs to be imported from within an `if TYPE_CHECKING` block. Additionally, `from __future__ import annotations` must be at the top of the file.
131+
`S3Config` is a "type-only" construct, and so it needs to be imported from within an `if TYPE_CHECKING` block. Additionally, `from __future__ import annotations` must be at the top of the file.

obstore/python/obstore/auth/boto3.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import botocore.session
1616

17-
from obstore.store import S3ConfigInput, S3Credential
17+
from obstore.store import S3Config, S3Credential
1818

1919

2020
class PolicyDescriptorTypeTypeDef(TypedDict): # noqa: D101
@@ -56,7 +56,7 @@ class Boto3CredentialProvider:
5656
""" # noqa: E501
5757

5858
credentials: botocore.credentials.Credentials
59-
config: S3ConfigInput
59+
config: S3Config
6060
ttl: timedelta
6161

6262
def __init__(
@@ -114,7 +114,7 @@ class StsCredentialProvider:
114114
store.
115115
""" # noqa: E501
116116

117-
config: S3ConfigInput
117+
config: S3Config
118118
session: boto3.session.Session
119119

120120
def __init__(

obstore/python/obstore/auth/earthdata.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from typing import TYPE_CHECKING
1111

1212
if TYPE_CHECKING:
13-
from obstore.store import S3ConfigInput, S3Credential
13+
from obstore.store import S3Config, S3Credential
1414

1515
CREDENTIALS_API = "https://archive.podaac.earthdata.nasa.gov/s3credentials"
1616

@@ -42,7 +42,7 @@ class NasaEarthdataCredentialProvider:
4242
[NASA Earthdata]: https://www.earthdata.nasa.gov/
4343
""" # noqa: E501
4444

45-
config: S3ConfigInput
45+
config: S3Config
4646

4747
def __init__(
4848
self,
@@ -118,7 +118,7 @@ class NasaEarthdataAsyncCredentialProvider:
118118
[NASA Earthdata]: https://www.earthdata.nasa.gov/
119119
""" # noqa: E501
120120

121-
config: S3ConfigInput
121+
config: S3Config
122122

123123
def __init__(
124124
self,

obstore/python/obstore/fsspec.py

+8-19
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,11 @@
5353
from obstore import Attributes, Bytes, ReadableFile, WritableFile
5454
from obstore.store import (
5555
AzureConfig,
56-
AzureConfigInput,
5756
ClientConfig,
5857
GCSConfig,
59-
GCSConfigInput,
6058
ObjectStore,
6159
RetryConfig,
6260
S3Config,
63-
S3ConfigInput,
6461
)
6562

6663
__all__ = [
@@ -119,56 +116,48 @@ def __init__(
119116
self,
120117
protocol: Literal["s3", "s3a"],
121118
*args: Any,
122-
config: S3Config | S3ConfigInput | None = None,
119+
config: S3Config | None = None,
123120
client_options: ClientConfig | None = None,
124121
retry_config: RetryConfig | None = None,
125122
asynchronous: bool = False,
126123
max_cache_size: int = 10,
127124
loop: Any = None,
128125
batch_size: int | None = None,
129-
**kwargs: Unpack[S3ConfigInput],
126+
**kwargs: Unpack[S3Config],
130127
) -> None: ...
131128
@overload
132129
def __init__(
133130
self,
134131
protocol: Literal["gs"],
135132
*args: Any,
136-
config: GCSConfig | GCSConfigInput | None = None,
133+
config: GCSConfig | None = None,
137134
client_options: ClientConfig | None = None,
138135
retry_config: RetryConfig | None = None,
139136
asynchronous: bool = False,
140137
max_cache_size: int = 10,
141138
loop: Any = None,
142139
batch_size: int | None = None,
143-
**kwargs: Unpack[GCSConfigInput],
140+
**kwargs: Unpack[GCSConfig],
144141
) -> None: ...
145142
@overload
146143
def __init__(
147144
self,
148145
protocol: Literal["az", "adl", "azure", "abfs", "abfss"],
149146
*args: Any,
150-
config: AzureConfig | AzureConfigInput | None = None,
147+
config: AzureConfig | None = None,
151148
client_options: ClientConfig | None = None,
152149
retry_config: RetryConfig | None = None,
153150
asynchronous: bool = False,
154151
max_cache_size: int = 10,
155152
loop: Any = None,
156153
batch_size: int | None = None,
157-
**kwargs: Unpack[AzureConfigInput],
154+
**kwargs: Unpack[AzureConfig],
158155
) -> None: ...
159156
def __init__( # noqa: PLR0913
160157
self,
161158
protocol: SUPPORTED_PROTOCOLS_T | str | None = None,
162159
*args: Any,
163-
config: (
164-
S3Config
165-
| S3ConfigInput
166-
| GCSConfig
167-
| GCSConfigInput
168-
| AzureConfig
169-
| AzureConfigInput
170-
| None
171-
) = None,
160+
config: (S3Config | GCSConfig | AzureConfig | None) = None,
172161
client_options: ClientConfig | None = None,
173162
retry_config: RetryConfig | None = None,
174163
asynchronous: bool = False,
@@ -184,7 +173,7 @@ def __init__( # noqa: PLR0913
184173
"gcs", or "abfs". If `None`, the default class-level protocol
185174
is used. Default to None.
186175
config: Configuration for the cloud storage provider, which can be one of
187-
S3Config, S3ConfigInput, GCSConfig, GCSConfigInput, AzureConfig,
176+
S3Config, GCSConfig, AzureConfig,
188177
or AzureConfigInput. Any of these values will be applied after checking
189178
for environment variables. If `None`, no cloud storage configuration is
190179
applied beyond what is found in environment variables.

obstore/python/obstore/store/__init__.pyi

+7-10
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@ from pathlib import Path
44
from typing import Any, TypeAlias, Unpack, overload
55

66
from ._aws import S3Config as S3Config
7-
from ._aws import S3ConfigInput as S3ConfigInput
87
from ._aws import S3Credential as S3Credential
98
from ._aws import S3CredentialProvider as S3CredentialProvider
109
from ._aws import S3Store as S3Store
1110
from ._azure import AzureAccessKey as AzureAccessKey
1211
from ._azure import AzureBearerToken as AzureBearerToken
1312
from ._azure import AzureConfig as AzureConfig
14-
from ._azure import AzureConfigInput as AzureConfigInput
1513
from ._azure import AzureCredential as AzureCredential
1614
from ._azure import AzureCredentialProvider as AzureCredentialProvider
1715
from ._azure import AzureSASToken as AzureSASToken
1816
from ._azure import AzureStore as AzureStore
1917
from ._client import ClientConfig as ClientConfig
2018
from ._gcs import GCSConfig as GCSConfig
21-
from ._gcs import GCSConfigInput as GCSConfigInput
2219
from ._gcs import GCSCredential as GCSCredential
2320
from ._gcs import GCSCredentialProvider as GCSCredentialProvider
2421
from ._gcs import GCSStore as GCSStore
@@ -30,31 +27,31 @@ from ._retry import RetryConfig as RetryConfig
3027
def from_url(
3128
url: str,
3229
*,
33-
config: S3Config | S3ConfigInput | None = None,
30+
config: S3Config | None = None,
3431
client_options: ClientConfig | None = None,
3532
retry_config: RetryConfig | None = None,
3633
credential_provider: S3CredentialProvider | None = None,
37-
**kwargs: Unpack[S3ConfigInput],
34+
**kwargs: Unpack[S3Config],
3835
) -> ObjectStore: ...
3936
@overload
4037
def from_url(
4138
url: str,
4239
*,
43-
config: GCSConfig | GCSConfigInput | None = None,
40+
config: GCSConfig | None = None,
4441
client_options: ClientConfig | None = None,
4542
retry_config: RetryConfig | None = None,
4643
credential_provider: GCSCredentialProvider | None = None,
47-
**kwargs: Unpack[GCSConfigInput],
44+
**kwargs: Unpack[GCSConfig],
4845
) -> ObjectStore: ...
4946
@overload
5047
def from_url(
5148
url: str,
5249
*,
53-
config: AzureConfig | AzureConfigInput | None = None,
50+
config: AzureConfig | None = None,
5451
client_options: ClientConfig | None = None,
5552
retry_config: RetryConfig | None = None,
5653
credential_provider: AzureCredentialProvider | None = None,
57-
**kwargs: Unpack[AzureConfigInput],
54+
**kwargs: Unpack[AzureConfig],
5855
) -> ObjectStore: ...
5956
@overload
6057
def from_url(
@@ -69,7 +66,7 @@ def from_url(
6966
def from_url(
7067
url: str,
7168
*,
72-
config: S3ConfigInput | GCSConfigInput | AzureConfigInput | None = None,
69+
config: S3Config | GCSConfig | AzureConfig | None = None,
7370
client_options: ClientConfig | None = None,
7471
retry_config: RetryConfig | None = None,
7572
credential_provider: Callable | None = None,

0 commit comments

Comments
 (0)