settings.S3Settings
S3 profile and botocore tuning from <PREFIX>ENDPOINT_URL and friends.
Usage
settings.S3Settings()Authentication is by named AWS profile only: <PREFIX>PROFILE selects a section of ~/.aws/credentials (or of AWS_SHARED_CREDENTIALS_FILE), so no access key ever passes through the environment. Selecting a profile explicitly also drops boto’s environment-variable provider from the credential chain, so a stray AWS_ACCESS_KEY_ID in a shell cannot sign these requests.
<PREFIX>ENDPOINT_URL is optional. Without it, the endpoint is whatever the profile’s config section sets, which is where botocore, s3fs and ~freezebase.s3.s3_env() all read it from.
Build one with from_env(), which fixes the prefix.
Methods
| Name | Description |
|---|---|
| from_env() |
Read the settings whose variable names start with prefix.
|
| make_upath() |
Open an s3:// URI with these settings.
|
| resolve_path() |
Resolve a local path or an s3:// URI.
|
from_env()
Read the settings whose variable names start with prefix.
Usage
from_env(prefix)Parameters
prefix: str-
Environment variable prefix, such as
"GLACE_S3_".
Returns
S3Settings- The settings, remembering the prefix for its error messages.
make_upath()
Open an s3:// URI with these settings.
Usage
make_upath(uri)Parameters
uri: str-
An
s3://URI.
Returns
UPath-
The path, carrying the profile, endpoint, checksum policies and the retry budget
~freezebase.s3.make_s3_upath()applies.
Raises
ValueError- If no profile is configured.
resolve_path()
Resolve a local path or an s3:// URI.
Usage
resolve_path(raw)Parameters
raw: str-
A filesystem path, possibly
~-prefixed, or ans3://URI.
Returns
Path or UPath-
A
~pathlib.Pathfor a local value, else the URI opened with make_upath(), so downstream code does not branch on the storage backend.
Raises
ValueError-
If
rawis ans3://URI and no profile is configured.