A generic object store interface for uniformly interacting with AWS S3, Google Cloud Storage, Azure Storage and local files.
Project description
object-store-python
Python bindings and integrations for the excellent object_store
crate.
The main idea is to provide a common interface to various storage backends including the
objects stores from most major cloud providers. The APIs are very focussed and taylored
towards modern cloud native applications by hiding away many features (and complexities)
encountered in full fledges file systems.
Among the included backend are:
- Amazon S3 and S3 compliant APIs
- Google Cloud Storage Buckets
- Azure Blob Gen1 and Gen2 accounts (including ADLS Gen2)
- local storage
- in-memory store
Installation
The object-store-python
package is available on PyPI and can be installed via
poetry add object-store-python
or using pip
pip install object-store-python
Usage
The main ObjectStore
API mirrors the native object_store
implementation, with some slight adjustments for ease of use in python programs.
ObjectStore
api
from object_store import ObjectStore, ObjectMeta
# we use an in-memory store for demonstration purposes.
# data will not be persisted and is not shared across store instances
store = ObjectStore("memory://")
store.put("data", b"some data")
data = store.get("data")
assert data == b"some data"
blobs = store.list()
meta: ObjectMeta = store.head("data")
range = store.get_range("data", start=0, length=4)
assert range == b"some"
store.copy("data", "copied")
copied = store.get("copied")
assert copied == data
Configuration
As much as possible we aim to make access to various storage backends dependent only on runtime configuration.
from object_store import ObjectStore
storage_options = {
"azure_storage_account_name": "<my-account-name>",
"azure_client_id": "<my-client-id>",
"azure_client_secret": "<my-client-secret>",
"azure_tenant_id": "<my-tenant-id>"
}
store = ObjectStore("az://<container-name>", storage_options)
We can provide the same configuration via the environment.
import os
from object_store import ObjectStore
os.environ["AZURE_STORAGE_ACCOUNT_NAME"] = "<my-account-name>"
os.environ["AZURE_CLIENT_ID"] = "<my-client-id>"
os.environ["AZURE_CLIENT_SECRET"] = "<my-client-secret>"
os.environ["AZURE_TENANT_ID"] = "<my-tenant-id>"
store = ObjectStore("az://<container-name>")
with pyarrow
from pathlib import Path
import numpy as np
import pyarrow as pa
import pyarrow.fs as fs
import pyarrow.dataset as ds
import pyarrow.parquet as pq
from object_store import ArrowFileSystemHandler
table = pa.table({"a": range(10), "b": np.random.randn(10), "c": [1, 2] * 5})
base = Path.cwd()
store = fs.PyFileSystem(ArrowFileSystemHandler(str(base.absolute())))
pq.write_table(table.slice(0, 5), "data/data1.parquet", filesystem=store)
pq.write_table(table.slice(5, 10), "data/data2.parquet", filesystem=store)
dataset = ds.dataset("data", format="parquet", filesystem=store)
Development
Prerequisites
Running tests
If you do not have just
installed and do not wish to install it,
have a look at the justfile
to see the raw commands.
To set up the development environment, and install a dev version of the native package just run:
just init
This will also configure pre-commit
hooks in the repository.
To run the rust as well as python tests:
just test
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 Distribution
Built Distributions
File details
Details for the file object_store_python-0.1.0.tar.gz
.
File metadata
- Download URL: object_store_python-0.1.0.tar.gz
- Upload date:
- Size: 32.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.14.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b8d5aaa479747e7be5841cfd5ec659e308b37244e900ea7ab653555b9891e86 |
|
MD5 | 7174ddf6c3f2942a7f38ed105dd792fd |
|
BLAKE2b-256 | 0a9dee27b4b3fdbe03e5ea892d7d7cd026104d98e41dde448100155acfa960c1 |
File details
Details for the file object_store_python-0.1.0-cp38-abi3-win_amd64.whl
.
File metadata
- Download URL: object_store_python-0.1.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 4.3 MB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.14.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7861e6cc4c8d3678d97d4bbd7f31a86fc5a4b000edf813c51c52d77df6f781e1 |
|
MD5 | 7704a716641a00690539a751b8338e2f |
|
BLAKE2b-256 | 1ee198faf7397510e5238a57d5d8921810dda89486023812cab676c2e71d7dc2 |
File details
Details for the file object_store_python-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: object_store_python-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.7 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.14.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d70074a015b7b978444b72efbbff0060879bc02e33eebe733c8b4def167d4c28 |
|
MD5 | 4908e6bad95a7dc6f7a530c5baf99f51 |
|
BLAKE2b-256 | 388fc9f2ec4cfced8114318f6321315d37d92dbeaa3e15beca651a3e3b6c67a1 |
File details
Details for the file object_store_python-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: object_store_python-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.2 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.14.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94d5f71980fe465a96f820b682cfe8bb32d038757964555385c48db392f65113 |
|
MD5 | 2b20ac365b4a8ce945402d587fdf21af |
|
BLAKE2b-256 | 0c21c45e9456b6fcf64d5110438fb88f1e7db9dbd6ffc5ec060eb846a0c52e08 |
File details
Details for the file object_store_python-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
.
File metadata
- Download URL: object_store_python-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.1 MB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.14.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77fc11b3c2bb1eeac24694308e2585a416faeb74a1f2ed72ed48b2140c91813e |
|
MD5 | ffb1fa037444691b1c24d76a88e3b2ca |
|
BLAKE2b-256 | 913e1adab4f8c40fdce8bd9f4d014bf70ac38398c2faec1a21e0ba71e537780b |
File details
Details for the file object_store_python-0.1.0-cp38-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: object_store_python-0.1.0-cp38-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 8.4 MB
- Tags: CPython 3.8+, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.14.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e1d1690ed529e53b20fd237c735026568d6d82f5535b56c65f7376d425e4c7d |
|
MD5 | ee100a9171613ff348e6904956f866b7 |
|
BLAKE2b-256 | 06eb902f06e27a25cdcbcb487fe983a56a438e9c380402b7339dad317c8643d6 |
File details
Details for the file object_store_python-0.1.0-cp38-abi3-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: object_store_python-0.1.0-cp38-abi3-macosx_10_7_x86_64.whl
- Upload date:
- Size: 4.4 MB
- Tags: CPython 3.8+, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.14.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0235bc9607a4003cfe0e4a1807912cbcda017b74442709eea390bf563de7fd45 |
|
MD5 | c6f8f259b766ee2e4d82e38d684b0de1 |
|
BLAKE2b-256 | 459d26690f1048eba3071b7e2fa75168493ab6dac75e045fe2bebb5e7cf08d12 |