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.0.9.tar.gz
.
File metadata
- Download URL: object_store_python-0.0.9.tar.gz
- Upload date:
- Size: 32.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.14.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d41ece27230524ce33526ee9afb319a32833e1f0762bb0301972429638492bb |
|
MD5 | 9bf94960e4ba4bb12988666eddc402a9 |
|
BLAKE2b-256 | 6b952b4523a1dbd780d8663260d91ec933d702c53250bfef20f6b79726897b83 |
File details
Details for the file object_store_python-0.0.9-cp38-abi3-win_amd64.whl
.
File metadata
- Download URL: object_store_python-0.0.9-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.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ed3b90352cef4175a21600ee919990ff07e9102e17dcee7b91a9bb355ede0da |
|
MD5 | a455557fda40ebd8571d12243d10119b |
|
BLAKE2b-256 | e06587d5b4ea92c96b499f4e7f0e06627ab248cc9ea26da7d3b73d81d4bfd437 |
File details
Details for the file object_store_python-0.0.9-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: object_store_python-0.0.9-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.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 924cd9a175599dae5894ba6e44a119f2210887412006dbf1111227f8ea955bf7 |
|
MD5 | 3a302ee44508de211be231f58eabf2a6 |
|
BLAKE2b-256 | c1b7c469c1a1cca1e61f4b44839f741b71f80051bb369b0a969c07c0220fbc09 |
File details
Details for the file object_store_python-0.0.9-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: object_store_python-0.0.9-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.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b62816f22aabfa8d47ab3ba5ee3f34af3940c6ecb349dbbdaed8db6fe7a3d259 |
|
MD5 | 2169f5c464f6c56cb494f31a460cca43 |
|
BLAKE2b-256 | 6b68d9d0dfac9673f4d3b9f3b8361953c472fafb1e27c3d3b22b36ce020809bb |
File details
Details for the file object_store_python-0.0.9-cp38-abi3-macosx_11_0_arm64.whl
.
File metadata
- Download URL: object_store_python-0.0.9-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.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2ef0ded645aabe237e201f21c9e66bb9008c2627513c3052442047ce3bd2bc4 |
|
MD5 | de185807a3e937577862e3e511be12b5 |
|
BLAKE2b-256 | a77576fd1cca224244b61efde11b73b360d1603cd92e4c363ac0a67d1b912ac3 |
File details
Details for the file object_store_python-0.0.9-cp38-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: object_store_python-0.0.9-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.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7152911cf57ab57b8ef3b266a2e742fcc73d474bf84c7ef762685add236b503f |
|
MD5 | 8bb265e7e1af3a7673938aa57bfd8d2b |
|
BLAKE2b-256 | a674c98a5a53b97d7cbd472b065b6037e67e42a7cbb34a1cb08b6b50720ce741 |
File details
Details for the file object_store_python-0.0.9-cp38-abi3-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: object_store_python-0.0.9-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.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | faab6e7c8513c3eb1e2e888f00f88a6170b6e21a9eeb736ffa28a94b2f80ebc8 |
|
MD5 | f49cb92df6bbbf378fb265bc7c6c1be9 |
|
BLAKE2b-256 | 3a68cdcbb85c67d3ea1b6bc7d17ac3e828010f2753d4530132f19e4097ef27b9 |