Skip to main content

Python bindings for Alopex DB

Project description

Alopex Python バインディング

Python から AlopexDB を操作するためのバインディングです。
Database/Transaction の基本機能に加え、ベクトル検索(numpy)と Unity Catalog 互換の Catalog API(polars)を提供します。

インストール

pip install alopex

開発中は maturin を利用できます。

maturin develop -m crates/alopex-py/pyproject.toml

オプション依存:

  • numpy を使う場合: pip install alopex[numpy]
  • polars を使う場合: pip install alopex[polars]

基本的な使い方

Database / Transaction

from alopex import Database, TxnMode

db = Database.new()

with db.begin(TxnMode.READ_WRITE) as txn:
    txn.put(b"user:1", b"alice")
    txn.commit()

with db.begin(TxnMode.READ_ONLY) as txn:
    value = txn.get(b"user:1")
    print(value)

db.close()

ベクトル検索(numpy 必須)

import numpy as np
from alopex import Database, Metric, TxnMode

db = Database.new()
with db.begin(TxnMode.READ_WRITE) as txn:
    vec = np.array([1.0, 0.0, 0.0], dtype=np.float32)
    txn.upsert_vector(b"k1", None, vec, Metric.COSINE)
    results = txn.search_similar(vec, Metric.COSINE, 1)
    print(results[0].key, results[0].score)

HNSW インデックス(numpy 必須)

import numpy as np
from alopex import Database, HnswConfig, TxnMode

db = Database.new()
db.create_hnsw_index("idx", HnswConfig(2))

with db.begin(TxnMode.READ_WRITE) as txn:
    vec = np.array([1.0, 0.0], dtype=np.float32)
    txn.upsert_to_hnsw("idx", b"k1", vec, None)
    txn.commit()

results, stats = db.search_hnsw("idx", np.array([1.0, 0.0], dtype=np.float32), 1)
print(stats.node_count)

Catalog API(polars 必須)

import polars as pl
from alopex import Catalog, ColumnInfo

Catalog.create_catalog("main")
Catalog.create_namespace("main", "default")

columns = [ColumnInfo("id", "int", 0, False)]
Catalog.create_table("main", "default", "users", columns, "/tmp/users.parquet")

df = pl.DataFrame({"id": [1, 2], "name": ["a", "b"]})
Catalog.write_table(
    df,
    "main",
    "default",
    "users",
    delta_mode="overwrite",
    storage_location="/tmp/users.parquet",
)

lazy_frame = Catalog.scan_table("main", "default", "users")
print(lazy_frame.collect())

注意事項

  • numpy / polars が未インストールの場合、対応 API は AlopexError を返します。
  • Phase 1 では Parquet のみ対応しています。

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

alopex-0.3.2.tar.gz (464.8 kB view details)

Uploaded Source

Built Distributions

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

alopex-0.3.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (612.1 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

alopex-0.3.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (613.9 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

alopex-0.3.2-cp38-abi3-win_amd64.whl (515.1 kB view details)

Uploaded CPython 3.8+Windows x86-64

alopex-0.3.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (635.4 kB view details)

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

alopex-0.3.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (614.4 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

alopex-0.3.2-cp38-abi3-macosx_11_0_arm64.whl (588.2 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

alopex-0.3.2-cp38-abi3-macosx_10_12_x86_64.whl (620.6 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file alopex-0.3.2.tar.gz.

File metadata

  • Download URL: alopex-0.3.2.tar.gz
  • Upload date:
  • Size: 464.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for alopex-0.3.2.tar.gz
Algorithm Hash digest
SHA256 892f695cfb587b947b4821fe2b94fecd34c07284899d57e71ce373c97a506835
MD5 10c6a09a6e4ac1a541ca8ba72239df38
BLAKE2b-256 7a9f4a22d459cbca054cf3adcbbf9c8bbf50c989864d52e3b4f231ff22be52f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.2.tar.gz:

Publisher: alopex-py-release.yml on alopex-db/alopex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alopex-0.3.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for alopex-0.3.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 12672a7dec4d8cda31f0fedb16d2ac923c3cf060c326e0b39482787350aa7d14
MD5 d55eb131da6609026b29c48f77c102b3
BLAKE2b-256 4f6df5333cc24d184ae39f3f96287f8396d7721b773375bdb454222dac3bb7ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: alopex-py-release.yml on alopex-db/alopex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alopex-0.3.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for alopex-0.3.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2c3da52329a335ecbebf118fde9faab11c061194e61ac982d34ed95957619fe6
MD5 5ec1a1a31850fb668876ee7dd868f0ea
BLAKE2b-256 de24c652be95e2c320865468bea3b740ec632380c5d6e2f3e716a3f975e4a98f

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: alopex-py-release.yml on alopex-db/alopex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alopex-0.3.2-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: alopex-0.3.2-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 515.1 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for alopex-0.3.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3ca17b3a0e7466a9b026f6c1d87d888d689d8d192c0ffe464fb9e3b508ff8fe2
MD5 edecfc8048b5bcba41a3274f6ef9dc3a
BLAKE2b-256 4af5a8001d6df7e0b8b40a171b7ea409e57736a48ba7d4c3245b05a624a37eef

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.2-cp38-abi3-win_amd64.whl:

Publisher: alopex-py-release.yml on alopex-db/alopex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alopex-0.3.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for alopex-0.3.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a2277b5eac947c9b130cb8a32d4ba236571944fb1dcf372b93303b9a2a2f537
MD5 ea24cc54803494616866f548f2c4c07d
BLAKE2b-256 7192aabb8bea08efb69978bd8e0628f7e9849adb488fc97e2aa7b7b411a8d1a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: alopex-py-release.yml on alopex-db/alopex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alopex-0.3.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for alopex-0.3.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e7df27e795cadf3e8baec1ae346ee68ff17e1612a1cac9e6fe16138dd52fd856
MD5 a301fcadf19f69dbc728b5f52c121849
BLAKE2b-256 d7990a9e5b4cba4379683486870e47d01c1bdedd5e5da6c0332df433aa7ff2d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: alopex-py-release.yml on alopex-db/alopex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alopex-0.3.2-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for alopex-0.3.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e25e764470b38531faf1a864a31a1fd0d3752ddeb99075283de0957424a74c2b
MD5 d960a85f0e6d10b026fc3d82ee3c0139
BLAKE2b-256 dbe6cf86f3a3fb898856e98421e88e135f9d66684a24bcb93b7574c616a9e16e

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.2-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: alopex-py-release.yml on alopex-db/alopex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alopex-0.3.2-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for alopex-0.3.2-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a6601a60b44a16fe12a6b14766fe8c428059850624d1289f2bb30a8d9ca6a948
MD5 7414e71af934adc25c8053dcd55743a3
BLAKE2b-256 930f342262d0c63eb8101ed3f06d25badb1ec4947e2c410c321e3d11ecaab8cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.2-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: alopex-py-release.yml on alopex-db/alopex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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