Skip to main content

objstore-r

pip install uu-objstore-r → import objstore_r (Python ≥ 3.12, one abi3 wheel per platform).

One small object-store API over Google Cloud Storage, a local directory and memory, with the primitive that makes object storage usable as a database: generation preconditions (compare-and-swap).

import objstore_r

store = objstore_r.Store.gcs("my-bucket")        # Application Default Credentials
# store = objstore_r.Store.local("/var/data")    # same API on disk
# store = objstore_r.Store.memory()              # same API in memory (tests)

gen = store.put("state/HEAD", b"v1", create_only=True)
blob = store.get("state/HEAD")                   # Blob, zero-copy
view = memoryview(blob)                          # no copy of the downloaded bytes
store.put("state/HEAD", b"v2", if_generation=blob.generation)   # CAS
try:
    store.put("state/HEAD", b"v3", if_generation=gen)           # stale
except objstore_r.PreconditionFailedError:
    ...
  • Compare-and-swap everywhere. Every write returns the object's new generation; if_generation= and create_only= make writes conditional — on GCS (ifGenerationMatch), on disk (atomic across threads and processes), and in memory.
  • Zero-copy reads. Blob exports the downloaded buffer through the buffer protocol; pass a Blob back to put and it is not copied either.
  • Ranged and concurrent reads. get_range(key, start, end); get_many(keys) fetches concurrently.
  • Opt-in compression. put(key, data, content_encoding="gzip") stores an object compressed (on GCS as its contentEncoding); get decodes it once, in Rust, and the Blob is zero-copy from there. Meta.content_encoding reports it from head and list. A ranged read of an encoded object raises EncodedRangeError; decoding stops at max_inflated bytes (1 GiB by default, a keyword on every constructor) with TooLargeError.
  • Safe keys. /-separated segments of [A-Za-z0-9._-], validated before any I/O: no traversal, no hidden files, portable to every OS (InvalidKeyError otherwise).
  • Production GCS client. Resumable uploads above 8 MiB, ranged downloads, retries with jittered backoff on 408/429/5xx (never on conflicts), lost-response detection on conditional writes, response size limits, no redirects, TLS required except for a loopback emulator. Tokens are cached and never appear in errors or reprs.
  • Credentials. Application Default Credentials by default (gcloud user credentials or the metadata server on Cloud Run / GCE / GKE; service-account key files are deliberately unsupported), token= for a fixed bearer token, anonymous=True for fake-gcs-server.
  • Thread-safe. Every call releases the GIL; use a thread pool or asyncio.to_thread for concurrency.

Errors

All derive from ObjstoreError: NotFoundError (ranged read of a missing object; get/head return None instead), ConflictError, PreconditionFailedError, InvalidKeyError, UnavailableError, AuthError, TooLargeError, ProtocolError, EncodedRangeError (ranged read of an encoded object), UnsupportedEncodingError (an object stored with an encoding this build cannot decode). An unknown content_encoding= argument is a ValueError before any I/O.

Testing your code

Store.memory().inject_failure(after=n, lost_response=True) makes the n-th next operation fail — before applying, or after applying with the reply lost — to exercise retry paths.

Licence

AGPL-3.0-or-later, or a commercial licence — see the repository.

Metadata

Release files for uu-objstore-r 0.2.4

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

Source distribution (sdist)

Source distribution for uu-objstore-r 0.2.4
File Size Uploaded
uu_objstore_r-0.2.4.tar.gz 251.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for uu-objstore-r 0.2.4
File
uu_objstore_r-0.2.4-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
uu_objstore_r-0.2.4-cp312-abi3-manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64 Details
uu_objstore_r-0.2.4-cp312-abi3-manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.28+ ARM64 Details
uu_objstore_r-0.2.4-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details
uu_objstore_r-0.2.4-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details

Total release size: 10.6 MB

Release files / uu_objstore_r-0.2.4.tar.gz

Download URL uu_objstore_r-0.2.4.tar.gz
Size 251.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e559a8be2e93e8379601dd348cc20c5466a94b3d48cb5bc67ad2aa3e80c9c896
BLAKE2b-256 checksum
How to use checksums
2e05eff852249880bd3fe74c85a82f2fd689a6185969a5e03f217b9adcb53698
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / uu_objstore_r-0.2.4-cp312-abi3-win_amd64.whl

Download URL uu_objstore_r-0.2.4-cp312-abi3-win_amd64.whl
Size 2.1 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
adbc8a3c40cbd3844a446dcc732f986dcaedced0072960de5f71ae288e23e4bb
BLAKE2b-256 checksum
How to use checksums
ba712f047e5866b5ae0485d2a1cefaf4de7ee646952065bb26701140e65a1443
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / uu_objstore_r-0.2.4-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL uu_objstore_r-0.2.4-cp312-abi3-manylinux_2_28_x86_64.whl
Size 2.1 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
94c86da90fe5d22852fed945806c27191348fc939ea5afdbefee75e885bebe29
BLAKE2b-256 checksum
How to use checksums
5edcc50ea854c64a8900c0cffe040f2d7de940c5f657ed678b31c266bf23cd28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / uu_objstore_r-0.2.4-cp312-abi3-manylinux_2_28_aarch64.whl

Download URL uu_objstore_r-0.2.4-cp312-abi3-manylinux_2_28_aarch64.whl
Size 2.0 MB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
2dfe59560691a2ef539e2ea1db1217337fcfa41da6ba1dd1f5268e9c77d7d20b
BLAKE2b-256 checksum
How to use checksums
364f896ee076d894230ec5b813f738a6e7b0fa73a0052406448045fdaac1019c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / uu_objstore_r-0.2.4-cp312-abi3-macosx_11_0_arm64.whl

Download URL uu_objstore_r-0.2.4-cp312-abi3-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
565bdd220fac792f6a92481ab3a060fa690da5a15f9f6449a6600909b74a46b3
BLAKE2b-256 checksum
How to use checksums
83e4828ed527f3126696e24cb43480dff68eb460ca13cb8cc94d18fc9b003663
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / uu_objstore_r-0.2.4-cp312-abi3-macosx_10_12_x86_64.whl

Download URL uu_objstore_r-0.2.4-cp312-abi3-macosx_10_12_x86_64.whl
Size 2.1 MB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
f03258677d9921814880b120cfbba06d183708b30c2e235634b5aedeaf5c0391
BLAKE2b-256 checksum
How to use checksums
55de03273dfe30095bde36d00f6aba169fa940856ce2634e8dc435ecf64ba93c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.2.4 This release

6 release files

0.2.3

6 release files

0.2.2

6 release files

0.2.0

6 release files

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