Skip to main content

Python client for skeg (KV+vector store).

Project description

skeg-py

Python client for skeg, an SSD-primary KV+vector store designed for Personal AI Inference machines.

pip install skeg              # pure-Python
pip install 'skeg[fast]'      # PyO3-backed (binary wheels for macOS arm64, Linux x86_64, Linux aarch64)

Wire formats (skeg binary protocol v1 and the RESP3 subset) are frozen. The PyO3 backend mirrors the pure-Python BinaryClient API exactly.

What's in the package

Two synchronous clients sharing one error hierarchy:

Module Wire Server binary Default port Use case
skeg.BinaryClient skeg-proto (native) skeg 7379 Max throughput, full feature surface (KV + vector)
skeg.RespClient RESP2/3 (Redis) skeg-resp3 6379 Drop-in compat with redis-cli / redis-py / Redis tooling

Three backends behind one selector (skeg.client(...)):

  • Pure-Python (default, zero deps) - just pip install skeg
  • PyO3 / Rust (optional, faster framing) - pip install skeg[fast] (requires Rust toolchain at install time, or a pre-built wheel)

The PyO3 path mirrors BinaryClient's public API exactly, so you can swap with no code changes:

import skeg
c = skeg.client(prefer_native=True)   # uses PyO3 if available
c = skeg.client(prefer_native=False)  # forces pure-Python

Install

pip install skeg              # pure-Python, zero dependencies
pip install 'skeg[fast]'      # PyO3-backed; binary wheels for macOS arm64, Linux x86_64, Linux aarch64

To build from source (e.g. on Windows or another arch), pip install will compile the PyO3 backend; set SKEG_PY_PURE=1 to skip it.

Quick start

KV

from skeg import BinaryClient

with BinaryClient.connect("127.0.0.1", 7379) as c:
    c.ping()
    c.set(b"hello", b"world")
    print(c.get(b"hello"))               # b"world"
    print(c.mget([b"hello", b"nope"]))   # [b"world", None]
    c.delete(b"hello")

Vectors (in-RAM flat)

from skeg import BinaryClient

with BinaryClient.connect("127.0.0.1", 7379) as c:
    c.vindex_create("notes", dim=1024, kind="int8", backend="flat")
    c.vset("notes", 1, my_embedding_1024d)
    c.vset("notes", 2, another_embedding)
    for hit in c.vsearch("notes", query_embedding, k=10):
        print(hit.id, hit.distance)

Vectors (on-disk Vamana)

Build the index offline (one-shot), then point the client at the served copy:

skeg-cli build --input embeddings.npy --output ./data --name notes
skeg --mode serve --data-dir ./data --tier pq:128:256
# Same client code as above; the server handles the disk-backed index.
hits = c.vsearch("notes", query, k=10)

Redis-compat (RESP3)

from skeg import RespClient

with RespClient.connect("127.0.0.1", 6379) as c:
    c.hello(3)                      # upgrade to RESP3
    c.set(b"foo", b"bar")
    print(c.get(b"foo"))            # b"bar"
    c.mset({b"a": b"1", b"b": b"2"})
    print(c.mget([b"a", b"b"]))     # [b"1", b"2"]
    print(c.incr(b"counter"))       # 1
    print(c.skeg_stats())           # "cache_bytes=... n_keys=..."

Multi-tenant via HELLO AUTH:

c.hello(3, auth=("alice", "hunter2"))
print(c.skeg_whoami())  # "tenant=<hex> mode=tenant-aware"
# All subsequent GET/SET are auto-scoped to alice's namespace.

Testing

brew tap skegdb/tap
brew install skeg
git clone https://github.com/skegdb/skeg-py
cd skeg-py
pip install -e '.[test]'
SKEG_BIN=$(which skeg) SKEG_RESP3_BIN=$(which skeg-resp3) pytest

The test fixture spawns one server per session and tears it down at the end. SKEG_BIN / SKEG_RESP3_BIN may be omitted if skeg and skeg-resp3 are on $PATH.

Test-suite safety vs your data

The pytest suite is designed for a server it owns. It writes keys under names like doc:N, counter:N, sk-N, and creates/drops VINDEX entries prefixed with pytst-. If you ever override the default fixture to point the suite at a server that already holds real data:

  • KV: keys with the names above will be overwritten or deleted.
  • VINDEX: only entries that match the pytst- prefix are touched by the cleanup loop. Unrelated VINDEX are left alone.

In short: never point pytest at a server you can't afford to lose KV state on. The pytest-spawned fixture is the safe default.

Compatibility

  • Python 3.10+ (one abi3 wheel covers 3.10, 3.11, 3.12, 3.13).
  • macOS arm64, Linux x86_64, Linux aarch64 (wheels). Other targets build from sdist; set SKEG_PY_PURE=1 to skip the PyO3 backend.
  • Server protocol version 1. Wire format is stable.

License

Apache-2.0. See LICENSE.

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

skeg-0.1.1.tar.gz (26.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

skeg-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (480.5 kB view details)

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

skeg-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (475.5 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

skeg-0.1.1-cp310-abi3-macosx_11_0_arm64.whl (410.4 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file skeg-0.1.1.tar.gz.

File metadata

  • Download URL: skeg-0.1.1.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for skeg-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7e496deff306afadd9c1322d862e1c5eca765ea5e0e4b19460d413f33e0cf205
MD5 c82ec8513f87c457348995969539ed39
BLAKE2b-256 6f1aad7037a2fe2f8d5f3bb935ab1f1972c07da13d910ed96c4aeedf6ec2e083

See more details on using hashes here.

File details

Details for the file skeg-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for skeg-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 65f38276aca40de81a0a79d9c98a9ed8f4b119c16f2c96ffce3c712fdcecb85b
MD5 e6beaeaa69b24d0668d984b7d197acb5
BLAKE2b-256 1f520e55b7584bad617843ffc2ed107462bee1861c32ffa67d83235adead263e

See more details on using hashes here.

File details

Details for the file skeg-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for skeg-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d0f61bd5ba1644c2614b90b1b4ea60aad10d5ab9dc84f11b8d051cb2d8fc5df0
MD5 50939b936ddca735038d8aeaff448fd6
BLAKE2b-256 08e544a1af61b827567afb8cb9e5e6d7e265813db15a9b60b88785cfa0ae67e0

See more details on using hashes here.

File details

Details for the file skeg-0.1.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for skeg-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f4077d3f5d0d49d85145647bcd40b2ec69b1383c21f6bd4b728655513a5135e8
MD5 a1da96c8fcb06d4f8ca82a3a06af60b4
BLAKE2b-256 7d3ced590705a69b83e94627aa7fb2a190be3eb03ac338118762ae0785e8b7a9

See more details on using hashes here.

Supported by

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