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-tool build --input embeddings.npy --output ./data --name notes
skeg-server --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.0.tar.gz (22.7 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.0-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.0-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.0-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.0.tar.gz.

File metadata

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

File hashes

Hashes for skeg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 39d83dbeef860d824be6744d0cf9ae5e6a4f21aa082da122ef685efaf6de85b2
MD5 763570b29704ebe622d71eadfbd0fe37
BLAKE2b-256 358f26b92ac97634a06ff603d63c4bb847c502b74ceebe5facddd62428097c80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for skeg-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2d11ca0e97b7777ed4c013662c63b9e7f69118c17e6d45f2dc776468368c54a9
MD5 d73d80bae985ba0d9ef2f562c168e1da
BLAKE2b-256 6f047f74095067a99a230f2e7f489b81a04073678013c1c00bbc759d79cafe03

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for skeg-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 50d2285c4def279e4e99eee726fe863eeceb3fc41cb796d88c17d2af93550019
MD5 6f2cc04adbc7eb1f8426724161cd0e9c
BLAKE2b-256 0d79e4ce3d303ed5adc4fbf38c897d83053ec394bb2110c1f330db5d38437d90

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for skeg-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 75c664fdbaf8f16eb55a3895f32258c2832028a73301a693956934920474e115
MD5 c1d5d3dbd7f08738f52df99553708753
BLAKE2b-256 c657b205d15335e7c296dfc230ad219ebb984ca9693685a8ad4914148f473e06

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