skeg 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- skeg-0.1.0/PKG-INFO +180 -0
- skeg-0.1.0/README.md +153 -0
- skeg-0.1.0/pyproject.toml +56 -0
- skeg-0.1.0/rust/Cargo.lock +761 -0
- skeg-0.1.0/rust/Cargo.toml +38 -0
- skeg-0.1.0/rust/src/lib.rs +272 -0
- skeg-0.1.0/src/skeg/__init__.py +68 -0
- skeg-0.1.0/src/skeg/_wire.py +375 -0
- skeg-0.1.0/src/skeg/binary.py +342 -0
- skeg-0.1.0/src/skeg/errors.py +32 -0
- skeg-0.1.0/src/skeg/resp.py +281 -0
skeg-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: skeg
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Topic :: Database
|
|
13
|
+
Requires-Dist: pytest>=7.0 ; extra == 'test'
|
|
14
|
+
Requires-Dist: pytest-timeout>=2.0 ; extra == 'test'
|
|
15
|
+
Provides-Extra: test
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Summary: Python client for skeg (KV+vector store).
|
|
18
|
+
Keywords: vector-store,kv-store,redis,rag,vamana
|
|
19
|
+
Author: skeg authors
|
|
20
|
+
License: Apache-2.0
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
23
|
+
Project-URL: Homepage, https://github.com/skegdb/skeg-py
|
|
24
|
+
Project-URL: Issues, https://github.com/skegdb/skeg-py/issues
|
|
25
|
+
Project-URL: Repository, https://github.com/skegdb/skeg-py
|
|
26
|
+
|
|
27
|
+
# skeg-py
|
|
28
|
+
|
|
29
|
+
Python client for [skeg](https://github.com/skegdb/skeg), an
|
|
30
|
+
SSD-primary KV+vector store designed for Personal AI Inference machines.
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
pip install skeg # pure-Python
|
|
34
|
+
pip install 'skeg[fast]' # PyO3-backed (binary wheels for macOS arm64, Linux x86_64, Linux aarch64)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Wire formats (skeg binary protocol v1 and the RESP3 subset) are frozen.
|
|
38
|
+
The PyO3 backend mirrors the pure-Python `BinaryClient` API exactly.
|
|
39
|
+
|
|
40
|
+
## What's in the package
|
|
41
|
+
|
|
42
|
+
Two synchronous clients sharing one error hierarchy:
|
|
43
|
+
|
|
44
|
+
| Module | Wire | Server binary | Default port | Use case |
|
|
45
|
+
| --- | --- | --- | --- | --- |
|
|
46
|
+
| `skeg.BinaryClient` | skeg-proto (native) | `skeg` | 7379 | Max throughput, full feature surface (KV + vector) |
|
|
47
|
+
| `skeg.RespClient` | RESP2/3 (Redis) | `skeg-resp3` | 6379 | Drop-in compat with redis-cli / redis-py / Redis tooling |
|
|
48
|
+
|
|
49
|
+
Three backends behind one selector (`skeg.client(...)`):
|
|
50
|
+
|
|
51
|
+
- **Pure-Python** (default, zero deps) - just `pip install skeg`
|
|
52
|
+
- **PyO3 / Rust** (optional, faster framing) - `pip install skeg[fast]`
|
|
53
|
+
(requires Rust toolchain at install time, or a pre-built wheel)
|
|
54
|
+
|
|
55
|
+
The PyO3 path mirrors `BinaryClient`'s public API exactly, so you can
|
|
56
|
+
swap with no code changes:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
import skeg
|
|
60
|
+
c = skeg.client(prefer_native=True) # uses PyO3 if available
|
|
61
|
+
c = skeg.client(prefer_native=False) # forces pure-Python
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Install
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
pip install skeg # pure-Python, zero dependencies
|
|
68
|
+
pip install 'skeg[fast]' # PyO3-backed; binary wheels for macOS arm64, Linux x86_64, Linux aarch64
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
To build from source (e.g. on Windows or another arch), `pip install`
|
|
72
|
+
will compile the PyO3 backend; set `SKEG_PY_PURE=1` to skip it.
|
|
73
|
+
|
|
74
|
+
## Quick start
|
|
75
|
+
|
|
76
|
+
### KV
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from skeg import BinaryClient
|
|
80
|
+
|
|
81
|
+
with BinaryClient.connect("127.0.0.1", 7379) as c:
|
|
82
|
+
c.ping()
|
|
83
|
+
c.set(b"hello", b"world")
|
|
84
|
+
print(c.get(b"hello")) # b"world"
|
|
85
|
+
print(c.mget([b"hello", b"nope"])) # [b"world", None]
|
|
86
|
+
c.delete(b"hello")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Vectors (in-RAM flat)
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from skeg import BinaryClient
|
|
93
|
+
|
|
94
|
+
with BinaryClient.connect("127.0.0.1", 7379) as c:
|
|
95
|
+
c.vindex_create("notes", dim=1024, kind="int8", backend="flat")
|
|
96
|
+
c.vset("notes", 1, my_embedding_1024d)
|
|
97
|
+
c.vset("notes", 2, another_embedding)
|
|
98
|
+
for hit in c.vsearch("notes", query_embedding, k=10):
|
|
99
|
+
print(hit.id, hit.distance)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Vectors (on-disk Vamana)
|
|
103
|
+
|
|
104
|
+
Build the index offline (one-shot), then point the client at the served
|
|
105
|
+
copy:
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
skeg-tool build --input embeddings.npy --output ./data --name notes
|
|
109
|
+
skeg-server --mode serve --data-dir ./data --tier pq:128:256
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
# Same client code as above; the server handles the disk-backed index.
|
|
114
|
+
hits = c.vsearch("notes", query, k=10)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Redis-compat (RESP3)
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from skeg import RespClient
|
|
121
|
+
|
|
122
|
+
with RespClient.connect("127.0.0.1", 6379) as c:
|
|
123
|
+
c.hello(3) # upgrade to RESP3
|
|
124
|
+
c.set(b"foo", b"bar")
|
|
125
|
+
print(c.get(b"foo")) # b"bar"
|
|
126
|
+
c.mset({b"a": b"1", b"b": b"2"})
|
|
127
|
+
print(c.mget([b"a", b"b"])) # [b"1", b"2"]
|
|
128
|
+
print(c.incr(b"counter")) # 1
|
|
129
|
+
print(c.skeg_stats()) # "cache_bytes=... n_keys=..."
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Multi-tenant via HELLO AUTH:
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
c.hello(3, auth=("alice", "hunter2"))
|
|
136
|
+
print(c.skeg_whoami()) # "tenant=<hex> mode=tenant-aware"
|
|
137
|
+
# All subsequent GET/SET are auto-scoped to alice's namespace.
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Testing
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
brew tap skegdb/tap
|
|
144
|
+
brew install skeg
|
|
145
|
+
git clone https://github.com/skegdb/skeg-py
|
|
146
|
+
cd skeg-py
|
|
147
|
+
pip install -e '.[test]'
|
|
148
|
+
SKEG_BIN=$(which skeg) SKEG_RESP3_BIN=$(which skeg-resp3) pytest
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The test fixture spawns one server per session and tears it down at
|
|
152
|
+
the end. `SKEG_BIN` / `SKEG_RESP3_BIN` may be omitted if `skeg` and
|
|
153
|
+
`skeg-resp3` are on `$PATH`.
|
|
154
|
+
|
|
155
|
+
### Test-suite safety vs your data
|
|
156
|
+
|
|
157
|
+
**The pytest suite is designed for a server it owns.** It writes keys
|
|
158
|
+
under names like `doc:N`, `counter:N`, `sk-N`, and creates/drops
|
|
159
|
+
VINDEX entries prefixed with `pytst-`. If you ever override the
|
|
160
|
+
default fixture to point the suite at a server that already holds
|
|
161
|
+
real data:
|
|
162
|
+
|
|
163
|
+
- KV: keys with the names above will be overwritten or deleted.
|
|
164
|
+
- VINDEX: only entries that match the `pytst-` prefix are touched
|
|
165
|
+
by the cleanup loop. Unrelated VINDEX are left alone.
|
|
166
|
+
|
|
167
|
+
In short: never point `pytest` at a server you can't afford to lose
|
|
168
|
+
KV state on. The pytest-spawned fixture is the safe default.
|
|
169
|
+
|
|
170
|
+
## Compatibility
|
|
171
|
+
|
|
172
|
+
- Python 3.10+ (one abi3 wheel covers 3.10, 3.11, 3.12, 3.13).
|
|
173
|
+
- macOS arm64, Linux x86_64, Linux aarch64 (wheels). Other targets
|
|
174
|
+
build from sdist; set `SKEG_PY_PURE=1` to skip the PyO3 backend.
|
|
175
|
+
- Server protocol version 1. Wire format is stable.
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
180
|
+
|
skeg-0.1.0/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# skeg-py
|
|
2
|
+
|
|
3
|
+
Python client for [skeg](https://github.com/skegdb/skeg), an
|
|
4
|
+
SSD-primary KV+vector store designed for Personal AI Inference machines.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
pip install skeg # pure-Python
|
|
8
|
+
pip install 'skeg[fast]' # PyO3-backed (binary wheels for macOS arm64, Linux x86_64, Linux aarch64)
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Wire formats (skeg binary protocol v1 and the RESP3 subset) are frozen.
|
|
12
|
+
The PyO3 backend mirrors the pure-Python `BinaryClient` API exactly.
|
|
13
|
+
|
|
14
|
+
## What's in the package
|
|
15
|
+
|
|
16
|
+
Two synchronous clients sharing one error hierarchy:
|
|
17
|
+
|
|
18
|
+
| Module | Wire | Server binary | Default port | Use case |
|
|
19
|
+
| --- | --- | --- | --- | --- |
|
|
20
|
+
| `skeg.BinaryClient` | skeg-proto (native) | `skeg` | 7379 | Max throughput, full feature surface (KV + vector) |
|
|
21
|
+
| `skeg.RespClient` | RESP2/3 (Redis) | `skeg-resp3` | 6379 | Drop-in compat with redis-cli / redis-py / Redis tooling |
|
|
22
|
+
|
|
23
|
+
Three backends behind one selector (`skeg.client(...)`):
|
|
24
|
+
|
|
25
|
+
- **Pure-Python** (default, zero deps) - just `pip install skeg`
|
|
26
|
+
- **PyO3 / Rust** (optional, faster framing) - `pip install skeg[fast]`
|
|
27
|
+
(requires Rust toolchain at install time, or a pre-built wheel)
|
|
28
|
+
|
|
29
|
+
The PyO3 path mirrors `BinaryClient`'s public API exactly, so you can
|
|
30
|
+
swap with no code changes:
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import skeg
|
|
34
|
+
c = skeg.client(prefer_native=True) # uses PyO3 if available
|
|
35
|
+
c = skeg.client(prefer_native=False) # forces pure-Python
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
pip install skeg # pure-Python, zero dependencies
|
|
42
|
+
pip install 'skeg[fast]' # PyO3-backed; binary wheels for macOS arm64, Linux x86_64, Linux aarch64
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
To build from source (e.g. on Windows or another arch), `pip install`
|
|
46
|
+
will compile the PyO3 backend; set `SKEG_PY_PURE=1` to skip it.
|
|
47
|
+
|
|
48
|
+
## Quick start
|
|
49
|
+
|
|
50
|
+
### KV
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from skeg import BinaryClient
|
|
54
|
+
|
|
55
|
+
with BinaryClient.connect("127.0.0.1", 7379) as c:
|
|
56
|
+
c.ping()
|
|
57
|
+
c.set(b"hello", b"world")
|
|
58
|
+
print(c.get(b"hello")) # b"world"
|
|
59
|
+
print(c.mget([b"hello", b"nope"])) # [b"world", None]
|
|
60
|
+
c.delete(b"hello")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Vectors (in-RAM flat)
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from skeg import BinaryClient
|
|
67
|
+
|
|
68
|
+
with BinaryClient.connect("127.0.0.1", 7379) as c:
|
|
69
|
+
c.vindex_create("notes", dim=1024, kind="int8", backend="flat")
|
|
70
|
+
c.vset("notes", 1, my_embedding_1024d)
|
|
71
|
+
c.vset("notes", 2, another_embedding)
|
|
72
|
+
for hit in c.vsearch("notes", query_embedding, k=10):
|
|
73
|
+
print(hit.id, hit.distance)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Vectors (on-disk Vamana)
|
|
77
|
+
|
|
78
|
+
Build the index offline (one-shot), then point the client at the served
|
|
79
|
+
copy:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
skeg-tool build --input embeddings.npy --output ./data --name notes
|
|
83
|
+
skeg-server --mode serve --data-dir ./data --tier pq:128:256
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
# Same client code as above; the server handles the disk-backed index.
|
|
88
|
+
hits = c.vsearch("notes", query, k=10)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Redis-compat (RESP3)
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from skeg import RespClient
|
|
95
|
+
|
|
96
|
+
with RespClient.connect("127.0.0.1", 6379) as c:
|
|
97
|
+
c.hello(3) # upgrade to RESP3
|
|
98
|
+
c.set(b"foo", b"bar")
|
|
99
|
+
print(c.get(b"foo")) # b"bar"
|
|
100
|
+
c.mset({b"a": b"1", b"b": b"2"})
|
|
101
|
+
print(c.mget([b"a", b"b"])) # [b"1", b"2"]
|
|
102
|
+
print(c.incr(b"counter")) # 1
|
|
103
|
+
print(c.skeg_stats()) # "cache_bytes=... n_keys=..."
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Multi-tenant via HELLO AUTH:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
c.hello(3, auth=("alice", "hunter2"))
|
|
110
|
+
print(c.skeg_whoami()) # "tenant=<hex> mode=tenant-aware"
|
|
111
|
+
# All subsequent GET/SET are auto-scoped to alice's namespace.
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Testing
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
brew tap skegdb/tap
|
|
118
|
+
brew install skeg
|
|
119
|
+
git clone https://github.com/skegdb/skeg-py
|
|
120
|
+
cd skeg-py
|
|
121
|
+
pip install -e '.[test]'
|
|
122
|
+
SKEG_BIN=$(which skeg) SKEG_RESP3_BIN=$(which skeg-resp3) pytest
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The test fixture spawns one server per session and tears it down at
|
|
126
|
+
the end. `SKEG_BIN` / `SKEG_RESP3_BIN` may be omitted if `skeg` and
|
|
127
|
+
`skeg-resp3` are on `$PATH`.
|
|
128
|
+
|
|
129
|
+
### Test-suite safety vs your data
|
|
130
|
+
|
|
131
|
+
**The pytest suite is designed for a server it owns.** It writes keys
|
|
132
|
+
under names like `doc:N`, `counter:N`, `sk-N`, and creates/drops
|
|
133
|
+
VINDEX entries prefixed with `pytst-`. If you ever override the
|
|
134
|
+
default fixture to point the suite at a server that already holds
|
|
135
|
+
real data:
|
|
136
|
+
|
|
137
|
+
- KV: keys with the names above will be overwritten or deleted.
|
|
138
|
+
- VINDEX: only entries that match the `pytst-` prefix are touched
|
|
139
|
+
by the cleanup loop. Unrelated VINDEX are left alone.
|
|
140
|
+
|
|
141
|
+
In short: never point `pytest` at a server you can't afford to lose
|
|
142
|
+
KV state on. The pytest-spawned fixture is the safe default.
|
|
143
|
+
|
|
144
|
+
## Compatibility
|
|
145
|
+
|
|
146
|
+
- Python 3.10+ (one abi3 wheel covers 3.10, 3.11, 3.12, 3.13).
|
|
147
|
+
- macOS arm64, Linux x86_64, Linux aarch64 (wheels). Other targets
|
|
148
|
+
build from sdist; set `SKEG_PY_PURE=1` to skip the PyO3 backend.
|
|
149
|
+
- Server protocol version 1. Wire format is stable.
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
# Default build backend: maturin (Rust + Python). The pure-Python install
|
|
3
|
+
# path works equally well via the lightweight wheel maturin produces with
|
|
4
|
+
# an empty `[tool.maturin]` extension. If you want pure-Python only and
|
|
5
|
+
# don't have a Rust toolchain, install with:
|
|
6
|
+
# SKEG_PY_PURE=1 pip install -e .
|
|
7
|
+
# (the [tool.maturin] block below is skipped when SKEG_PY_PURE is set).
|
|
8
|
+
requires = ["maturin>=1.4,<2.0"]
|
|
9
|
+
build-backend = "maturin"
|
|
10
|
+
|
|
11
|
+
[project]
|
|
12
|
+
name = "skeg"
|
|
13
|
+
version = "0.1.0"
|
|
14
|
+
description = "Python client for skeg (KV+vector store)."
|
|
15
|
+
readme = "README.md"
|
|
16
|
+
requires-python = ">=3.10"
|
|
17
|
+
license = { text = "Apache-2.0" }
|
|
18
|
+
authors = [{ name = "skeg authors" }]
|
|
19
|
+
keywords = ["vector-store", "kv-store", "redis", "rag", "vamana"]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 4 - Beta",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"License :: OSI Approved :: Apache Software License",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.10",
|
|
26
|
+
"Programming Language :: Python :: 3.11",
|
|
27
|
+
"Programming Language :: Python :: 3.12",
|
|
28
|
+
"Programming Language :: Python :: 3.13",
|
|
29
|
+
"Topic :: Database",
|
|
30
|
+
]
|
|
31
|
+
dependencies = []
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
test = [
|
|
35
|
+
"pytest>=7.0",
|
|
36
|
+
"pytest-timeout>=2.0",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/skegdb/skeg-py"
|
|
41
|
+
Repository = "https://github.com/skegdb/skeg-py"
|
|
42
|
+
Issues = "https://github.com/skegdb/skeg-py/issues"
|
|
43
|
+
|
|
44
|
+
[tool.maturin]
|
|
45
|
+
# The Rust extension lives under rust/. The python package lives under
|
|
46
|
+
# src/skeg/. maturin merges them: the compiled module is imported as
|
|
47
|
+
# `skeg._native`, the Python files stay at `skeg.*`.
|
|
48
|
+
manifest-path = "rust/Cargo.toml"
|
|
49
|
+
module-name = "skeg._native"
|
|
50
|
+
python-source = "src"
|
|
51
|
+
features = ["pyo3/extension-module"]
|
|
52
|
+
|
|
53
|
+
[tool.pytest.ini_options]
|
|
54
|
+
testpaths = ["tests"]
|
|
55
|
+
timeout = 30
|
|
56
|
+
addopts = "-v"
|