fsspeckit.storage_options API Reference¶
storage_options
¶
Storage configuration options for different cloud providers and services.
Classes¶
fsspeckit.storage_options.BaseStorageOptions
¶
Bases: Struct
Base class for filesystem storage configuration options.
Provides common functionality for all storage option classes including: - YAML serialization/deserialization - Dictionary conversion - Filesystem instance creation - Configuration updates
Attributes:
| Name | Type | Description |
|---|---|---|
protocol |
str
|
Storage protocol identifier (e.g., "s3", "gs", "file") |
Example
Functions¶
fsspeckit.storage_options.BaseStorageOptions.from_yaml
classmethod
¶
from_yaml(
path: str, fs: AbstractFileSystem = None
) -> BaseStorageOptions
Load storage options from YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to YAML configuration file |
required |
fs
|
AbstractFileSystem
|
Filesystem to use for reading file |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
BaseStorageOptions |
BaseStorageOptions
|
Loaded storage options instance |
Example
Source code in src/fsspeckit/storage_options/base.py
fsspeckit.storage_options.BaseStorageOptions.to_dict
¶
Convert storage options to dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
with_protocol
|
bool
|
Whether to include protocol in output dictionary |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Dictionary of storage options with non-None values |
Example
Source code in src/fsspeckit/storage_options/base.py
fsspeckit.storage_options.BaseStorageOptions.to_filesystem
¶
to_filesystem(
use_listings_cache: bool = True,
skip_instance_cache: bool = False,
**kwargs: Any,
) -> AbstractFileSystem
Create fsspec filesystem instance from options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
use_listings_cache
|
bool
|
Whether to enable the fsspec listings cache. |
True
|
skip_instance_cache
|
bool
|
Whether to skip fsspec's instance cache. |
False
|
**kwargs
|
Any
|
Additional arguments forwarded to |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
AbstractFileSystem |
AbstractFileSystem
|
Configured filesystem instance |
Example
Source code in src/fsspeckit/storage_options/base.py
fsspeckit.storage_options.BaseStorageOptions.to_yaml
¶
Save storage options to YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path where to save configuration |
required |
fs
|
AbstractFileSystem
|
Filesystem to use for writing |
None
|
Source code in src/fsspeckit/storage_options/base.py
fsspeckit.storage_options.BaseStorageOptions.update
¶
update(**kwargs: Any) -> BaseStorageOptions
Update storage options with new values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
New option values to set |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
BaseStorageOptions |
BaseStorageOptions
|
Updated instance |
Example
Source code in src/fsspeckit/storage_options/base.py
fsspeckit.storage_options.StorageOptions
¶
Bases: Struct
High-level storage options container and factory.
Provides a unified interface for creating and managing storage options for different protocols.
Attributes:
| Name | Type | Description |
|---|---|---|
storage_options |
BaseStorageOptions
|
Underlying storage options instance |
Example
Functions¶
fsspeckit.storage_options.StorageOptions.create
classmethod
¶
create(**data: Any) -> StorageOptions
Create storage options from arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**data
|
Any
|
Either: - protocol and configuration options - storage_options=pre-configured instance |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
StorageOptions |
StorageOptions
|
Configured storage options instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If protocol missing or invalid |
Example
Direct protocol config¶
options = StorageOptions.create( ... protocol="s3", ... region="us-east-1" ... )
Source code in src/fsspeckit/storage_options/core.py
fsspeckit.storage_options.StorageOptions.from_env
classmethod
¶
from_env(protocol: str) -> StorageOptions
Create storage options from environment variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
protocol
|
str
|
Storage protocol to configure |
required |
Returns:
| Name | Type | Description |
|---|---|---|
StorageOptions |
StorageOptions
|
Environment-configured options |
Example
Load AWS config from environment¶
options = StorageOptions.from_env("s3")
Source code in src/fsspeckit/storage_options/core.py
fsspeckit.storage_options.StorageOptions.from_yaml
classmethod
¶
from_yaml(
path: str, fs: AbstractFileSystem = None
) -> StorageOptions
Create storage options from YAML configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to YAML configuration file |
required |
fs
|
AbstractFileSystem
|
Filesystem for reading configuration |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
StorageOptions |
StorageOptions
|
Configured storage options |
Example
Load from config file¶
options = StorageOptions.from_yaml("storage.yml") print(options.storage_options.protocol) 's3'
Source code in src/fsspeckit/storage_options/core.py
fsspeckit.storage_options.StorageOptions.to_dict
¶
Convert storage options to dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
with_protocol
|
bool
|
Whether to include protocol in output |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Storage options as dictionary |
Example
options = StorageOptions.create( ... protocol="s3", ... region="us-east-1" ... ) print(options.to_dict())
Source code in src/fsspeckit/storage_options/core.py
fsspeckit.storage_options.StorageOptions.to_filesystem
¶
to_filesystem(
use_listings_cache: bool = True,
skip_instance_cache: bool = False,
**kwargs: Any,
) -> AbstractFileSystem
Create fsspec filesystem instance.
Returns:
| Name | Type | Description |
|---|---|---|
AbstractFileSystem |
AbstractFileSystem
|
Configured filesystem instance |
Example
options = StorageOptions.create(protocol="file") fs = options.to_filesystem() files = fs.ls("/data")
Source code in src/fsspeckit/storage_options/core.py
fsspeckit.storage_options.StorageOptions.to_object_store_kwargs
¶
Get options formatted for object store clients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
with_conditional_put
|
bool
|
Add etag-based conditional put support |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Object store configuration dictionary |
Example
options = StorageOptions.create(protocol="s3") kwargs = options.to_object_store_kwargs()
store = ObjectStore(**kwargs)¶
Source code in src/fsspeckit/storage_options/core.py
fsspeckit.storage_options.LocalStorageOptions
¶
Bases: BaseStorageOptions
Local filesystem configuration options.
Provides basic configuration for local file access. While this class is simple, it maintains consistency with other storage options and enables transparent switching between local and remote storage.
Attributes:
| Name | Type | Description |
|---|---|---|
protocol |
str
|
Always "file" for local filesystem |
auto_mkdir |
bool
|
Create directories automatically |
mode |
int
|
Default file creation mode (unix-style) |
Example
Functions¶
fsspeckit.storage_options.LocalStorageOptions.to_fsspec_kwargs
¶
Convert options to fsspec filesystem arguments.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Arguments suitable for LocalFileSystem |
Example
Source code in src/fsspeckit/storage_options/core.py
fsspeckit.storage_options.AwsStorageOptions
¶
Bases: BaseStorageOptions
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 - Anonymous access for public buckets
Attributes:
| Name | Type | Description |
|---|---|---|
protocol |
str
|
Always "s3" for S3 storage |
access_key_id |
str
|
AWS access key ID |
secret_access_key |
str
|
AWS secret access key |
session_token |
str
|
AWS session token |
endpoint_url |
str
|
Custom S3 endpoint URL |
region |
str
|
AWS region name |
allow_invalid_certificates |
bool
|
Skip SSL certificate validation |
allow_http |
bool
|
Allow unencrypted HTTP connections |
anonymous |
bool
|
Use anonymous (unsigned) S3 access |
Example
Basic credentials¶
options = AwsStorageOptions( ... access_key_id="AKIAXXXXXXXX", ... secret_access_key="SECRETKEY", ... region="us-east-1" ... )
Profile-based auth¶
options = AwsStorageOptions.create(profile="dev")
S3-compatible service (MinIO)¶
options = AwsStorageOptions( ... endpoint_url="http://localhost:9000", ... access_key_id="minioadmin", ... secret_access_key="minioadmin", ... allow_http=True ... )
Anonymous access for public buckets¶
options = AwsStorageOptions(anonymous=True)
Functions¶
fsspeckit.storage_options.AwsStorageOptions.create
classmethod
¶
create(
protocol: str = "s3",
access_key_id: str | None = None,
secret_access_key: str | None = None,
session_token: str | None = None,
endpoint_url: str | None = None,
region: str | None = None,
allow_invalid_certificates: bool | str | None = None,
allow_invalid_certs: bool | str | None = None,
allow_http: bool | str | None = None,
anonymous: bool | str | None = None,
key: str | None = None,
secret: str | None = None,
token: str | None = None,
profile: str | None = None,
) -> AwsStorageOptions
Creates an AwsStorageOptions instance, handling aliases and profile loading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
protocol
|
str
|
Storage protocol, defaults to "s3". |
's3'
|
access_key_id
|
str | None
|
AWS access key ID. |
None
|
secret_access_key
|
str | None
|
AWS secret access key. |
None
|
session_token
|
str | None
|
AWS session token. |
None
|
endpoint_url
|
str | None
|
Custom S3 endpoint URL. |
None
|
region
|
str | None
|
AWS region name. |
None
|
allow_invalid_certificates
|
bool | str | None
|
Skip SSL certificate validation. |
None
|
allow_http
|
bool | str | None
|
Allow unencrypted HTTP connections. |
None
|
anonymous
|
bool | str | None
|
Use anonymous (unsigned) S3 access. |
None
|
key
|
str | None
|
Alias for access_key_id. |
None
|
secret
|
str | None
|
Alias for secret_access_key. |
None
|
token
|
str | None
|
Alias for session_token. |
None
|
profile
|
str | None
|
AWS credentials profile name to load credentials from. |
None
|
Returns:
| Type | Description |
|---|---|
AwsStorageOptions
|
An initialized AwsStorageOptions instance. |
Source code in src/fsspeckit/storage_options/cloud.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | |
fsspeckit.storage_options.AwsStorageOptions.from_aws_credentials
classmethod
¶
from_aws_credentials(
profile: str,
allow_invalid_certificates: bool | str | None = None,
allow_invalid_certs: bool | str | None = None,
allow_http: bool | str | None = None,
anonymous: bool | str | None = None,
) -> AwsStorageOptions
Create storage options from AWS credentials file.
Loads credentials from ~/.aws/credentials and ~/.aws/config files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
str
|
AWS credentials profile name |
required |
allow_invalid_certificates
|
bool | str | None
|
Skip SSL certificate validation |
None
|
allow_invalid_certs
|
bool | str | None
|
Skip SSL certificate validation (deprecated, use allow_invalid_certificates) |
None
|
allow_http
|
bool | str | None
|
Allow unencrypted HTTP connections |
None
|
anonymous
|
bool | str | None
|
Use anonymous (unsigned) S3 access |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
AwsStorageOptions |
AwsStorageOptions
|
Configured storage options |
Raises:
| Type | Description |
|---|---|
ValueError
|
If profile not found |
FileNotFoundError
|
If credentials files missing |
Example
Load developer profile¶
options = AwsStorageOptions.from_aws_credentials( ... profile="dev", ... allow_http=True # For local testing ... )
Source code in src/fsspeckit/storage_options/cloud.py
fsspeckit.storage_options.AwsStorageOptions.from_env
classmethod
¶
from_env() -> AwsStorageOptions
Create storage options from environment variables.
1 2 3 4 5 6 7 8 9 | |
Returns:
| Name | Type | Description |
|---|---|---|
AwsStorageOptions |
AwsStorageOptions
|
Configured storage options |
1 2 3 4 5 6 7 | |
Source code in src/fsspeckit/storage_options/cloud.py
fsspeckit.storage_options.AwsStorageOptions.to_env
¶
Export options to environment variables.
Sets standard AWS environment variables.
Example
Source code in src/fsspeckit/storage_options/cloud.py
fsspeckit.storage_options.AwsStorageOptions.to_fsspec_kwargs
¶
Convert options to fsspec filesystem arguments. Args: conditional_put: Enable etag-based conditional puts use_listings_cache: Enable fsspec listings cache skip_instance_cache: Skip fsspec instance cache
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Arguments suitable for fsspec S3FileSystem |
Example
Source code in src/fsspeckit/storage_options/cloud.py
fsspeckit.storage_options.AwsStorageOptions.to_object_store_kwargs
¶
to_object_store_kwargs(
*,
with_conditional_put: bool | str = False,
conditional_put: str | None = None,
) -> dict
Convert options to object store arguments.
Source code in src/fsspeckit/storage_options/cloud.py
fsspeckit.storage_options.GcsStorageOptions
¶
Bases: BaseStorageOptions
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:
| Name | Type | Description |
|---|---|---|
protocol |
str
|
Storage protocol ("gs" or "gcs") |
token |
str
|
Path to service account JSON file |
project |
str
|
Google Cloud project ID |
access_token |
str
|
OAuth2 access token |
endpoint_url |
str
|
Custom storage endpoint |
timeout |
int
|
Request timeout in seconds |
Example
Service account auth¶
options = GcsStorageOptions( ... protocol="gs", ... token="path/to/service-account.json", ... project="my-project-123" ... )
Application default credentials¶
options = GcsStorageOptions( ... protocol="gcs", ... project="my-project-123" ... )
Custom endpoint (e.g., test server)¶
options = GcsStorageOptions( ... protocol="gs", ... endpoint_url="http://localhost:4443", ... token="test-token.json" ... )
Functions¶
fsspeckit.storage_options.GcsStorageOptions.from_env
classmethod
¶
from_env() -> GcsStorageOptions
Create storage options from environment variables.
Reads standard GCP environment variables: - GOOGLE_CLOUD_PROJECT: Project ID - GOOGLE_APPLICATION_CREDENTIALS: Service account file path - STORAGE_EMULATOR_HOST: Custom endpoint (for testing) - GCS_OAUTH_TOKEN: OAuth2 access token
Returns:
| Name | Type | Description |
|---|---|---|
GcsStorageOptions |
GcsStorageOptions
|
Configured storage options |
Example
With environment variables set:¶
options = GcsStorageOptions.from_env() print(options.project) # From GOOGLE_CLOUD_PROJECT 'my-project-123'
Source code in src/fsspeckit/storage_options/cloud.py
fsspeckit.storage_options.GcsStorageOptions.to_env
¶
Export options to environment variables.
Sets standard GCP environment variables.
Example
options = GcsStorageOptions( ... protocol="gs", ... project="my-project", ... token="service-account.json" ... ) options.to_env() print(os.getenv("GOOGLE_CLOUD_PROJECT")) 'my-project'
Source code in src/fsspeckit/storage_options/cloud.py
fsspeckit.storage_options.GcsStorageOptions.to_fsspec_kwargs
¶
Convert options to fsspec filesystem arguments.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Arguments suitable for GCSFileSystem |
Example
options = GcsStorageOptions( ... protocol="gs", ... token="service-account.json", ... project="my-project" ... ) kwargs = options.to_fsspec_kwargs() fs = filesystem("gcs", **kwargs)
Source code in src/fsspeckit/storage_options/cloud.py
fsspeckit.storage_options.AzureStorageOptions
¶
Bases: BaseStorageOptions
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:
| Name | Type | Description |
|---|---|---|
protocol |
str
|
Storage protocol ("az", "abfs", or "adl") |
account_name |
str
|
Storage account name |
account_key |
str
|
Storage account access key |
connection_string |
str
|
Full connection string |
tenant_id |
str
|
Azure AD tenant ID |
client_id |
str
|
Service principal client ID |
client_secret |
str
|
Service principal client secret |
sas_token |
str
|
SAS token for limited access |
Example
Blob Storage with account key¶
options = AzureStorageOptions( ... protocol="az", ... account_name="mystorageacct", ... account_key="key123..." ... )
Data Lake with service principal¶
options = AzureStorageOptions( ... protocol="abfs", ... account_name="mydatalake", ... tenant_id="tenant123", ... client_id="client123", ... client_secret="secret123" ... )
Simple connection string auth¶
options = AzureStorageOptions( ... protocol="az", ... connection_string="DefaultEndpoints..." ... )
Functions¶
fsspeckit.storage_options.AzureStorageOptions.from_env
classmethod
¶
from_env() -> AzureStorageOptions
Create storage options from environment variables.
Reads standard Azure environment variables: - 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:
| Name | Type | Description |
|---|---|---|
AzureStorageOptions |
AzureStorageOptions
|
Configured storage options |
Example
With environment variables set:¶
options = AzureStorageOptions.from_env() print(options.account_name) # From AZURE_STORAGE_ACCOUNT_NAME 'mystorageacct'
Source code in src/fsspeckit/storage_options/cloud.py
fsspeckit.storage_options.AzureStorageOptions.to_env
¶
Export options to environment variables.
Sets standard Azure environment variables.
Example
options = AzureStorageOptions( ... protocol="az", ... account_name="mystorageacct", ... account_key="key123" ... ) options.to_env() print(os.getenv("AZURE_STORAGE_ACCOUNT_NAME")) 'mystorageacct'
Source code in src/fsspeckit/storage_options/cloud.py
fsspeckit.storage_options.AzureStorageOptions.to_fsspec_kwargs
¶
Convert options to Azure-compatible fsspec kwargs.
Source code in src/fsspeckit/storage_options/cloud.py
fsspeckit.storage_options.GitHubStorageOptions
¶
Bases: BaseStorageOptions
GitHub repository storage configuration options.
Provides access to files in GitHub repositories with support for: - Public and private repositories - Branch/tag/commit selection - Token-based authentication - Custom GitHub Enterprise instances
Attributes:
| Name | Type | Description |
|---|---|---|
protocol |
str
|
Always "github" for GitHub storage |
org |
str
|
Organization or user name |
repo |
str
|
Repository name |
ref |
str
|
Git reference (branch, tag, or commit SHA) |
token |
str
|
GitHub personal access token |
api_url |
str
|
Custom GitHub API URL for enterprise instances |
Example
Functions¶
fsspeckit.storage_options.GitHubStorageOptions.from_env
classmethod
¶
from_env() -> GitHubStorageOptions
Create storage options from environment variables.
Reads standard GitHub environment variables: - GITHUB_ORG: Organization or user name - GITHUB_REPO: Repository name - GITHUB_REF: Git reference - GITHUB_TOKEN: Personal access token - GITHUB_API_URL: Custom API URL
Returns:
| Name | Type | Description |
|---|---|---|
GitHubStorageOptions |
GitHubStorageOptions
|
Configured storage options |
Example
Source code in src/fsspeckit/storage_options/git.py
fsspeckit.storage_options.GitHubStorageOptions.to_env
¶
Export options to environment variables.
Sets standard GitHub environment variables.
Example
Source code in src/fsspeckit/storage_options/git.py
fsspeckit.storage_options.GitHubStorageOptions.to_fsspec_kwargs
¶
Convert options to fsspec filesystem arguments.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Arguments suitable for GitHubFileSystem |
Example
options = GitHubStorageOptions( ... org="microsoft", ... repo="vscode", ... token="ghp_xxxx" ... ) kwargs = options.to_fsspec_kwargs() fs = filesystem("github", **kwargs)
Source code in src/fsspeckit/storage_options/git.py
fsspeckit.storage_options.GitLabStorageOptions
¶
Bases: BaseStorageOptions
GitLab repository storage configuration options.
Provides access to files in GitLab repositories with support for: - Public and private repositories - Self-hosted GitLab instances - Project ID or name-based access - Branch/tag/commit selection - Token-based authentication
Attributes:
| Name | Type | Description |
|---|---|---|
protocol |
str
|
Always "gitlab" for GitLab storage |
base_url |
str
|
GitLab instance URL, defaults to gitlab.com |
project_id |
Union[str, int]
|
Project ID number |
project_name |
str
|
Project name/path |
ref |
str
|
Git reference (branch, tag, or commit SHA) |
token |
str
|
GitLab personal access token |
api_version |
str
|
API version to use |
timeout |
float
|
Request timeout in seconds (must be positive, max 3600) |
max_pages |
int
|
Maximum number of pages to fetch (default 1000, max 10000) |
Example
Functions¶
fsspeckit.storage_options.GitLabStorageOptions.__post_init__
¶
Validate GitLab configuration after initialization.
Ensures either project_id or project_name is provided and validates timeout and max_pages parameters.
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither project_id nor project_name is provided, or if timeout/max_pages values are invalid |
Source code in src/fsspeckit/storage_options/git.py
fsspeckit.storage_options.GitLabStorageOptions.from_env
classmethod
¶
from_env() -> GitLabStorageOptions
Create storage options from environment variables.
Reads standard GitLab environment variables: - GITLAB_URL: Instance URL - GITLAB_PROJECT_ID: Project ID - GITLAB_PROJECT_NAME: Project name/path - GITLAB_REF: Git reference - GITLAB_TOKEN: Personal access token - GITLAB_API_VERSION: API version - GITLAB_TIMEOUT: Request timeout in seconds - GITLAB_MAX_PAGES: Maximum number of pages to fetch
Returns:
| Name | Type | Description |
|---|---|---|
GitLabStorageOptions |
GitLabStorageOptions
|
Configured storage options |
Example
Source code in src/fsspeckit/storage_options/git.py
fsspeckit.storage_options.GitLabStorageOptions.to_env
¶
Export options to environment variables.
Sets standard GitLab environment variables.
Example
Source code in src/fsspeckit/storage_options/git.py
fsspeckit.storage_options.GitLabStorageOptions.to_fsspec_kwargs
¶
Convert options to fsspec filesystem arguments.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Arguments suitable for GitLabFileSystem |
Example
Source code in src/fsspeckit/storage_options/git.py
Functions¶
fsspeckit.storage_options.from_dict
¶
from_dict(
protocol: str, storage_options: dict
) -> BaseStorageOptions
Create appropriate storage options instance from dictionary.
Factory function that creates the correct storage options class based on protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
protocol
|
str
|
Storage protocol identifier (e.g., "s3", "gs", "file") |
required |
storage_options
|
dict
|
Dictionary of configuration options |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BaseStorageOptions |
BaseStorageOptions
|
Appropriate storage options instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If protocol is not supported |
Example
Source code in src/fsspeckit/storage_options/core.py
fsspeckit.storage_options.from_env
¶
from_env(protocol: str) -> BaseStorageOptions
Create storage options from environment variables.
Factory function that creates and configures storage options from protocol-specific environment variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
protocol
|
str
|
Storage protocol identifier (e.g., "s3", "github") |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BaseStorageOptions |
BaseStorageOptions
|
Configured storage options instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If protocol is not supported |
Example
Source code in src/fsspeckit/storage_options/core.py
fsspeckit.storage_options.merge_storage_options
¶
merge_storage_options(
*options: BaseStorageOptions | dict | None,
overwrite: bool = True,
) -> BaseStorageOptions
Merge multiple storage options into a single configuration.
Combines options from multiple sources with control over precedence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*options
|
BaseStorageOptions | dict | None
|
Storage options to merge. Can be: - BaseStorageOptions instances - Dictionaries of options - None values (ignored) |
()
|
overwrite
|
bool
|
Whether later options override earlier ones |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
BaseStorageOptions |
BaseStorageOptions
|
Combined storage options |
Example
Source code in src/fsspeckit/storage_options/core.py
fsspeckit.storage_options.infer_protocol_from_uri
¶
Infer the storage protocol from a URI string.
Analyzes the URI to determine the appropriate storage protocol based on the scheme or path format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
URI or path string to analyze. Examples: - "s3://bucket/path" - "gs://bucket/path" - "github://org/repo" - "/local/path" |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Inferred protocol identifier |
Example
Source code in src/fsspeckit/storage_options/core.py
fsspeckit.storage_options.storage_options_from_uri
¶
storage_options_from_uri(uri: str) -> BaseStorageOptions
Create storage options instance from a URI string.
Infers the protocol and extracts relevant configuration from the URI to create appropriate storage options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
URI string containing protocol and optional configuration. Examples: - "s3://bucket/path" - "gs://project/bucket/path" - "github://org/repo" |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BaseStorageOptions |
BaseStorageOptions
|
Configured storage options instance |