fsspec_utils.storage_options.cloud
API Documentation¶
This module defines storage option classes for various cloud providers, including Azure, Google Cloud Storage (GCS), and Amazon Web Services (AWS) S3. These classes provide structured ways to configure access to cloud storage, supporting different authentication methods and specific cloud service parameters.
AzureStorageOptions
¶
Azure Storage configuration options.
Provides configuration for Azure storage services:
- Azure Blob Storage (
az://
) - Azure Data Lake Storage Gen2 (
abfs://
) - Azure Data Lake Storage Gen1 (
adl://
)
Supports multiple authentication methods:
- Connection string
- Account key
- Service principal
- Managed identity
- SAS token
Attributes:
protocol
(str
): Storage protocol ("az", "abfs", or "adl")account_name
(str
): Storage account nameaccount_key
(str
): Storage account access keyconnection_string
(str
): Full connection stringtenant_id
(str
): Azure AD tenant IDclient_id
(str
): Service principal client IDclient_secret
(str
): Service principal client secretsas_token
(str
): SAS token for limited access
Example:
from_env()
¶
Create storage options from environment variables.
Reads standard Azure environment variables:
AZURE_STORAGE_PROTOCOL
AZURE_STORAGE_ACCOUNT_NAME
AZURE_STORAGE_ACCOUNT_KEY
AZURE_STORAGE_CONNECTION_STRING
AZURE_TENANT_ID
AZURE_CLIENT_ID
AZURE_CLIENT_SECRET
AZURE_STORAGE_SAS_TOKEN
Returns | Type | Description |
---|---|---|
AzureStorageOptions |
AzureStorageOptions |
Configured storage options |
Example:
to_env()
¶
Export options to environment variables.
Sets standard Azure environment variables.
Example:
GcsStorageOptions
¶
Google Cloud Storage configuration options.
Provides configuration for GCS access with support for:
- Service account authentication
- Default application credentials
- Token-based authentication
- Project configuration
- Custom endpoints
Attributes:
protocol
(str
): Storage protocol ("gs" or "gcs")token
(str
): Path to service account JSON fileproject
(str
): Google Cloud project IDaccess_token
(str
): OAuth2 access tokenendpoint_url
(str
): Custom storage endpointtimeout
(int
): Request timeout in seconds
Example:
from_env()
¶
Create storage options from environment variables.
Reads standard GCP environment variables:
GOOGLE_CLOUD_PROJECT
: ProjectGOOGLE_APPLICATION_CREDENTIALS
: Service account file pathSTORAGE_EMULATOR_HOST
: Custom endpoint (for testing)GCS_OAUTH_TOKEN
: OAuth2 access token
Returns | Type | Description |
---|---|---|
GcsStorageOptions |
GcsStorageOptions |
Configured storage options |
Example:
to_env()
¶
Export options to environment variables.
Sets standard GCP environment variables.
Example:
to_fsspec_kwargs()
¶
Convert options to fsspec filesystem arguments.
Returns | Type | Description |
---|---|---|
dict |
dict |
Arguments suitable for GCSFileSystem |
Example:
AwsStorageOptions
¶
AWS S3 storage configuration options.
Provides comprehensive configuration for S3 access with support for:
- Multiple authentication methods (keys, profiles, environment)
- Custom endpoints for S3-compatible services
- Region configuration
- SSL/TLS settings
Attributes:
protocol
(str
): Always "s3" for S3 storageaccess_key_id
(str
): AWS access key IDsecret_access_key
(str
): AWS secret access keysession_token
(str
): AWS session tokenendpoint_url
(str
): Custom S3 endpoint URLregion
(str
): AWS region nameallow_invalid_certificates
(bool
): Skip SSL certificate validationallow_http
(bool
): Allow unencrypted HTTP connections
Example:
create()
¶
Creates an AwsStorageOptions
instance, handling aliases and profile loading.
Parameter | Type | Description |
---|---|---|
protocol |
str |
Storage protocol, defaults to "s3". |
access_key_id |
str | None |
AWS access key ID. |
secret_access_key |
str | None |
AWS secret access key. |
session_token |
str | None |
AWS session token. |
endpoint_url |
str | None |
Custom S3 endpoint URL. |
region |
str | None |
AWS region name. |
allow_invalid_certificates |
bool | None |
Skip SSL certificate validation. |
allow_http |
bool | None |
Allow unencrypted HTTP connections. |
key |
str | None |
Alias for access_key_id . |
secret |
str | None |
Alias for secret_access_key . |
token |
str | None |
Alias for session_token . |
profile |
str | None |
AWS credentials profile name to load credentials from. |
Returns | Type | Description |
---|---|---|
AwsStorageOptions |
AwsStorageOptions |
An initialized AwsStorageOptions instance. |
from_aws_credentials()
¶
Create storage options from AWS credentials file.
Loads credentials from ~/.aws/credentials
and ~/.aws/config
files.
Parameter | Type | Description |
---|---|---|
profile |
str |
AWS credentials profile name |
allow_invalid_certificates |
bool |
Skip SSL certificate validation |
allow_http |
bool |
Allow unencrypted HTTP connections |
Returns | Type | Description |
---|---|---|
AwsStorageOptions |
AwsStorageOptions |
Configured storage options |
Raises | Type | Description |
---|---|---|
ValueError |
ValueError |
If profile not found |
FileNotFoundError |
FileNotFoundError |
If credentials files missing |
Example:
from_env()
¶
Create storage options from environment variables.
Reads standard AWS environment variables:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_SESSION_TOKEN
AWS_ENDPOINT_URL
AWS_DEFAULT_REGION
ALLOW_INVALID_CERTIFICATE
AWS_ALLOW_HTTP
Returns | Type | Description |
---|---|---|
AwsStorageOptions |
AwsStorageOptions |
Configured storage options |
Example:
to_fsspec_kwargs()
¶
Convert options to fsspec filesystem arguments.
Returns | Type | Description |
---|---|---|
dict |
dict |
Arguments suitable for fsspec S3FileSystem |
Example:
to_object_store_kwargs()
¶
Convert options to object store arguments.
Parameter | Type | Description |
---|---|---|
with_conditional_put |
bool |
Add etag-based conditional put support |
Returns | Type | Description |
---|---|---|
dict |
dict |
Arguments suitable for object store clients |
Example:
to_env()
¶
Export options to environment variables.
Sets standard AWS environment variables.
Example:
to_filesystem()
¶
Create fsspec filesystem instance from options.
Returns | Type | Description |
---|---|---|
AbstractFileSystem |
AbstractFileSystem |
Configured filesystem instance |