mirror of
https://github.com/lancedb/lancedb.git
synced 2025-12-23 05:19:58 +00:00
Compare commits
25 Commits
python-v0.
...
python-v0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e4050e706 | ||
|
|
147796ffcd | ||
|
|
6fd465ceef | ||
|
|
e2e5a0fb83 | ||
|
|
ff8d5a6d51 | ||
|
|
8829988ada | ||
|
|
80a32be121 | ||
|
|
8325979bb8 | ||
|
|
ed5ff5a482 | ||
|
|
2c9371dcc4 | ||
|
|
6d5621da4a | ||
|
|
380c1572f3 | ||
|
|
4383848d53 | ||
|
|
473c43860c | ||
|
|
17cf244e53 | ||
|
|
0b60694df4 | ||
|
|
600da476e8 | ||
|
|
458217783c | ||
|
|
21b1a71a6b | ||
|
|
2d899675e8 | ||
|
|
1cbfc1bbf4 | ||
|
|
a2bb497135 | ||
|
|
0cf40c8da3 | ||
|
|
8233c689c3 | ||
|
|
6e24e731b8 |
@@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.1.15
|
current_version = 0.1.18
|
||||||
commit = True
|
commit = True
|
||||||
message = Bump version: {current_version} → {new_version}
|
message = Bump version: {current_version} → {new_version}
|
||||||
tag = True
|
tag = True
|
||||||
|
|||||||
65
.github/workflows/make-release-commit.yml
vendored
65
.github/workflows/make-release-commit.yml
vendored
@@ -25,38 +25,35 @@ jobs:
|
|||||||
bump-version:
|
bump-version:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out main
|
- name: Check out main
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: main
|
ref: main
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
lfs: true
|
lfs: true
|
||||||
- name: Set git configs for bumpversion
|
- name: Set git configs for bumpversion
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
git config user.name 'Lance Release'
|
git config user.name 'Lance Release'
|
||||||
git config user.email 'lance-dev@lancedb.com'
|
git config user.email 'lance-dev@lancedb.com'
|
||||||
- name: Set up Python 3.10
|
- name: Set up Python 3.10
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: "3.10"
|
||||||
- name: Bump version, create tag and commit
|
- name: Bump version, create tag and commit
|
||||||
run: |
|
run: |
|
||||||
pip install bump2version
|
pip install bump2version
|
||||||
bumpversion --verbose ${{ inputs.part }}
|
bumpversion --verbose ${{ inputs.part }}
|
||||||
- name: Update package-lock.json file
|
- name: Push new version and tag
|
||||||
run: |
|
if: ${{ inputs.dry_run }} == "false"
|
||||||
npm install
|
uses: ad-m/github-push-action@master
|
||||||
git add package-lock.json
|
with:
|
||||||
# Add this change to the commit created by bumpversion
|
github_token: ${{ secrets.LANCEDB_RELEASE_TOKEN }}
|
||||||
git commit --amend --no-edit
|
branch: main
|
||||||
working-directory: node
|
tags: true
|
||||||
- name: Push new version and tag
|
- uses: ./.github/workflows/update_package_lock
|
||||||
if: ${{ inputs.dry_run }} == "false"
|
if: ${{ inputs.dry_run }} == "false"
|
||||||
uses: ad-m/github-push-action@master
|
with:
|
||||||
with:
|
github_token: ${{ secrets.LANCEDB_RELEASE_TOKEN }}
|
||||||
github_token: ${{ secrets.LANCEDB_RELEASE_TOKEN }}
|
|
||||||
branch: main
|
|
||||||
tags: true
|
|
||||||
|
|
||||||
|
|||||||
4
.github/workflows/node.yml
vendored
4
.github/workflows/node.yml
vendored
@@ -70,7 +70,7 @@ jobs:
|
|||||||
npm run tsc
|
npm run tsc
|
||||||
npm run build
|
npm run build
|
||||||
npm run pack-build
|
npm run pack-build
|
||||||
npm install --no-save ./dist/vectordb-*.tgz
|
npm install --no-save ./dist/lancedb-vectordb-*.tgz
|
||||||
# Remove index.node to test with dependency installed
|
# Remove index.node to test with dependency installed
|
||||||
rm index.node
|
rm index.node
|
||||||
- name: Test
|
- name: Test
|
||||||
@@ -101,7 +101,7 @@ jobs:
|
|||||||
npm run tsc
|
npm run tsc
|
||||||
npm run build
|
npm run build
|
||||||
npm run pack-build
|
npm run pack-build
|
||||||
npm install --no-save ./dist/vectordb-*.tgz
|
npm install --no-save ./dist/lancedb-vectordb-*.tgz
|
||||||
# Remove index.node to test with dependency installed
|
# Remove index.node to test with dependency installed
|
||||||
rm index.node
|
rm index.node
|
||||||
- name: Test
|
- name: Test
|
||||||
|
|||||||
119
.github/workflows/npm-publish.yml
vendored
119
.github/workflows/npm-publish.yml
vendored
@@ -46,75 +46,51 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
target: [x86_64-apple-darwin, aarch64-apple-darwin]
|
target: [x86_64-apple-darwin, aarch64-apple-darwin]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Install system dependencies
|
- name: Install system dependencies
|
||||||
run: brew install protobuf
|
run: brew install protobuf
|
||||||
- name: Install npm dependencies
|
- name: Install npm dependencies
|
||||||
run: |
|
run: |
|
||||||
cd node
|
cd node
|
||||||
npm ci
|
npm ci
|
||||||
- name: Install rustup target
|
- name: Install rustup target
|
||||||
if: ${{ matrix.target == 'aarch64-apple-darwin' }}
|
if: ${{ matrix.target == 'aarch64-apple-darwin' }}
|
||||||
run: rustup target add aarch64-apple-darwin
|
run: rustup target add aarch64-apple-darwin
|
||||||
- name: Build MacOS native node modules
|
- name: Build MacOS native node modules
|
||||||
run: bash ci/build_macos_artifacts.sh ${{ matrix.target }}
|
run: bash ci/build_macos_artifacts.sh ${{ matrix.target }}
|
||||||
- name: Upload Darwin Artifacts
|
- name: Upload Darwin Artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: darwin-native
|
name: native-darwin
|
||||||
path: |
|
path: |
|
||||||
node/dist/vectordb-darwin*.tgz
|
node/dist/lancedb-vectordb-darwin*.tgz
|
||||||
|
|
||||||
node-linux:
|
node-linux:
|
||||||
name: node-linux (${{ matrix.arch}}-unknown-linux-${{ matrix.libc }})
|
name: node-linux (${{ matrix.config.arch}}-unknown-linux-gnu
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.config.runner }}
|
||||||
# Only runs on tags that matches the make-release action
|
# Only runs on tags that matches the make-release action
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
libc:
|
config:
|
||||||
- gnu
|
- arch: x86_64
|
||||||
# TODO: re-enable musl once we have refactored to pre-built containers
|
runner: ubuntu-latest
|
||||||
# Right now we have to build node from source which is too expensive.
|
- arch: aarch64
|
||||||
# - musl
|
runner: buildjet-4vcpu-ubuntu-2204-arm
|
||||||
arch:
|
|
||||||
- x86_64
|
|
||||||
# Building on aarch64 is too slow for now
|
|
||||||
# - aarch64
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Change owner to root (for npm)
|
- name: Build Linux Artifacts
|
||||||
# The docker container is run as root, so we need the files to be owned by root
|
run: |
|
||||||
# Otherwise npm is a nightmare: https://github.com/npm/cli/issues/3773
|
bash ci/build_linux_artifacts.sh ${{ matrix.config.arch }}
|
||||||
run: sudo chown -R root:root .
|
- name: Upload Linux Artifacts
|
||||||
- name: Set up QEMU
|
uses: actions/upload-artifact@v3
|
||||||
if: ${{ matrix.arch == 'aarch64' }}
|
with:
|
||||||
uses: docker/setup-qemu-action@v2
|
name: native-linux
|
||||||
with:
|
path: |
|
||||||
platforms: arm64
|
node/dist/lancedb-vectordb-linux*.tgz
|
||||||
- name: Build Linux GNU native node modules
|
|
||||||
if: ${{ matrix.libc == 'gnu' }}
|
|
||||||
run: |
|
|
||||||
docker run \
|
|
||||||
-v $(pwd):/io -w /io \
|
|
||||||
rust:1.70-bookworm \
|
|
||||||
bash ci/build_linux_artifacts.sh ${{ matrix.arch }}-unknown-linux-gnu
|
|
||||||
- name: Build musl Linux native node modules
|
|
||||||
if: ${{ matrix.libc == 'musl' }}
|
|
||||||
run: |
|
|
||||||
docker run --platform linux/arm64/v8 \
|
|
||||||
-v $(pwd):/io -w /io \
|
|
||||||
quay.io/pypa/musllinux_1_1_${{ matrix.arch }} \
|
|
||||||
bash ci/build_linux_artifacts.sh ${{ matrix.arch }}-unknown-linux-musl
|
|
||||||
- name: Upload Linux Artifacts
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: linux-native
|
|
||||||
path: |
|
|
||||||
node/dist/vectordb-linux*.tgz
|
|
||||||
|
|
||||||
node-windows:
|
node-windows:
|
||||||
runs-on: windows-2022
|
runs-on: windows-2022
|
||||||
@@ -145,12 +121,12 @@ jobs:
|
|||||||
- name: Upload Windows Artifacts
|
- name: Upload Windows Artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: windows-native
|
name: native-windows
|
||||||
path: |
|
path: |
|
||||||
node/dist/vectordb-win32*.tgz
|
node/dist/lancedb-vectordb-win32*.tgz
|
||||||
|
|
||||||
release:
|
release:
|
||||||
needs: [node, node-macos, node-linux]
|
needs: [node, node-macos, node-linux, node-windows]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Only runs on tags that matches the make-release action
|
# Only runs on tags that matches the make-release action
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
@@ -170,3 +146,18 @@ jobs:
|
|||||||
for filename in *.tgz; do
|
for filename in *.tgz; do
|
||||||
npm publish $filename
|
npm publish $filename
|
||||||
done
|
done
|
||||||
|
|
||||||
|
update-package-lock:
|
||||||
|
needs: [release]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: main
|
||||||
|
persist-credentials: false
|
||||||
|
fetch-depth: 0
|
||||||
|
lfs: true
|
||||||
|
- uses: ./.github/workflows/update_package_lock
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.LANCEDB_RELEASE_TOKEN }}
|
||||||
|
|||||||
33
.github/workflows/update_package_lock/action.yml
vendored
Normal file
33
.github/workflows/update_package_lock/action.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
name: update_package_lock
|
||||||
|
description: "Update node's package.lock"
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
github_token:
|
||||||
|
required: true
|
||||||
|
description: "github token for the repo"
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
- name: Set git configs
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
git config user.name 'Lance Release'
|
||||||
|
git config user.email 'lance-dev@lancedb.com'
|
||||||
|
- name: Update package-lock.json file
|
||||||
|
working-directory: ./node
|
||||||
|
run: |
|
||||||
|
npm install
|
||||||
|
git add package-lock.json
|
||||||
|
git commit -m "Updating package-lock.json"
|
||||||
|
shell: bash
|
||||||
|
- name: Push changes
|
||||||
|
if: ${{ inputs.dry_run }} == "false"
|
||||||
|
uses: ad-m/github-push-action@master
|
||||||
|
with:
|
||||||
|
github_token: ${{ inputs.github_token }}
|
||||||
|
branch: main
|
||||||
|
tags: true
|
||||||
19
.github/workflows/update_package_lock_run.yml
vendored
Normal file
19
.github/workflows/update_package_lock_run.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name: Update package-lock.json
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: main
|
||||||
|
persist-credentials: false
|
||||||
|
fetch-depth: 0
|
||||||
|
lfs: true
|
||||||
|
- uses: ./.github/workflows/update_package_lock
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.LANCEDB_RELEASE_TOKEN }}
|
||||||
@@ -6,7 +6,7 @@ members = [
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
lance = "=0.5.8"
|
lance = "=0.5.9"
|
||||||
arrow-array = "42.0"
|
arrow-array = "42.0"
|
||||||
arrow-data = "42.0"
|
arrow-data = "42.0"
|
||||||
arrow-schema = "42.0"
|
arrow-schema = "42.0"
|
||||||
|
|||||||
83
ci/build_linux_artifacts.sh
Normal file → Executable file
83
ci/build_linux_artifacts.sh
Normal file → Executable file
@@ -1,72 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Builds the Linux artifacts (node binaries).
|
|
||||||
# Usage: ./build_linux_artifacts.sh [target]
|
|
||||||
# Targets supported:
|
|
||||||
# - x86_64-unknown-linux-gnu:centos
|
|
||||||
# - aarch64-unknown-linux-gnu:centos
|
|
||||||
# - aarch64-unknown-linux-musl
|
|
||||||
# - x86_64-unknown-linux-musl
|
|
||||||
|
|
||||||
# TODO: refactor this into a Docker container we can pull
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
ARCH=${1:-x86_64}
|
||||||
|
|
||||||
setup_dependencies() {
|
# We pass down the current user so that when we later mount the local files
|
||||||
echo "Installing system dependencies..."
|
# into the container, the files are accessible by the current user.
|
||||||
if [[ $1 == *musl ]]; then
|
pushd ci/manylinux_node
|
||||||
# musllinux
|
docker build \
|
||||||
apk add openssl-dev
|
-t lancedb-node-manylinux \
|
||||||
else
|
--build-arg="ARCH=$ARCH" \
|
||||||
# rust / debian
|
--build-arg="DOCKER_USER=$(id -u)" \
|
||||||
apt update
|
--progress=plain \
|
||||||
apt install -y libssl-dev protobuf-compiler
|
.
|
||||||
fi
|
popd
|
||||||
}
|
|
||||||
|
|
||||||
install_node() {
|
docker run \
|
||||||
echo "Installing node..."
|
-v $(pwd):/io -w /io \
|
||||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
|
lancedb-node-manylinux \
|
||||||
source "$HOME"/.bashrc
|
bash ci/manylinux_node/build.sh $ARCH
|
||||||
|
|
||||||
if [[ $1 == *musl ]]; then
|
|
||||||
# This node version is 15, we need 16 or higher:
|
|
||||||
# apk add nodejs-current npm
|
|
||||||
# So instead we install from source (nvm doesn't provide binaries for musl):
|
|
||||||
nvm install -s --no-progress 17
|
|
||||||
else
|
|
||||||
nvm install --no-progress 17 # latest that supports glibc 2.17
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
build_node_binary() {
|
|
||||||
echo "Building node library for $1..."
|
|
||||||
pushd node
|
|
||||||
|
|
||||||
npm ci
|
|
||||||
|
|
||||||
if [[ $1 == *musl ]]; then
|
|
||||||
# This is needed for cargo to allow build cdylibs with musl
|
|
||||||
export RUSTFLAGS="-C target-feature=-crt-static"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Cargo can run out of memory while pulling dependencies, especially when running
|
|
||||||
# in QEMU. This is a workaround for that.
|
|
||||||
export CARGO_NET_GIT_FETCH_WITH_CLI=true
|
|
||||||
|
|
||||||
# We don't pass in target, since the native target here already matches
|
|
||||||
# We need to pass OPENSSL_LIB_DIR and OPENSSL_INCLUDE_DIR for static build to work https://github.com/sfackler/rust-openssl/issues/877
|
|
||||||
OPENSSL_STATIC=1 OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu OPENSSL_INCLUDE_DIR=/usr/include/openssl/ npm run build-release
|
|
||||||
npm run pack-build
|
|
||||||
|
|
||||||
popd
|
|
||||||
}
|
|
||||||
|
|
||||||
TARGET=${1:-x86_64-unknown-linux-gnu}
|
|
||||||
# Others:
|
|
||||||
# aarch64-unknown-linux-gnu
|
|
||||||
# x86_64-unknown-linux-musl
|
|
||||||
# aarch64-unknown-linux-musl
|
|
||||||
|
|
||||||
setup_dependencies $TARGET
|
|
||||||
install_node $TARGET
|
|
||||||
build_node_binary $TARGET
|
|
||||||
|
|||||||
31
ci/manylinux_node/Dockerfile
Normal file
31
ci/manylinux_node/Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# Many linux dockerfile with Rust, Node, and Lance dependencies installed.
|
||||||
|
# This container allows building the node modules native libraries in an
|
||||||
|
# environment with a very old glibc, so that we are compatible with a wide
|
||||||
|
# range of linux distributions.
|
||||||
|
ARG ARCH=x86_64
|
||||||
|
|
||||||
|
FROM quay.io/pypa/manylinux2014_${ARCH}
|
||||||
|
|
||||||
|
ARG ARCH=x86_64
|
||||||
|
ARG DOCKER_USER=default_user
|
||||||
|
|
||||||
|
# Install static openssl
|
||||||
|
COPY install_openssl.sh install_openssl.sh
|
||||||
|
RUN ./install_openssl.sh ${ARCH} > /dev/null
|
||||||
|
|
||||||
|
# Protobuf is also installed as root.
|
||||||
|
COPY install_protobuf.sh install_protobuf.sh
|
||||||
|
RUN ./install_protobuf.sh ${ARCH}
|
||||||
|
|
||||||
|
ENV DOCKER_USER=${DOCKER_USER}
|
||||||
|
# Create a group and user
|
||||||
|
RUN echo ${ARCH} && adduser --user-group --create-home --uid ${DOCKER_USER} build_user
|
||||||
|
|
||||||
|
# We switch to the user to install Rust and Node, since those like to be
|
||||||
|
# installed at the user level.
|
||||||
|
USER ${DOCKER_USER}
|
||||||
|
|
||||||
|
COPY prepare_manylinux_node.sh prepare_manylinux_node.sh
|
||||||
|
RUN cp /prepare_manylinux_node.sh $HOME/ && \
|
||||||
|
cd $HOME && \
|
||||||
|
./prepare_manylinux_node.sh ${ARCH}
|
||||||
19
ci/manylinux_node/build.sh
Executable file
19
ci/manylinux_node/build.sh
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Builds the node module for manylinux. Invoked by ci/build_linux_artifacts.sh.
|
||||||
|
set -e
|
||||||
|
ARCH=${1:-x86_64}
|
||||||
|
|
||||||
|
if [ "$ARCH" = "x86_64" ]; then
|
||||||
|
export OPENSSL_LIB_DIR=/usr/local/lib64/
|
||||||
|
else
|
||||||
|
export OPENSSL_LIB_DIR=/usr/local/lib/
|
||||||
|
fi
|
||||||
|
export OPENSSL_STATIC=1
|
||||||
|
export OPENSSL_INCLUDE_DIR=/usr/local/include/openssl
|
||||||
|
|
||||||
|
source $HOME/.bashrc
|
||||||
|
|
||||||
|
cd node
|
||||||
|
npm ci
|
||||||
|
npm run build-release
|
||||||
|
npm run pack-build
|
||||||
26
ci/manylinux_node/install_openssl.sh
Executable file
26
ci/manylinux_node/install_openssl.sh
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Builds openssl from source so we can statically link to it
|
||||||
|
|
||||||
|
# this is to avoid the error we get with the system installation:
|
||||||
|
# /usr/bin/ld: <library>: version node not found for symbol SSLeay@@OPENSSL_1.0.1
|
||||||
|
# /usr/bin/ld: failed to set dynamic section sizes: Bad value
|
||||||
|
set -e
|
||||||
|
|
||||||
|
git clone -b OpenSSL_1_1_1u \
|
||||||
|
--single-branch \
|
||||||
|
https://github.com/openssl/openssl.git
|
||||||
|
|
||||||
|
pushd openssl
|
||||||
|
|
||||||
|
if [[ $1 == x86_64* ]]; then
|
||||||
|
ARCH=linux-x86_64
|
||||||
|
else
|
||||||
|
# gnu target
|
||||||
|
ARCH=linux-aarch64
|
||||||
|
fi
|
||||||
|
|
||||||
|
./Configure no-shared $ARCH
|
||||||
|
|
||||||
|
make
|
||||||
|
|
||||||
|
make install
|
||||||
15
ci/manylinux_node/install_protobuf.sh
Executable file
15
ci/manylinux_node/install_protobuf.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Installs protobuf compiler. Should be run as root.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [[ $1 == x86_64* ]]; then
|
||||||
|
ARCH=x86_64
|
||||||
|
else
|
||||||
|
# gnu target
|
||||||
|
ARCH=aarch_64
|
||||||
|
fi
|
||||||
|
|
||||||
|
PB_REL=https://github.com/protocolbuffers/protobuf/releases
|
||||||
|
PB_VERSION=23.1
|
||||||
|
curl -LO $PB_REL/download/v$PB_VERSION/protoc-$PB_VERSION-linux-$ARCH.zip
|
||||||
|
unzip protoc-$PB_VERSION-linux-$ARCH.zip -d /usr/local
|
||||||
21
ci/manylinux_node/prepare_manylinux_node.sh
Executable file
21
ci/manylinux_node/prepare_manylinux_node.sh
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
install_node() {
|
||||||
|
echo "Installing node..."
|
||||||
|
|
||||||
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
|
||||||
|
|
||||||
|
source "$HOME"/.bashrc
|
||||||
|
|
||||||
|
nvm install --no-progress 16
|
||||||
|
}
|
||||||
|
|
||||||
|
install_rust() {
|
||||||
|
echo "Installing rust..."
|
||||||
|
curl https://sh.rustup.rs -sSf | bash -s -- -y
|
||||||
|
export PATH="$PATH:/root/.cargo/bin"
|
||||||
|
}
|
||||||
|
|
||||||
|
install_node
|
||||||
|
install_rust
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Vector embedding search using TransformersJS
|
# Vector embedding search using TransformersJS
|
||||||
|
|
||||||
## Embed and query data from LacneDB using TransformersJS
|
## Embed and query data from LanceDB using TransformersJS
|
||||||
|
|
||||||
<img id="splash" width="400" alt="transformersjs" src="https://github.com/lancedb/lancedb/assets/43097991/88a31e30-3d6f-4eef-9216-4b7c688f1b4f">
|
<img id="splash" width="400" alt="transformersjs" src="https://github.com/lancedb/lancedb/assets/43097991/88a31e30-3d6f-4eef-9216-4b7c688f1b4f">
|
||||||
|
|
||||||
|
|||||||
@@ -181,7 +181,7 @@
|
|||||||
"id": "c3852dd3",
|
"id": "c3852dd3",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"# Generating emebeddings from our docs\n",
|
"# Generating embeddings from our docs\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Now that we have our raw documents loaded, we need to pre-process them to generate embeddings:"
|
"Now that we have our raw documents loaded, we need to pre-process them to generate embeddings:"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const { currentTarget } = require('@neon-rs/load');
|
|||||||
let nativeLib;
|
let nativeLib;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
nativeLib = require(`vectordb-${currentTarget()}`);
|
nativeLib = require(`@lancedb/vectordb-${currentTarget()}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
try {
|
try {
|
||||||
// Might be developing locally, so try that. But don't expose that error
|
// Might be developing locally, so try that. But don't expose that error
|
||||||
@@ -25,12 +25,12 @@ try {
|
|||||||
nativeLib = require("./index.node");
|
nativeLib = require("./index.node");
|
||||||
} catch {
|
} catch {
|
||||||
throw new Error(`vectordb: failed to load native library.
|
throw new Error(`vectordb: failed to load native library.
|
||||||
You may need to run \`npm install vectordb-${currentTarget()}\`.
|
You may need to run \`npm install @lancedb/vectordb-${currentTarget()}\`.
|
||||||
|
|
||||||
If that does not work, please file a bug report at https://github.com/lancedb/lancedb/issues
|
If that does not work, please file a bug report at https://github.com/lancedb/lancedb/issues
|
||||||
|
|
||||||
Source error: ${e}`);
|
Source error: ${e}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dynamic require for runtime.
|
// Dynamic require for runtime.
|
||||||
|
|||||||
278
node/package-lock.json
generated
278
node/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "vectordb",
|
"name": "vectordb",
|
||||||
"version": "0.1.15",
|
"version": "0.1.18",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "vectordb",
|
"name": "vectordb",
|
||||||
"version": "0.1.15",
|
"version": "0.1.18",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64",
|
"x64",
|
||||||
"arm64"
|
"arm64"
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"axios": "^1.4.0"
|
"axios": "^1.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@neon-rs/cli": "^0.0.74",
|
"@neon-rs/cli": "^0.0.160",
|
||||||
"@types/chai": "^4.3.4",
|
"@types/chai": "^4.3.4",
|
||||||
"@types/chai-as-promised": "^7.1.5",
|
"@types/chai-as-promised": "^7.1.5",
|
||||||
"@types/mocha": "^10.0.1",
|
"@types/mocha": "^10.0.1",
|
||||||
@@ -51,11 +51,11 @@
|
|||||||
"typescript": "*"
|
"typescript": "*"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"vectordb-darwin-arm64": "0.1.15",
|
"@lancedb/vectordb-darwin-arm64": "0.1.18",
|
||||||
"vectordb-darwin-x64": "0.1.15",
|
"@lancedb/vectordb-darwin-x64": "0.1.18",
|
||||||
"vectordb-linux-arm64-gnu": "0.1.15",
|
"@lancedb/vectordb-linux-arm64-gnu": "0.1.18",
|
||||||
"vectordb-linux-x64-gnu": "0.1.15",
|
"@lancedb/vectordb-linux-x64-gnu": "0.1.18",
|
||||||
"vectordb-win32-x64-msvc": "0.1.15"
|
"@lancedb/vectordb-win32-x64-msvc": "0.1.18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@apache-arrow/ts": {
|
"node_modules/@apache-arrow/ts": {
|
||||||
@@ -85,6 +85,97 @@
|
|||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||||
},
|
},
|
||||||
|
"node_modules/@cargo-messages/android-arm-eabi": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/android-arm-eabi/-/android-arm-eabi-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-PTgCEmBHEPKJbxwlHVXB3aGES+NqpeBvn6hJNYWIkET3ZQCSJnScMlIDQXEkWndK7J+hW3Or3H32a93B/MbbfQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"android"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@cargo-messages/darwin-arm64": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/darwin-arm64/-/darwin-arm64-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-YSVUuc8TUTi/XmZVg9KrH0bDywKLqC1zeTyZYAYDDmqVDZW9KeTnbBUECKRs56iyHeO+kuEkVW7MKf7j2zb/FA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@cargo-messages/darwin-x64": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/darwin-x64/-/darwin-x64-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-U+YlAR+9tKpBljnNPWMop5YhvtwfIPQSAaUYN2llteC7ZNU5/cv8CGT1vm7uFNxr2LeGuAtRbzIh2gUmTV8mng==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@cargo-messages/linux-arm-gnueabihf": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/linux-arm-gnueabihf/-/linux-arm-gnueabihf-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-wqAelTzVv1E7Ls4aviqUbem5xjzCaJQxQtVnLhv6pf1k0UyEHCS2WdufFFmWcojGe7QglI4uve3KTe01MKYj0A==",
|
||||||
|
"cpu": [
|
||||||
|
"arm"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@cargo-messages/linux-x64-gnu": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/linux-x64-gnu/-/linux-x64-gnu-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-LQ6e7O7YYkWfDNIi/53q2QG/+lZok72LOG+NKDVCrrY4TYUcrTqWAybOV6IlkVntKPnpx8YB95umSQGeVuvhpQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@cargo-messages/win32-arm64-msvc": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/win32-arm64-msvc/-/win32-arm64-msvc-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-VDMBhyun02gIDwmEhkYP1W9Z0tYqn4drgY5Iua1qV2tYOU58RVkWhzUYxM9rzYbnwKZlltgM46J/j5QZ3VaFrA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@cargo-messages/win32-x64-msvc": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/win32-x64-msvc/-/win32-x64-msvc-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-vnoglDxF6zj0W/Co9D0H/bgnrhUuO5EumIf9v3ujLtBH94rAX11JsXh/FgC/8wQnQSsLyWSq70YxNS2wdETxjA==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
"node_modules/@cspotcode/source-map-support": {
|
"node_modules/@cspotcode/source-map-support": {
|
||||||
"version": "0.8.1",
|
"version": "0.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
|
||||||
@@ -223,13 +314,82 @@
|
|||||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@lancedb/vectordb-darwin-arm64": {
|
||||||
|
"version": "0.1.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.1.18.tgz",
|
||||||
|
"integrity": "sha512-vu8MCFgaAAGmTJF+4RaoApROMpRVVgrCk+V9my4adAfWkkXbSmtxiDgiIwwL1VqdGb8UwzGn3kVbNW7idE1ojA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@lancedb/vectordb-darwin-x64": {
|
||||||
|
"version": "0.1.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-darwin-x64/-/vectordb-darwin-x64-0.1.18.tgz",
|
||||||
|
"integrity": "sha512-ZU30bd6frRyKJ515ow972PlqO2wIiNT4Ohor9+KbUwl/VKDyAwKOKG8cWhRJXTxk0k1oqpiJ6+Q28TcYJ0sSAw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@lancedb/vectordb-linux-arm64-gnu": {
|
||||||
|
"version": "0.1.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-linux-arm64-gnu/-/vectordb-linux-arm64-gnu-0.1.18.tgz",
|
||||||
|
"integrity": "sha512-2UroC026bUYwyciSRonYlXei0SoYbKgfWpozxYOu7GgBAV2CQQtaAPgWJTEl6ZiCNeBmBTx+j0h3+ydUfZA73Q==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@lancedb/vectordb-linux-x64-gnu": {
|
||||||
|
"version": "0.1.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-linux-x64-gnu/-/vectordb-linux-x64-gnu-0.1.18.tgz",
|
||||||
|
"integrity": "sha512-DoQBskl22JAJFZh219ZOJ6o+f1niTZp0qRYngHa/kTIpLKzHWQ0OTtMCz32VBAjAsKjSLNxHE8rrT/S6tvS7KQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@lancedb/vectordb-win32-x64-msvc": {
|
||||||
|
"version": "0.1.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-win32-x64-msvc/-/vectordb-win32-x64-msvc-0.1.18.tgz",
|
||||||
|
"integrity": "sha512-a/kUM3V6rWuXS80pPECYxKfCUAnq56Of/GPCvnAkpk9C9ldyX10iff4aA6DiPHjEk9V2ytqDfJKl9N3QcMLKLA==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
"node_modules/@neon-rs/cli": {
|
"node_modules/@neon-rs/cli": {
|
||||||
"version": "0.0.74",
|
"version": "0.0.160",
|
||||||
"resolved": "https://registry.npmjs.org/@neon-rs/cli/-/cli-0.0.74.tgz",
|
"resolved": "https://registry.npmjs.org/@neon-rs/cli/-/cli-0.0.160.tgz",
|
||||||
"integrity": "sha512-9lPmNmjej5iKKOTMPryOMubwkgMRyTWRuaq1yokASvI5mPhr2kzPN7UVjdCOjQvpunNPngR9yAHoirpjiWhUHw==",
|
"integrity": "sha512-GQjzHPJVTOARbX3nP/fAWqBq7JlQ8XgfYlCa+iwzIXf0LC1EyfJTX+vqGD/36b9lKoyY01Z/aDUB9o/qF6ztHA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"neon": "index.js"
|
"neon": "index.js"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@cargo-messages/android-arm-eabi": "0.0.160",
|
||||||
|
"@cargo-messages/darwin-arm64": "0.0.160",
|
||||||
|
"@cargo-messages/darwin-x64": "0.0.160",
|
||||||
|
"@cargo-messages/linux-arm-gnueabihf": "0.0.160",
|
||||||
|
"@cargo-messages/linux-x64-gnu": "0.0.160",
|
||||||
|
"@cargo-messages/win32-arm64-msvc": "0.0.160",
|
||||||
|
"@cargo-messages/win32-x64-msvc": "0.0.160"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@neon-rs/load": {
|
"node_modules/@neon-rs/load": {
|
||||||
@@ -4542,6 +4702,55 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@cargo-messages/android-arm-eabi": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/android-arm-eabi/-/android-arm-eabi-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-PTgCEmBHEPKJbxwlHVXB3aGES+NqpeBvn6hJNYWIkET3ZQCSJnScMlIDQXEkWndK7J+hW3Or3H32a93B/MbbfQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@cargo-messages/darwin-arm64": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/darwin-arm64/-/darwin-arm64-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-YSVUuc8TUTi/XmZVg9KrH0bDywKLqC1zeTyZYAYDDmqVDZW9KeTnbBUECKRs56iyHeO+kuEkVW7MKf7j2zb/FA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@cargo-messages/darwin-x64": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/darwin-x64/-/darwin-x64-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-U+YlAR+9tKpBljnNPWMop5YhvtwfIPQSAaUYN2llteC7ZNU5/cv8CGT1vm7uFNxr2LeGuAtRbzIh2gUmTV8mng==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@cargo-messages/linux-arm-gnueabihf": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/linux-arm-gnueabihf/-/linux-arm-gnueabihf-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-wqAelTzVv1E7Ls4aviqUbem5xjzCaJQxQtVnLhv6pf1k0UyEHCS2WdufFFmWcojGe7QglI4uve3KTe01MKYj0A==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@cargo-messages/linux-x64-gnu": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/linux-x64-gnu/-/linux-x64-gnu-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-LQ6e7O7YYkWfDNIi/53q2QG/+lZok72LOG+NKDVCrrY4TYUcrTqWAybOV6IlkVntKPnpx8YB95umSQGeVuvhpQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@cargo-messages/win32-arm64-msvc": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/win32-arm64-msvc/-/win32-arm64-msvc-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-VDMBhyun02gIDwmEhkYP1W9Z0tYqn4drgY5Iua1qV2tYOU58RVkWhzUYxM9rzYbnwKZlltgM46J/j5QZ3VaFrA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@cargo-messages/win32-x64-msvc": {
|
||||||
|
"version": "0.0.160",
|
||||||
|
"resolved": "https://registry.npmjs.org/@cargo-messages/win32-x64-msvc/-/win32-x64-msvc-0.0.160.tgz",
|
||||||
|
"integrity": "sha512-vnoglDxF6zj0W/Co9D0H/bgnrhUuO5EumIf9v3ujLtBH94rAX11JsXh/FgC/8wQnQSsLyWSq70YxNS2wdETxjA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"@cspotcode/source-map-support": {
|
"@cspotcode/source-map-support": {
|
||||||
"version": "0.8.1",
|
"version": "0.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
|
||||||
@@ -4642,11 +4851,50 @@
|
|||||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@lancedb/vectordb-darwin-arm64": {
|
||||||
|
"version": "0.1.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.1.18.tgz",
|
||||||
|
"integrity": "sha512-vu8MCFgaAAGmTJF+4RaoApROMpRVVgrCk+V9my4adAfWkkXbSmtxiDgiIwwL1VqdGb8UwzGn3kVbNW7idE1ojA==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@lancedb/vectordb-darwin-x64": {
|
||||||
|
"version": "0.1.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-darwin-x64/-/vectordb-darwin-x64-0.1.18.tgz",
|
||||||
|
"integrity": "sha512-ZU30bd6frRyKJ515ow972PlqO2wIiNT4Ohor9+KbUwl/VKDyAwKOKG8cWhRJXTxk0k1oqpiJ6+Q28TcYJ0sSAw==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@lancedb/vectordb-linux-arm64-gnu": {
|
||||||
|
"version": "0.1.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-linux-arm64-gnu/-/vectordb-linux-arm64-gnu-0.1.18.tgz",
|
||||||
|
"integrity": "sha512-2UroC026bUYwyciSRonYlXei0SoYbKgfWpozxYOu7GgBAV2CQQtaAPgWJTEl6ZiCNeBmBTx+j0h3+ydUfZA73Q==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@lancedb/vectordb-linux-x64-gnu": {
|
||||||
|
"version": "0.1.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-linux-x64-gnu/-/vectordb-linux-x64-gnu-0.1.18.tgz",
|
||||||
|
"integrity": "sha512-DoQBskl22JAJFZh219ZOJ6o+f1niTZp0qRYngHa/kTIpLKzHWQ0OTtMCz32VBAjAsKjSLNxHE8rrT/S6tvS7KQ==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@lancedb/vectordb-win32-x64-msvc": {
|
||||||
|
"version": "0.1.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-win32-x64-msvc/-/vectordb-win32-x64-msvc-0.1.18.tgz",
|
||||||
|
"integrity": "sha512-a/kUM3V6rWuXS80pPECYxKfCUAnq56Of/GPCvnAkpk9C9ldyX10iff4aA6DiPHjEk9V2ytqDfJKl9N3QcMLKLA==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"@neon-rs/cli": {
|
"@neon-rs/cli": {
|
||||||
"version": "0.0.74",
|
"version": "0.0.160",
|
||||||
"resolved": "https://registry.npmjs.org/@neon-rs/cli/-/cli-0.0.74.tgz",
|
"resolved": "https://registry.npmjs.org/@neon-rs/cli/-/cli-0.0.160.tgz",
|
||||||
"integrity": "sha512-9lPmNmjej5iKKOTMPryOMubwkgMRyTWRuaq1yokASvI5mPhr2kzPN7UVjdCOjQvpunNPngR9yAHoirpjiWhUHw==",
|
"integrity": "sha512-GQjzHPJVTOARbX3nP/fAWqBq7JlQ8XgfYlCa+iwzIXf0LC1EyfJTX+vqGD/36b9lKoyY01Z/aDUB9o/qF6ztHA==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@cargo-messages/android-arm-eabi": "0.0.160",
|
||||||
|
"@cargo-messages/darwin-arm64": "0.0.160",
|
||||||
|
"@cargo-messages/darwin-x64": "0.0.160",
|
||||||
|
"@cargo-messages/linux-arm-gnueabihf": "0.0.160",
|
||||||
|
"@cargo-messages/linux-x64-gnu": "0.0.160",
|
||||||
|
"@cargo-messages/win32-arm64-msvc": "0.0.160",
|
||||||
|
"@cargo-messages/win32-x64-msvc": "0.0.160"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"@neon-rs/load": {
|
"@neon-rs/load": {
|
||||||
"version": "0.0.74",
|
"version": "0.0.74",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vectordb",
|
"name": "vectordb",
|
||||||
"version": "0.1.15",
|
"version": "0.1.18",
|
||||||
"description": " Serverless, low-latency vector database for AI applications",
|
"description": " Serverless, low-latency vector database for AI applications",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"author": "Lance Devs",
|
"author": "Lance Devs",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@neon-rs/cli": "^0.0.74",
|
"@neon-rs/cli": "^0.0.160",
|
||||||
"@types/chai": "^4.3.4",
|
"@types/chai": "^4.3.4",
|
||||||
"@types/chai-as-promised": "^7.1.5",
|
"@types/chai-as-promised": "^7.1.5",
|
||||||
"@types/mocha": "^10.0.1",
|
"@types/mocha": "^10.0.1",
|
||||||
@@ -70,18 +70,18 @@
|
|||||||
],
|
],
|
||||||
"neon": {
|
"neon": {
|
||||||
"targets": {
|
"targets": {
|
||||||
"x86_64-apple-darwin": "vectordb-darwin-x64",
|
"x86_64-apple-darwin": "@lancedb/vectordb-darwin-x64",
|
||||||
"aarch64-apple-darwin": "vectordb-darwin-arm64",
|
"aarch64-apple-darwin": "@lancedb/vectordb-darwin-arm64",
|
||||||
"x86_64-unknown-linux-gnu": "vectordb-linux-x64-gnu",
|
"x86_64-unknown-linux-gnu": "@lancedb/vectordb-linux-x64-gnu",
|
||||||
"aarch64-unknown-linux-gnu": "vectordb-linux-arm64-gnu",
|
"aarch64-unknown-linux-gnu": "@lancedb/vectordb-linux-arm64-gnu",
|
||||||
"x86_64-pc-windows-msvc": "vectordb-win32-x64-msvc"
|
"x86_64-pc-windows-msvc": "@lancedb/vectordb-win32-x64-msvc"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"vectordb-darwin-arm64": "0.1.15",
|
"@lancedb/vectordb-darwin-arm64": "0.1.18",
|
||||||
"vectordb-darwin-x64": "0.1.15",
|
"@lancedb/vectordb-darwin-x64": "0.1.18",
|
||||||
"vectordb-linux-arm64-gnu": "0.1.15",
|
"@lancedb/vectordb-linux-arm64-gnu": "0.1.18",
|
||||||
"vectordb-linux-x64-gnu": "0.1.15",
|
"@lancedb/vectordb-linux-x64-gnu": "0.1.18",
|
||||||
"vectordb-win32-x64-msvc": "0.1.15"
|
"@lancedb/vectordb-win32-x64-msvc": "0.1.18"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,3 +26,9 @@ export interface EmbeddingFunction<T> {
|
|||||||
*/
|
*/
|
||||||
embed: (data: T[]) => Promise<number[][]>
|
embed: (data: T[]) => Promise<number[][]>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isEmbeddingFunction<T> (value: any): value is EmbeddingFunction<T> {
|
||||||
|
return Object.keys(value).length === 2 &&
|
||||||
|
typeof value.sourceColumn === 'string' &&
|
||||||
|
typeof value.embed === 'function'
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,10 +20,12 @@ import { fromRecordsToBuffer } from './arrow'
|
|||||||
import type { EmbeddingFunction } from './embedding/embedding_function'
|
import type { EmbeddingFunction } from './embedding/embedding_function'
|
||||||
import { RemoteConnection } from './remote'
|
import { RemoteConnection } from './remote'
|
||||||
import { Query } from './query'
|
import { Query } from './query'
|
||||||
|
import { isEmbeddingFunction } from './embedding/embedding_function'
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const { databaseNew, databaseTableNames, databaseOpenTable, databaseDropTable, tableCreate, tableAdd, tableCreateVectorIndex, tableCountRows, tableDelete } = require('../native.js')
|
const { databaseNew, databaseTableNames, databaseOpenTable, databaseDropTable, tableCreate, tableAdd, tableCreateVectorIndex, tableCountRows, tableDelete } = require('../native.js')
|
||||||
|
|
||||||
|
export { Query }
|
||||||
export type { EmbeddingFunction }
|
export type { EmbeddingFunction }
|
||||||
export { OpenAIEmbeddingFunction } from './embedding/openai'
|
export { OpenAIEmbeddingFunction } from './embedding/openai'
|
||||||
|
|
||||||
@@ -100,10 +102,35 @@ export interface Connection {
|
|||||||
*
|
*
|
||||||
* @param {string} name - The name of the table.
|
* @param {string} name - The name of the table.
|
||||||
* @param data - Non-empty Array of Records to be inserted into the table
|
* @param data - Non-empty Array of Records to be inserted into the table
|
||||||
* @param {WriteMode} mode - The write mode to use when creating the table.
|
*/
|
||||||
|
createTable (name: string, data: Array<Record<string, unknown>>): Promise<Table>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Table and initialize it with new data.
|
||||||
|
*
|
||||||
|
* @param {string} name - The name of the table.
|
||||||
|
* @param data - Non-empty Array of Records to be inserted into the table
|
||||||
|
* @param {WriteOptions} options - The write options to use when creating the table.
|
||||||
|
*/
|
||||||
|
createTable (name: string, data: Array<Record<string, unknown>>, options: WriteOptions): Promise<Table>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Table and initialize it with new data.
|
||||||
|
*
|
||||||
|
* @param {string} name - The name of the table.
|
||||||
|
* @param data - Non-empty Array of Records to be inserted into the table
|
||||||
* @param {EmbeddingFunction} embeddings - An embedding function to use on this table
|
* @param {EmbeddingFunction} embeddings - An embedding function to use on this table
|
||||||
*/
|
*/
|
||||||
createTable<T>(name: string, data: Array<Record<string, unknown>>, mode?: WriteMode, embeddings?: EmbeddingFunction<T>): Promise<Table<T>>
|
createTable<T> (name: string, data: Array<Record<string, unknown>>, embeddings: EmbeddingFunction<T>): Promise<Table<T>>
|
||||||
|
/**
|
||||||
|
* Creates a new Table and initialize it with new data.
|
||||||
|
*
|
||||||
|
* @param {string} name - The name of the table.
|
||||||
|
* @param data - Non-empty Array of Records to be inserted into the table
|
||||||
|
* @param {EmbeddingFunction} embeddings - An embedding function to use on this table
|
||||||
|
* @param {WriteOptions} options - The write options to use when creating the table.
|
||||||
|
*/
|
||||||
|
createTable<T> (name: string, data: Array<Record<string, unknown>>, embeddings: EmbeddingFunction<T>, options: WriteOptions): Promise<Table<T>>
|
||||||
|
|
||||||
createTableArrow(name: string, table: ArrowTable): Promise<Table>
|
createTableArrow(name: string, table: ArrowTable): Promise<Table>
|
||||||
|
|
||||||
@@ -237,32 +264,19 @@ export class LocalConnection implements Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
async createTable<T> (name: string, data: Array<Record<string, unknown>>, optsOrEmbedding?: WriteOptions | EmbeddingFunction<T>, opt?: WriteOptions): Promise<Table<T>> {
|
||||||
* Creates a new Table and initialize it with new data.
|
let writeOptions: WriteOptions = new DefaultWriteOptions()
|
||||||
*
|
if (opt !== undefined && isWriteOptions(opt)) {
|
||||||
* @param name The name of the table.
|
writeOptions = opt
|
||||||
* @param data Non-empty Array of Records to be inserted into the Table
|
} else if (optsOrEmbedding !== undefined && isWriteOptions(optsOrEmbedding)) {
|
||||||
* @param mode The write mode to use when creating the table.
|
writeOptions = optsOrEmbedding
|
||||||
*/
|
|
||||||
async createTable (name: string, data: Array<Record<string, unknown>>, mode?: WriteMode): Promise<Table>
|
|
||||||
async createTable (name: string, data: Array<Record<string, unknown>>, mode: WriteMode): Promise<Table>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new Table and initialize it with new data.
|
|
||||||
*
|
|
||||||
* @param name The name of the table.
|
|
||||||
* @param data Non-empty Array of Records to be inserted into the Table
|
|
||||||
* @param mode The write mode to use when creating the table.
|
|
||||||
* @param embeddings An embedding function to use on this Table
|
|
||||||
*/
|
|
||||||
async createTable<T> (name: string, data: Array<Record<string, unknown>>, mode: WriteMode, embeddings: EmbeddingFunction<T>): Promise<Table<T>>
|
|
||||||
async createTable<T> (name: string, data: Array<Record<string, unknown>>, mode: WriteMode, embeddings?: EmbeddingFunction<T>): Promise<Table<T>>
|
|
||||||
async createTable<T> (name: string, data: Array<Record<string, unknown>>, mode: WriteMode, embeddings?: EmbeddingFunction<T>): Promise<Table<T>> {
|
|
||||||
if (mode === undefined) {
|
|
||||||
mode = WriteMode.Create
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const createArgs = [this._db, name, await fromRecordsToBuffer(data, embeddings), mode.toLowerCase()]
|
let embeddings: undefined | EmbeddingFunction<T>
|
||||||
|
if (optsOrEmbedding !== undefined && isEmbeddingFunction(optsOrEmbedding)) {
|
||||||
|
embeddings = optsOrEmbedding
|
||||||
|
}
|
||||||
|
const createArgs = [this._db, name, await fromRecordsToBuffer(data, embeddings), writeOptions.writeMode?.toString()]
|
||||||
if (this._options.awsCredentials !== undefined) {
|
if (this._options.awsCredentials !== undefined) {
|
||||||
createArgs.push(this._options.awsCredentials.accessKeyId)
|
createArgs.push(this._options.awsCredentials.accessKeyId)
|
||||||
createArgs.push(this._options.awsCredentials.secretKey)
|
createArgs.push(this._options.awsCredentials.secretKey)
|
||||||
@@ -459,6 +473,23 @@ export enum WriteMode {
|
|||||||
Append = 'append'
|
Append = 'append'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write options when creating a Table.
|
||||||
|
*/
|
||||||
|
export interface WriteOptions {
|
||||||
|
/** A {@link WriteMode} to use on this operation */
|
||||||
|
writeMode?: WriteMode
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DefaultWriteOptions implements WriteOptions {
|
||||||
|
writeMode = WriteMode.Create
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isWriteOptions (value: any): value is WriteOptions {
|
||||||
|
return Object.keys(value).length === 1 &&
|
||||||
|
(value.writeMode === undefined || typeof value.writeMode === 'string')
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Distance metrics type.
|
* Distance metrics type.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,13 +18,15 @@ import { tableFromIPC, type Table as ArrowTable } from 'apache-arrow'
|
|||||||
|
|
||||||
export class HttpLancedbClient {
|
export class HttpLancedbClient {
|
||||||
private readonly _url: string
|
private readonly _url: string
|
||||||
|
private readonly _apiKey: () => string
|
||||||
|
|
||||||
public constructor (
|
public constructor (
|
||||||
url: string,
|
url: string,
|
||||||
private readonly _apiKey: string,
|
apiKey: string,
|
||||||
private readonly _dbName?: string
|
private readonly _dbName?: string
|
||||||
) {
|
) {
|
||||||
this._url = url
|
this._url = url
|
||||||
|
this._apiKey = () => apiKey
|
||||||
}
|
}
|
||||||
|
|
||||||
get uri (): string {
|
get uri (): string {
|
||||||
@@ -41,7 +43,7 @@ export class HttpLancedbClient {
|
|||||||
filter?: string
|
filter?: string
|
||||||
): Promise<ArrowTable<any>> {
|
): Promise<ArrowTable<any>> {
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
`${this._url}/v1/table/${tableName}`,
|
`${this._url}/v1/table/${tableName}/query/`,
|
||||||
{
|
{
|
||||||
vector,
|
vector,
|
||||||
k,
|
k,
|
||||||
@@ -53,7 +55,7 @@ export class HttpLancedbClient {
|
|||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'x-api-key': this._apiKey,
|
'x-api-key': this._apiKey(),
|
||||||
...(this._dbName !== undefined ? { 'x-lancedb-database': this._dbName } : {})
|
...(this._dbName !== undefined ? { 'x-lancedb-database': this._dbName } : {})
|
||||||
},
|
},
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
@@ -84,7 +86,7 @@ export class HttpLancedbClient {
|
|||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'x-api-key': this._apiKey
|
'x-api-key': this._apiKey()
|
||||||
},
|
},
|
||||||
params,
|
params,
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ import * as chai from 'chai'
|
|||||||
import * as chaiAsPromised from 'chai-as-promised'
|
import * as chaiAsPromised from 'chai-as-promised'
|
||||||
|
|
||||||
import * as lancedb from '../index'
|
import * as lancedb from '../index'
|
||||||
import { type AwsCredentials, type EmbeddingFunction, MetricType, WriteMode } from '../index'
|
import { type AwsCredentials, type EmbeddingFunction, MetricType, Query, WriteMode, DefaultWriteOptions, isWriteOptions } from '../index'
|
||||||
import { Query } from '../query'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
const assert = chai.assert
|
const assert = chai.assert
|
||||||
@@ -145,7 +144,7 @@ describe('LanceDB client', function () {
|
|||||||
]
|
]
|
||||||
|
|
||||||
const tableName = 'overwrite'
|
const tableName = 'overwrite'
|
||||||
await con.createTable(tableName, data, WriteMode.Create)
|
await con.createTable(tableName, data, { writeMode: WriteMode.Create })
|
||||||
|
|
||||||
const newData = [
|
const newData = [
|
||||||
{ id: 1, vector: [0.1, 0.2], price: 10 },
|
{ id: 1, vector: [0.1, 0.2], price: 10 },
|
||||||
@@ -155,7 +154,7 @@ describe('LanceDB client', function () {
|
|||||||
|
|
||||||
await expect(con.createTable(tableName, newData)).to.be.rejectedWith(Error, 'already exists')
|
await expect(con.createTable(tableName, newData)).to.be.rejectedWith(Error, 'already exists')
|
||||||
|
|
||||||
const table = await con.createTable(tableName, newData, WriteMode.Overwrite)
|
const table = await con.createTable(tableName, newData, { writeMode: WriteMode.Overwrite })
|
||||||
assert.equal(table.name, tableName)
|
assert.equal(table.name, tableName)
|
||||||
assert.equal(await table.countRows(), 3)
|
assert.equal(await table.countRows(), 3)
|
||||||
})
|
})
|
||||||
@@ -260,7 +259,7 @@ describe('LanceDB client', function () {
|
|||||||
{ price: 10, name: 'foo' },
|
{ price: 10, name: 'foo' },
|
||||||
{ price: 50, name: 'bar' }
|
{ price: 50, name: 'bar' }
|
||||||
]
|
]
|
||||||
const table = await con.createTable('vectors', data, WriteMode.Create, embeddings)
|
const table = await con.createTable('vectors', data, embeddings, { writeMode: WriteMode.Create })
|
||||||
const results = await table.search('foo').execute()
|
const results = await table.search('foo').execute()
|
||||||
assert.equal(results.length, 2)
|
assert.equal(results.length, 2)
|
||||||
})
|
})
|
||||||
@@ -318,3 +317,20 @@ describe('Drop table', function () {
|
|||||||
assert.deepEqual(await con.tableNames(), ['t2'])
|
assert.deepEqual(await con.tableNames(), ['t2'])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('WriteOptions', function () {
|
||||||
|
context('#isWriteOptions', function () {
|
||||||
|
it('should not match empty object', function () {
|
||||||
|
assert.equal(isWriteOptions({}), false)
|
||||||
|
})
|
||||||
|
it('should match write options', function () {
|
||||||
|
assert.equal(isWriteOptions({ writeMode: WriteMode.Create }), true)
|
||||||
|
})
|
||||||
|
it('should match undefined write mode', function () {
|
||||||
|
assert.equal(isWriteOptions({ writeMode: undefined }), true)
|
||||||
|
})
|
||||||
|
it('should match default write options', function () {
|
||||||
|
assert.equal(isWriteOptions(new DefaultWriteOptions()), true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.1.13
|
current_version = 0.1.15
|
||||||
commit = True
|
commit = True
|
||||||
message = [python] Bump version: {current_version} → {new_version}
|
message = [python] Bump version: {current_version} → {new_version}
|
||||||
tag = True
|
tag = True
|
||||||
|
|||||||
@@ -19,7 +19,11 @@ from .schema import vector
|
|||||||
|
|
||||||
|
|
||||||
def connect(
|
def connect(
|
||||||
uri: URI, *, api_key: Optional[str] = None, region: str = "us-west-2"
|
uri: URI,
|
||||||
|
*,
|
||||||
|
api_key: Optional[str] = None,
|
||||||
|
region: str = "us-west-2",
|
||||||
|
host_override: Optional[str] = None,
|
||||||
) -> DBConnection:
|
) -> DBConnection:
|
||||||
"""Connect to a LanceDB database.
|
"""Connect to a LanceDB database.
|
||||||
|
|
||||||
@@ -55,5 +59,5 @@ def connect(
|
|||||||
if isinstance(uri, str) and uri.startswith("db://"):
|
if isinstance(uri, str) and uri.startswith("db://"):
|
||||||
if api_key is None:
|
if api_key is None:
|
||||||
raise ValueError(f"api_key is required to connected LanceDB cloud: {uri}")
|
raise ValueError(f"api_key is required to connected LanceDB cloud: {uri}")
|
||||||
return RemoteDBConnection(uri, api_key, region)
|
return RemoteDBConnection(uri, api_key, region, host_override)
|
||||||
return LanceDBConnection(uri)
|
return LanceDBConnection(uri)
|
||||||
|
|||||||
@@ -327,6 +327,6 @@ class LanceDBConnection(DBConnection):
|
|||||||
name: str
|
name: str
|
||||||
The name of the table.
|
The name of the table.
|
||||||
"""
|
"""
|
||||||
filesystem, path = pa.fs.FileSystem.from_uri(self.uri)
|
filesystem, path = fs_from_uri(self.uri)
|
||||||
table_path = os.path.join(path, name + ".lance")
|
table_path = os.path.join(path, name + ".lance")
|
||||||
filesystem.delete_dir(table_path)
|
filesystem.delete_dir(table_path)
|
||||||
|
|||||||
@@ -48,11 +48,16 @@ class RestfulLanceDBClient:
|
|||||||
db_name: str
|
db_name: str
|
||||||
region: str
|
region: str
|
||||||
api_key: Credential
|
api_key: Credential
|
||||||
|
host_override: Optional[str] = attr.field(default=None)
|
||||||
|
|
||||||
closed: bool = attr.field(default=False, init=False)
|
closed: bool = attr.field(default=False, init=False)
|
||||||
|
|
||||||
@functools.cached_property
|
@functools.cached_property
|
||||||
def session(self) -> aiohttp.ClientSession:
|
def session(self) -> aiohttp.ClientSession:
|
||||||
url = f"https://{self.db_name}.{self.region}.api.lancedb.com"
|
url = (
|
||||||
|
self.host_override
|
||||||
|
or f"https://{self.db_name}.{self.region}.api.lancedb.com"
|
||||||
|
)
|
||||||
return aiohttp.ClientSession(url)
|
return aiohttp.ClientSession(url)
|
||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
@@ -66,6 +71,8 @@ class RestfulLanceDBClient:
|
|||||||
}
|
}
|
||||||
if self.region == "local": # Local test mode
|
if self.region == "local": # Local test mode
|
||||||
headers["Host"] = f"{self.db_name}.{self.region}.api.lancedb.com"
|
headers["Host"] = f"{self.db_name}.{self.region}.api.lancedb.com"
|
||||||
|
if self.host_override:
|
||||||
|
headers["x-lancedb-database"] = self.db_name
|
||||||
return headers
|
return headers
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -98,7 +105,7 @@ class RestfulLanceDBClient:
|
|||||||
async def post(
|
async def post(
|
||||||
self,
|
self,
|
||||||
uri: str,
|
uri: str,
|
||||||
data: Union[Dict[str, Any], BaseModel, bytes],
|
data: Optional[Union[Dict[str, Any], BaseModel, bytes]] = None,
|
||||||
params: Optional[Dict[str, Any]] = None,
|
params: Optional[Dict[str, Any]] = None,
|
||||||
content_type: Optional[str] = None,
|
content_type: Optional[str] = None,
|
||||||
deserialize: Callable = lambda resp: resp.json(),
|
deserialize: Callable = lambda resp: resp.json(),
|
||||||
@@ -141,5 +148,7 @@ class RestfulLanceDBClient:
|
|||||||
@_check_not_closed
|
@_check_not_closed
|
||||||
async def query(self, table_name: str, query: VectorQuery) -> VectorQueryResult:
|
async def query(self, table_name: str, query: VectorQuery) -> VectorQueryResult:
|
||||||
"""Query a table."""
|
"""Query a table."""
|
||||||
tbl = await self.post(f"/v1/table/{table_name}/", query, deserialize=_read_ipc)
|
tbl = await self.post(
|
||||||
|
f"/v1/table/{table_name}/query/", query, deserialize=_read_ipc
|
||||||
|
)
|
||||||
return VectorQueryResult(tbl)
|
return VectorQueryResult(tbl)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import uuid
|
import uuid
|
||||||
from typing import List
|
from typing import List, Optional
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import pyarrow as pa
|
import pyarrow as pa
|
||||||
@@ -30,14 +30,22 @@ from .client import ARROW_STREAM_CONTENT_TYPE, RestfulLanceDBClient
|
|||||||
class RemoteDBConnection(DBConnection):
|
class RemoteDBConnection(DBConnection):
|
||||||
"""A connection to a remote LanceDB database."""
|
"""A connection to a remote LanceDB database."""
|
||||||
|
|
||||||
def __init__(self, db_url: str, api_key: str, region: str):
|
def __init__(
|
||||||
|
self,
|
||||||
|
db_url: str,
|
||||||
|
api_key: str,
|
||||||
|
region: str,
|
||||||
|
host_override: Optional[str] = None,
|
||||||
|
):
|
||||||
"""Connect to a remote LanceDB database."""
|
"""Connect to a remote LanceDB database."""
|
||||||
parsed = urlparse(db_url)
|
parsed = urlparse(db_url)
|
||||||
if parsed.scheme != "db":
|
if parsed.scheme != "db":
|
||||||
raise ValueError(f"Invalid scheme: {parsed.scheme}, only accepts db://")
|
raise ValueError(f"Invalid scheme: {parsed.scheme}, only accepts db://")
|
||||||
self.db_name = parsed.netloc
|
self.db_name = parsed.netloc
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
self._client = RestfulLanceDBClient(self.db_name, region, api_key)
|
self._client = RestfulLanceDBClient(
|
||||||
|
self.db_name, region, api_key, host_override
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
self._loop = asyncio.get_running_loop()
|
self._loop = asyncio.get_running_loop()
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
@@ -95,7 +103,7 @@ class RemoteDBConnection(DBConnection):
|
|||||||
|
|
||||||
self._loop.run_until_complete(
|
self._loop.run_until_complete(
|
||||||
self._client.post(
|
self._client.post(
|
||||||
f"/v1/table/{name}/create",
|
f"/v1/table/{name}/create/",
|
||||||
data=data,
|
data=data,
|
||||||
params={"request_id": request_id},
|
params={"request_id": request_id},
|
||||||
content_type=ARROW_STREAM_CONTENT_TYPE,
|
content_type=ARROW_STREAM_CONTENT_TYPE,
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ class RemoteTable(Table):
|
|||||||
self._name = name
|
self._name = name
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"RemoteTable({self._conn.db_name}.{self.name})"
|
return f"RemoteTable({self._conn.db_name}.{self._name})"
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def schema(self) -> pa.Schema:
|
def schema(self) -> pa.Schema:
|
||||||
"""Return the schema of the table."""
|
"""Return the schema of the table."""
|
||||||
resp = self._conn._loop.run_until_complete(
|
resp = self._conn._loop.run_until_complete(
|
||||||
self._conn._client.get(f"/v1/table/{self._name}/describe")
|
self._conn._client.post(f"/v1/table/{self._name}/describe/")
|
||||||
)
|
)
|
||||||
schema = json_to_schema(resp["schema"])
|
schema = json_to_schema(resp["schema"])
|
||||||
return schema
|
return schema
|
||||||
@@ -73,7 +73,7 @@ class RemoteTable(Table):
|
|||||||
|
|
||||||
self._conn._loop.run_until_complete(
|
self._conn._loop.run_until_complete(
|
||||||
self._conn._client.post(
|
self._conn._client.post(
|
||||||
f"/v1/table/{self._name}/insert",
|
f"/v1/table/{self._name}/insert/",
|
||||||
data=payload,
|
data=payload,
|
||||||
params={"request_id": request_id, "mode": mode},
|
params={"request_id": request_id, "mode": mode},
|
||||||
content_type=ARROW_STREAM_CONTENT_TYPE,
|
content_type=ARROW_STREAM_CONTENT_TYPE,
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ import numpy as np
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import pyarrow as pa
|
import pyarrow as pa
|
||||||
import pyarrow.compute as pc
|
import pyarrow.compute as pc
|
||||||
import pyarrow.fs
|
|
||||||
from lance import LanceDataset
|
from lance import LanceDataset
|
||||||
from lance.vector import vec_to_table
|
from lance.vector import vec_to_table
|
||||||
|
|
||||||
from .common import DATA, VEC, VECTOR_COLUMN_NAME
|
from .common import DATA, VEC, VECTOR_COLUMN_NAME
|
||||||
from .query import LanceFtsQueryBuilder, LanceQueryBuilder, Query
|
from .query import LanceFtsQueryBuilder, LanceQueryBuilder, Query
|
||||||
|
from .util import fs_from_uri
|
||||||
|
|
||||||
|
|
||||||
def _sanitize_data(data, schema, on_bad_vectors, fill_value):
|
def _sanitize_data(data, schema, on_bad_vectors, fill_value):
|
||||||
@@ -527,7 +527,7 @@ class LanceTable(Table):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def open(cls, db, name):
|
def open(cls, db, name):
|
||||||
tbl = cls(db, name)
|
tbl = cls(db, name)
|
||||||
fs, path = pa.fs.FileSystem.from_uri(tbl._dataset_uri)
|
fs, path = fs_from_uri(tbl._dataset_uri)
|
||||||
file_info = fs.get_file_info(path)
|
file_info = fs.get_file_info(path)
|
||||||
if file_info.type != pa.fs.FileType.Directory:
|
if file_info.type != pa.fs.FileType.Directory:
|
||||||
raise FileNotFoundError(
|
raise FileNotFoundError(
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ def fs_from_uri(uri: str) -> Tuple[pa_fs.FileSystem, str]:
|
|||||||
Get a PyArrow FileSystem from a URI, handling extra environment variables.
|
Get a PyArrow FileSystem from a URI, handling extra environment variables.
|
||||||
"""
|
"""
|
||||||
if get_uri_scheme(uri) == "s3":
|
if get_uri_scheme(uri) == "s3":
|
||||||
if os.environ["AWS_ENDPOINT"]:
|
fs = pa_fs.S3FileSystem(endpoint_override=os.environ.get("AWS_ENDPOINT"))
|
||||||
uri += "?endpoint_override=" + os.environ["AWS_ENDPOINT"]
|
path = get_uri_location(uri)
|
||||||
|
return fs, path
|
||||||
|
|
||||||
return pa_fs.FileSystem.from_uri(uri)
|
return pa_fs.FileSystem.from_uri(uri)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "lancedb"
|
name = "lancedb"
|
||||||
version = "0.1.13"
|
version = "0.1.15"
|
||||||
dependencies = ["pylance~=0.5.8", "ratelimiter", "retry", "tqdm", "aiohttp", "pydantic", "attr", "semver"]
|
dependencies = ["pylance~=0.5.8", "ratelimiter", "retry", "tqdm", "aiohttp", "pydantic", "attr", "semver"]
|
||||||
description = "lancedb"
|
description = "lancedb"
|
||||||
authors = [
|
authors = [
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "vectordb-node"
|
name = "vectordb-node"
|
||||||
version = "0.1.15"
|
version = "0.1.18"
|
||||||
description = "Serverless, low-latency vector database for AI applications"
|
description = "Serverless, low-latency vector database for AI applications"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ pub(crate) fn convert_record_batch(record_batch: RecordBatch) -> RecordBatch {
|
|||||||
.column_by_name("vector")
|
.column_by_name("vector")
|
||||||
.cloned()
|
.cloned()
|
||||||
.expect("vector column is missing");
|
.expect("vector column is missing");
|
||||||
// TODO: we should just consume the underlaying js buffer in the future instead of this arrow around a bunch of times
|
// TODO: we should just consume the underlying js buffer in the future instead of this arrow around a bunch of times
|
||||||
let arr = as_list_array(column.as_ref());
|
let arr = as_list_array(column.as_ref());
|
||||||
let list_size = arr.values().len() / record_batch.num_rows();
|
let list_size = arr.values().len() / record_batch.num_rows();
|
||||||
let r =
|
let r =
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ struct JsTable {
|
|||||||
impl Finalize for JsTable {}
|
impl Finalize for JsTable {}
|
||||||
|
|
||||||
// TODO: object_store didn't export this type so I copied it.
|
// TODO: object_store didn't export this type so I copied it.
|
||||||
// Make a requiest to object_store to export this type
|
// Make a request to object_store to export this type
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct StaticCredentialProvider<T> {
|
pub struct StaticCredentialProvider<T> {
|
||||||
credential: Arc<T>,
|
credential: Arc<T>,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "vectordb"
|
name = "vectordb"
|
||||||
version = "0.1.15"
|
version = "0.1.18"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Serverless, low-latency vector database for AI applications"
|
description = "Serverless, low-latency vector database for AI applications"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user