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.3.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.3-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (612.3 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

alopex-0.3.3-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (614.0 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.8+Windows x86-64

alopex-0.3.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (635.3 kB view details)

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

alopex-0.3.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (614.6 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

alopex-0.3.3-cp38-abi3-macosx_11_0_arm64.whl (587.7 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

alopex-0.3.3-cp38-abi3-macosx_10_12_x86_64.whl (620.7 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: alopex-0.3.3.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.3.tar.gz
Algorithm Hash digest
SHA256 d6491bb0c144f34891078cbbbf604f3d3964be0a0e15ff92f4c13662e9264092
MD5 7260e0c5bb10e372e5241572a4a13b7a
BLAKE2b-256 62f03d17da5897305c731d5b3c7e6cf995094af38ad6260a6fdb50f98578d246

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.3.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.3-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for alopex-0.3.3-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 371c944ef4fc26520fff34b3d17d7aaaaf341dcf39b1669ba8d2bf1e46a48aa5
MD5 671e8e03ee02c6448aeaab01be96f816
BLAKE2b-256 fe8133b79155f24e99f840396178ccc40a0b4ed784e601fef76a3085354d2d39

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.3-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.3-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for alopex-0.3.3-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 26fc1077284ffec267f4e5d95e3372afd680b28eb265e0aed0ec2cdc5e21fe53
MD5 291b680b8433758f39642a0bde1ffd65
BLAKE2b-256 4984f8aa9b40ae5126564da4ec5cb84d9b203c2ae52c9250c513df616696fd12

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.3-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.3-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: alopex-0.3.3-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.3-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2579aff3c48f0117d7393f68ec346aff58b3ea4c469b19b49f2882995b52ff84
MD5 6dcc3f4576705fd4ef3e656586cf45f6
BLAKE2b-256 53ae8cbe1048f09ab47d607811d777db8ac12aff310e4787a191e343999f9809

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.3-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.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for alopex-0.3.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e1dc9cb8fc86b0feb46ffc1a91817bd14a3115045c9f76a95a7e3db7a86bc29
MD5 ec6dac2e5cc824379a118eb4ca88132a
BLAKE2b-256 4ced8a089702cbeb997cac7e685f746e47998620b8dea9867cbbe8d4597f2ae1

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.3-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.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for alopex-0.3.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 381281997243f136bf461f61ba6151dfc7d0fc3b778844c452f05968cad31055
MD5 a38813165749f54c892a66f0ea4038c8
BLAKE2b-256 6e14bf8221475398333c682432aa5956fe1968dceb31c3e6c21f0f1fccf3f9b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.3-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.3-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for alopex-0.3.3-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 671db184a44b030a9dbfa6f38aef0511c36e0a716c6004a4e908013f4e8e9330
MD5 cbe61a2af31220ccf1a33a986b00b310
BLAKE2b-256 3b8daffd1def222c3d2635c1d7acd0e44ca9360dcade1850961fb8c8832b22f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.3-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.3-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for alopex-0.3.3-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3573d1ff433d322600b87cc86a6e95494d8b17eddfdd7565b3306b4c725551b9
MD5 39c2a5e7fc456d5a453b422f6cdcfe35
BLAKE2b-256 8ccad0d030803fe875bd092f3aae4ce493cbbb6fad78f4bc29443ff9320d5ab2

See more details on using hashes here.

Provenance

The following attestation bundles were made for alopex-0.3.3-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