Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-buster as builder-image
FROM python:3.11 as builder-image

RUN apt-get update

Expand Down
9 changes: 9 additions & 0 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"features": {
"ghcr.io/devcontainers/features/docker-in-docker": {
"version": "4.0.0",
"resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:4fa87399214366e320d489991769c4f3f461e1ffe461f54eea78a41b34945bb5",
"integrity": "sha256:4fa87399214366e320d489991769c4f3f461e1ffe461f54eea78a41b34945bb5"
}
}
}
6 changes: 5 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"workspaceFolder": "/opt/code/VectorDBBench",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
"features": {
"ghcr.io/devcontainers/features/docker-in-docker": {
"moby": false
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
Expand Down
4 changes: 2 additions & 2 deletions install/requirements_py3.11.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
grpcio==1.53.2
grpcio-tools==1.53.0
grpcio>=1.66.2
grpcio-tools>=1.66.2
qdrant-client
pinecone
weaviate-client
Expand Down
8 changes: 8 additions & 0 deletions tests/test_pgvector.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

from vectordb_bench.backend.clients import DB
from vectordb_bench.backend.clients.pgvector.config import PgVectorHNSWConfig
from vectordb_bench.backend.clients.pgvector.pgvector import PgVector
from vectordb_bench.backend.dataset import Dataset, DatasetSource
from vectordb_bench.backend.filter import Filter, FilterOp, non_filter
from vectordb_bench.backend.runner.concurrent_runner import ConcurrentInsertRunner
Expand Down Expand Up @@ -84,6 +85,13 @@ def random_embeddings(n: int = COUNT, d: int = DIM) -> list[list[float]]:

class TestPgVectorBasic:
"""Unit tests for the PgVector client (no subprocess)."""
def test_create_connection_installs_vector_extension(self):
conn, cursor = PgVector._create_connection(**DB_CONFIG["connect_config"])
try:
assert conn.execute("SELECT 1 FROM pg_extension WHERE extname = 'vector'").fetchone() is not None
finally:
cursor.close()
conn.close()

def test_insert_and_search(self):
db = make_db("test_basic")
Expand Down
6 changes: 2 additions & 4 deletions vectordb_bench/backend/clients/pgvector/pgvector.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ def __init__(
# construct basic units
self.conn, self.cursor = self._create_connection(**self.connect_config)

# create vector extension
self.cursor.execute("CREATE EXTENSION IF NOT EXISTS vector")
self.conn.commit()

log.info(f"{self.name} config values: {self.connect_config}\n{self.case_config}")
if not any(
(
Expand Down Expand Up @@ -90,6 +86,8 @@ def __init__(
@staticmethod
def _create_connection(**kwargs) -> tuple[Connection, Cursor]:
conn = psycopg.connect(**kwargs)
conn.execute("CREATE EXTENSION IF NOT EXISTS vector")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vectordb_bench/backend/clients/pgvector/pgvector.py line:89
Low ---- Please add a focused regression test that proves extension creation is committed before register_vector runs on a fresh database. The current PR checks only run the dataset unit test, while tests/test_pgvector.py is manual and does not assert the initial extension state, so the exact ordering bug that survived the 2024 psycopg3 migration can regress again without CI noticing; a mocked call-order test or fresh-database fixture would cover it directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

But also... when I started working on this, I realized that the current devcontainer setup is broken, since buster is no longer supported.
Also, docker is obviously needed in the container and dependency installation didn't work because of a conflict that I resolved in the same commit, since it's all about getting the devcontainer working again.

conn.commit()
register_vector(conn)
conn.autocommit = False
cursor = conn.cursor()
Expand Down
Loading