Skip to main content

object-store-python

CI code style: black PyPI 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. The kind of service is always derived from the url used to specifiy the storage location. Some basic configuration can also be derived from the url string, dependent on the chosen url format.

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>")

Azure

The recommended url format is az://<container>/<path> and Azure always requieres azure_storage_account_name to be configured.

  • shared key
    • azure_storage_account_key
  • service principal
    • azure_client_id
    • azure_client_secret
    • azure_tenant_id
  • shared access signature
    • azure_storage_sas_key (as provided by StorageExplorer)
  • bearer token
    • azure_storage_token
  • managed identity
    • if using user assigned identity one of azure_client_id, azure_object_id, azure_msi_resource_id
    • if no other credential can be created, managed identity will be tried
  • workload identity
    • azure_client_id
    • azure_tenant_id
    • azure_federated_token_file

S3

The recommended url format is s3://<bucket>/<path> S3 storage always requires a region to be specified via one of aws_region or aws_default_region.

AWS supports virtual hosting of buckets, which can be configured by setting aws_virtual_hosted_style_request to "true".

When an alternative implementation or a mocked service like localstack is used, the service endpoint needs to be explicitly specified via aws_endpoint.

GCS

The recommended url format is gs://<bucket>/<path>.

  • service account
    • google_service_account

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

Metadata

Release files for object-store-python 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for object-store-python 0.1.10
File Size Uploaded
object_store_python-0.1.10.tar.gz 36.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for object-store-python 0.1.10
File
object_store_python-0.1.10-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
object_store_python-0.1.10-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details
object_store_python-0.1.10-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details
object_store_python-0.1.10-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details
object_store_python-0.1.10-cp38-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl CPython 3.8 abi3 macOS 10.9+ x86-64, macOS 11.0+ ARM64, macOS 10.9+ universal2 (ARM64, x86-64) Details
object_store_python-0.1.10-cp38-abi3-macosx_10_7_x86_64.whl CPython 3.8 abi3 macOS 10.7+ x86-64 Details

Total release size: 33.4 MB

Release files / object_store_python-0.1.10.tar.gz

Download URL object_store_python-0.1.10.tar.gz
Size 36.8 kB
Tags Source
SHA-256 checksum
How to use checksums
451b22f89d15c5558c6b7ddbf9e773f47295931342a801ed1ff9f11d74857dc2
BLAKE2b-256 checksum
How to use checksums
0dbbb372b4b36926487b3b2ca6efb12261d0eaf0828ba1db0bba49f1e66b9862
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.17

Release files / object_store_python-0.1.10-cp38-abi3-win_amd64.whl

Download URL object_store_python-0.1.10-cp38-abi3-win_amd64.whl
Size 4.5 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1758cb6348f5a1cbcaa3400c0f91f2affee35f567d4bae9c590e711f74d9b18f
BLAKE2b-256 checksum
How to use checksums
373ef710554442df82eccce5c6e11c1c9a073b80cf5b25bd79ed72063a503da3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.17

Release files / object_store_python-0.1.10-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL object_store_python-0.1.10-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.9 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
7cbd3ec5172eb1a234d9ec9901d8298bbd84db486d2620a73249eb1d3f8586e3
BLAKE2b-256 checksum
How to use checksums
57bcd44f9f9e651fbf4a048a345ab20bd860b946f47c5d0cca30cb8af622f3bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.17

Release files / object_store_python-0.1.10-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL object_store_python-0.1.10-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.4 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
3ca4d1b85e99af1fb476f6a7d4dae0d11a86a5df36f8d00d1b4a10362ad444cd
BLAKE2b-256 checksum
How to use checksums
77cd4da4d5d16bc1c99d21e0f94a21400c8ba1f1fbf4cfba10b086b070e5c1ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.17

Release files / object_store_python-0.1.10-cp38-abi3-macosx_11_0_arm64.whl

Download URL object_store_python-0.1.10-cp38-abi3-macosx_11_0_arm64.whl
Size 4.2 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bf37ba9f9c79a5a2385f72109fb89c1155a6ffde1338fb6e8fb8d029de5b0b95
BLAKE2b-256 checksum
How to use checksums
24ed854395abe96bfea30a92ae2eff77b6f446257f1e4eba65be5ef71a345c2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.17

Release files / object_store_python-0.1.10-cp38-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl

Download URL object_store_python-0.1.10-cp38-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Size 8.8 MB
Tags CPython 3.8 abi3 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
33f1f2fd11bcf2c1d6936dd2a09f538530c99b8735f9be5d2f4bf56b83f2f386
BLAKE2b-256 checksum
How to use checksums
057a2b4d984f794bfd98b3be0e252ef22682e85f00e96be292d6c6bfb6fc600d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.17

Release files / object_store_python-0.1.10-cp38-abi3-macosx_10_7_x86_64.whl

Download URL object_store_python-0.1.10-cp38-abi3-macosx_10_7_x86_64.whl
Size 4.6 MB
Tags CPython 3.8 abi3 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
e84f719d06773fdef17e82d7d8ad48aee2a82a04b97b4c50f7a2f5c6da4223a3
BLAKE2b-256 checksum
How to use checksums
2ee3e6a2ca93484ea190d1a0f5c866af3b5415f7594ac4c9adc7d7a6b1534f1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.17

Release history Release notifications | RSS feed

This release

0.1.10 This release

7 release files

0.1.9

7 release files

0.1.8

7 release files

0.1.7

7 release files

0.1.6

7 release files

0.1.5

7 release files

0.1.4

7 release files

0.1.3

7 release files

0.1.2

7 release files

0.1.1

7 release files

0.1.0

7 release files

0.0.9

7 release files

0.0.8

7 release files

0.0.7

7 release files

0.0.6

7 release files

0.0.5

7 release files

0.0.4

6 release files

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page