Skip to main content

A generic object store interface for uniformly interacting with AWS S3, Google Cloud Storage, Azure Storage and local files.

Project description

object-store-python

CI code style: black PyPI - Downloads

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


Download files

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

Source Distribution

object_store_python-0.0.8.tar.gz (32.0 kB view details)

Uploaded Source

Built Distributions

object_store_python-0.0.8-cp38-abi3-win_amd64.whl (4.3 MB view details)

Uploaded CPython 3.8+ Windows x86-64

object_store_python-0.0.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64

object_store_python-0.0.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.2 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

object_store_python-0.0.8-cp38-abi3-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

object_store_python-0.0.8-cp38-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (8.4 MB view details)

Uploaded CPython 3.8+ macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

object_store_python-0.0.8-cp38-abi3-macosx_10_7_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.8+ macOS 10.7+ x86-64

File details

Details for the file object_store_python-0.0.8.tar.gz.

File metadata

File hashes

Hashes for object_store_python-0.0.8.tar.gz
Algorithm Hash digest
SHA256 82707385d47ae77302dc6cdf3e1af0b5358d6ac0898bd37f341c10113ebff4f5
MD5 918673155071422cd055a506ade8f575
BLAKE2b-256 a5c2be51d84dc054388549ef46291bda3ed03b3ac88f78dd8251f69b3e120aac

See more details on using hashes here.

File details

Details for the file object_store_python-0.0.8-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for object_store_python-0.0.8-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 becad9df6618c9c025076ff37ec8da5845715ff4633d37c33639372ea10064e8
MD5 2a226156c36d9d109efdd6b8837496d1
BLAKE2b-256 5fef5fd49b52df4258b37c2a744ba929cabffd7dc0188ee15b2493485dca15ba

See more details on using hashes here.

File details

Details for the file object_store_python-0.0.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for object_store_python-0.0.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dd42d54fc3129c98441e9702778310126c07c776bb2207e4fc36c3d5d1990bdc
MD5 fbdc35afb390fabfa6fff6cdc66644f5
BLAKE2b-256 f07be4aead1c44243e7bec1e1f399651d505ec78fc510c2c3ae73e7e82a16705

See more details on using hashes here.

File details

Details for the file object_store_python-0.0.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for object_store_python-0.0.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 04acc99c3e499128cc09b9428fc523aeb708b1cd0d478f980244b823bac19bbc
MD5 644001f38f4219ae35b355e1c4e016e7
BLAKE2b-256 25a1b0c78b5e66c697e7657bb99e6847514c91c0413a3a2f8b832a35606babe1

See more details on using hashes here.

File details

Details for the file object_store_python-0.0.8-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for object_store_python-0.0.8-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 86d35eedb2054b65d7c78f3b837ce4ae5dd573680a62fc891dafd6a325774468
MD5 9b1303aa6d22bf763c606536af811607
BLAKE2b-256 3e44d2d1d5a44338af80330066e91db04cd2d1dfc20abc392609ff6130c276ab

See more details on using hashes here.

File details

Details for the file object_store_python-0.0.8-cp38-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for object_store_python-0.0.8-cp38-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 196137c9deefd637efb2a48644313b9cc42427bd42d046b115fbe5318fa2e9e2
MD5 6dea6ed532be81d00e29098805724ee1
BLAKE2b-256 24824f35a53aba39fa00d6ad07e0bc9444c888b1d2627c4ba0f9cc32e175e04c

See more details on using hashes here.

File details

Details for the file object_store_python-0.0.8-cp38-abi3-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for object_store_python-0.0.8-cp38-abi3-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 34b75a8c794ea110e7e638f2ae21a86ccf27c9e948e44237ac8a2f2656716524
MD5 5d56375633cc553b1cd0507e74c7fd12
BLAKE2b-256 0c78d21146ec83a1e84d60f149a52d002fd3dc700b8e0d9d1ceef57e3884959a

See more details on using hashes here.

Supported by

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