Skip to main content

Unified storage interface.

Project description

fw-storage

Unified file storage interface tuned for simple filtering, memory-efficiency and performance to support processing large datasets in Flywheel imports and exports.

Supported storage backends:

  • fs:// - Local file-system
  • s3:// - Amazon S3
  • gs:// - Google Cloud Storage
  • az:// - Azure Blob Storage

Installation

Add as a poetry dependency to your project:

poetry add fw-storage

The local file-system storage backend has no extra package dependencies. To use any other backend, though, fw-storage needs to be installed with extras. For example, in order to access S3:

poetry add fw-storage --extras s3

Alternatively, install with all extras to get everything:

poetry add fw-storage --extras all

Usage

from fw_storage import create_storage_client

# instantiate storage with URL
fs = create_storage_client("fs:///tmp")

# set objects from bytes, filepaths or open files
fs.set("test/file1.dat", b"content")
fs.set("test/file2.dat", "/tmp/test/file1.dat")
fs.set("test/file3.dat", open("/tmp/test/file2.dat"))

# list objects, filtering with expressions
files = list(fs.ls("test", include=["size<1kB"], exclude=["path!~file3"]))
len(files) == 2

# get object info with path, size, created and modified
info = fs.stat("test/file1.dat")
info.size == 7

# read object contents
file = fs.get("test/file1.dat")
file.read() == b"content"

# remove one or more objects
fs.rm("test", recurse=True)

Configuration

Credentials for cloud storage providers are loaded using the vendor SDKs to support every standard config file location and environment variable recommended by the provider:

Storage Config docs
s3:// https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
gs:// https://google-auth.readthedocs.io/en/latest/reference/google.auth.html
az:// https://docs.microsoft.com/en-us/python/api/azure-identity/azure.identity.defaultazurecredential

In addition, az:// can be configured with the envvar AZ_ACCESS_KEY.

Development

Install the project using poetry and enable pre-commit:

poetry install -E all
pre-commit install

License

MIT

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fw_storage-2.1.0-py3-none-any.whl (37.7 kB view details)

Uploaded Python 3

File details

Details for the file fw_storage-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: fw_storage-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 37.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.7 Linux/5.4.202+

File hashes

Hashes for fw_storage-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14d18c92736b599a849ba0ff0508221935d87fcbe03dab4e821ccbcf966fc2af
MD5 cba51e89d09a1613cb66863c770541a8
BLAKE2b-256 153789d4b11574674550a3600984ea366f259841013257daa1ec6a7735dc32c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page