Skip to main content

swiftspec

import fsspec

with fsspec.open("swift://server/account/container/object.txt", "r") as f:
    print(f.read())

Authentication

swiftspec uses the environment variables OS_STORAGE_URL and OS_AUTH_TOKEN for authentication if available. To create these variables, you can use the swift auth command from the python-swiftclient.

fault tolerance / automatic retry

Sometimes reading or writing from / to a swift storage might fail occasionally. If many objects are accessed, occasional failures can be extremely annoying and could be fixed relatively easily by retrying the request. Fortunately the aiohttp_retry package can help out in these situations. aiohttp_retry provides a wrapper around an aiohttp Client, which will automatically retry requests based on some user-provided rules. You can inject this client into the swiftspec filesystem using the get_client argument. First you'll have to define an async get_client function, which configures the RetryClient according to your preferences, e.g.:

async def get_client(**kwargs):
    import aiohttp
    import aiohttp_retry
    retry_options = aiohttp_retry.ExponentialRetry(
            attempts=3,
            exceptions={OSError, aiohttp.ServerDisconnectedError})
    retry_client = aiohttp_retry.RetryClient(raise_for_status=False, retry_options=retry_options)
    return retry_client

afterwards, you can use this function like:

with fsspec.open("swift://server/account/container/object.txt", "r", get_client=get_client) as f:
    print(f.read())

or:

import xarray as xr
ds = xr.Dataset(...)
ds.to_zarr("swift://server/account/container/object.zarr", storage_options={"get_client": get_client})

Develop

Code Formatting

swiftspec uses Black to ensure a consistent code format throughout the project. Run black . from the root of the swiftspec repository to auto-format your code. Additionally, many editors have plugins that will apply black as you edit files.

Optionally, you may wish to setup pre-commit hooks to automatically run black when you make a git commit. Run pre-commit install --install-hooks from the root of the swiftspec repository to setup pre-commit hooks. black will now be run before you commit, reformatting any changed files. You can format without committing via pre-commit run or skip these checks with git commit --no-verify.

Metadata

Release files for swiftspec 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swiftspec 0.0.4
File Size Uploaded
swiftspec-0.0.4.tar.gz 27.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swiftspec 0.0.4
File Interpreter ABI Platform
swiftspec-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 34.6 kB

Release files / swiftspec-0.0.4.tar.gz

Download URL swiftspec-0.0.4.tar.gz
Size 27.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b7ab0b9b2c5d754b45850e7d75a47bea36451c135adc6411b6dd4c2686a95349
BLAKE2b-256 checksum
How to use checksums
109a9f1a705fa60744fbe22cfadd4817c3d391d746fcaddcb6ed279a78a4cd82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release files / swiftspec-0.0.4-py3-none-any.whl

Download URL swiftspec-0.0.4-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c89888fd1068a13d667863102ce9eab5b5c7e06391f557bc6cd7c8be3d2b6b1
BLAKE2b-256 checksum
How to use checksums
4ce27c432ca5bd7dc0035ee922e94645ca3a5593e1909842556b6a4c8454bcc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page