Skip to content

Commit

Permalink
update tests, syrupy, use uv
Browse files Browse the repository at this point in the history
  • Loading branch information
asg017 committed Nov 13, 2024
1 parent 26fbdf2 commit 76b8247
Show file tree
Hide file tree
Showing 11 changed files with 521 additions and 52 deletions.
96 changes: 53 additions & 43 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,66 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v3
with:
python-version: "3.12"
enable-cache: true
- run: ./scripts/vendor.sh
- run: make loadable static
- run: pip install pytest numpy; make test-loadable
- run: uv sync --directory tests
- run: make test-loadable python=./venv/bin/python
- uses: actions/upload-artifact@v4
with:
name: sqlite-vec-linux-x86_64-extension
path: dist/*
build-macos-x86_64-extension:
runs-on: macos-12
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- run: ./scripts/vendor.sh
- run: make loadable static
- run: uv sync --directory tests
- run: make test-loadable python=./venv/bin/python
- uses: actions/upload-artifact@v4
with:
name: sqlite-vec-macos-x86_64-extension
path: dist/*
build-macos-aarch64-extension:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- run: ./scripts/vendor.sh
- run: make loadable static
- run: uv sync --directory tests
- run: make test-loadable python=./venv/bin/python
- uses: actions/upload-artifact@v4
with:
name: sqlite-vec-macos-aarch64-extension
path: dist/*
build-windows-x86_64-extension:
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- run: ./scripts/vendor.sh
shell: bash
- run: make sqlite-vec.h
- run: mkdir dist
- run: cl.exe /fPIC -shared /W4 /Ivendor/ /O2 /LD sqlite-vec.c -o dist/vec0.dll
- run: uv sync --directory tests
- run: make test-loadable python=./venv/bin/python
- uses: actions/upload-artifact@v4
with:
name: sqlite-vec-windows-x86_64-extension
path: dist/*
build-android-extensions:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -99,46 +149,6 @@ jobs:
with:
name: sqlite-vec-${{ matrix.platforms.name }}-extension
path: dist/*
build-macos-x86_64-extension:
runs-on: macos-12
steps:
- uses: actions/checkout@v4
- run: ./scripts/vendor.sh
- run: make loadable static
- run: /usr/local/opt/python@3/libexec/bin/python -m pip install --break-system-packages pytest numpy; make test-loadable python=/usr/local/opt/python@3/libexec/bin/python
- uses: actions/upload-artifact@v4
with:
name: sqlite-vec-macos-x86_64-extension
path: dist/*
build-macos-aarch64-extension:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- run: ./scripts/vendor.sh
- run: make loadable static
- run: /opt/homebrew/opt/python3/libexec/bin/python -m pip install pytest numpy --break-system-packages; make test-loadable python=/opt/homebrew/opt/python3/libexec/bin/python
- uses: actions/upload-artifact@v4
with:
name: sqlite-vec-macos-aarch64-extension
path: dist/*
build-windows-x86_64-extension:
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: ./scripts/vendor.sh
shell: bash
- run: make sqlite-vec.h
- run: mkdir dist
- run: cl.exe /fPIC -shared /W4 /Ivendor/ /O2 /LD sqlite-vec.c -o dist/vec0.dll
- run: pip install pytest numpy; make test-loadable
- uses: actions/upload-artifact@v4
with:
name: sqlite-vec-windows-x86_64-extension
path: dist/*
build-wasm32-emscripten:
runs-on: ubuntu-latest
steps:
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,16 @@ publish-release:

# -k test_vec0_update
test-loadable: loadable
$(PYTHON) -m pytest -vv -s -x tests/test-loadable.py
$(PYTHON) -m pytest -vv -s -x tests/test-*.py

test-loadable-snapshot-update: loadable
$(PYTHON) -m pytest -vv tests/test-loadable.py --snapshot-update

test-loadable-watch:
watchexec -w sqlite-vec.c -w tests/test-loadable.py -w Makefile --clear -- make test-loadable
watchexec --exts c,py,Makefile --clear -- make test-loadable

test-unit:
$(CC) tests/test-unit.c sqlite-vec.c -I./ -Ivendor -o $(prefix)/test-unit && $(prefix)/test-unit

site-dev:
npm --prefix site run dev
Expand Down
6 changes: 2 additions & 4 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# partition

- UPDATE on partition key values
- [ ] UPDATE on partition key values
- remove previous row from chunk, insert into new one?
- enforce column types on insert?
- allow null values?
- properly sqlite3_vtab_nochange / sqlite3_value_nochange handling
- [ ] properly sqlite3_vtab_nochange / sqlite3_value_nochange handling
17 changes: 14 additions & 3 deletions sqlite-vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -5477,7 +5477,6 @@ int vec0Filter_knn(vec0_cursor *pCur, vec0_vtab *p, int idxNum,
assert(k_idx >= 0);

// make sure the query vector matches the vector column (type dimensions etc.)
// TODO not argv[0], source idx from idxStr
rc = vector_from_value(argv[query_idx], &queryVector, &dimensions, &elementType,
&queryVectorCleanup, &pzError);

Expand Down Expand Up @@ -5510,7 +5509,6 @@ int vec0Filter_knn(vec0_cursor *pCur, vec0_vtab *p, int idxNum,
goto cleanup;
}

// TODO not argv[1], source idx from idxStr
i64 k = sqlite3_value_int64(argv[k_idx]);
if (k < 0) {
vtab_set_error(
Expand Down Expand Up @@ -5540,7 +5538,6 @@ int vec0Filter_knn(vec0_cursor *pCur, vec0_vtab *p, int idxNum,
// Array of all the rowids that appear in any `rowid in (...)` constraint.
// NULL if none were provided, which means a "full" scan.
#if COMPILER_SUPPORTS_VTAB_IN
// TODO fix
if (rowid_in_idx >= 0) {
sqlite3_value *item;
int rc;
Expand Down Expand Up @@ -6420,6 +6417,20 @@ int vec0Update_Insert(sqlite3_vtab *pVTab, int argc, sqlite3_value **argv,
}
int partition_key_idx = p->user_column_idxs[i];
partitionKeyValues[partition_key_idx] = argv[2+VEC0_COLUMN_USERN_START + i];

int new_value_type = sqlite3_value_type(partitionKeyValues[partition_key_idx]);
if(new_value_type != SQLITE_NULL && new_value_type != p->paritition_columns[partition_key_idx].type) {
// IMP: V11454_28292
vtab_set_error(
pVTab,
"Parition key type mismatch: The partition key column %.*s has type %s, but %s was provided.",
p->paritition_columns[partition_key_idx].name_length,
p->paritition_columns[partition_key_idx].name,
type_name(p->paritition_columns[partition_key_idx].type),
type_name(new_value_type)
);
goto cleanup;
}
}

// read all the inserted vectors into vectorDatas, validate their lengths.
Expand Down
1 change: 1 addition & 0 deletions tests/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
Loading

0 comments on commit 76b8247

Please sign in to comment.