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-systemgs://
- Google Cloud Storage (pip install fw-storage[gs]
)s3://
- Amazon S3 (pip install fw-storage[s3]
)
Installation
Add as a poetry
dependency to your project:
poetry add fw-storage
Usage
from fw_storage import get_storage
# instantiate storage with URL
fs = get_storage("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)
Development
Install the project using poetry
and enable pre-commit
:
poetry install
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
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
fw_storage-0.2.0-py3-none-any.whl
(14.8 kB
view hashes)
Close
Hashes for fw_storage-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff8eeaf9f96ec7be35c842e003f51ccbac30f28664f8a2bc845dcea429244dec |
|
MD5 | 2df51f7547684b004016a6cd4afce203 |
|
BLAKE2b-256 | fe377da448276c7d938fba11308821421a3f171c11acb4c9009738c4a7797027 |