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-systems3://
- Amazon S3gs://
- Google Cloud Storageaz://
- 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:
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
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
Built Distribution
Hashes for fw_storage-2.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26d7ef9ec190d36b3d0801a617516efdd0522edc6911f5b8eda62d6399dc5566 |
|
MD5 | adbb6ea6d3ee31f11e220d5f7105a845 |
|
BLAKE2b-256 | 8acfb2b9df2029c41dff38d9ff4a08779678e6dec9126d3369304d8025b6d2d4 |