Skip to content

Commit

Permalink
chore: setup unit testing from core
Browse files Browse the repository at this point in the history
  • Loading branch information
louis030195 committed May 2, 2023
1 parent 6eb8d81 commit 3fbe294
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "embedbase"]
path = embedbase
path = monorepo
url = https://github.com/different-ai/embedbase
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"python.formatting.provider": "black"
"python.formatting.provider": "none",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
}
}
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
install:
poetry lock -n
poetry install -n


#* Formatters
.PHONY: codestyle
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
Embedbase + Qdrant - Advanced and high-performant vector similarity search technology in your AI applications

WIP.


pip install git+https://github.com/different-ai/embedbase.git@main#subdirectory=tests

git submodule add https://github.com/different-ai/embedbase embedbase

git submodule update --remote embedbase
4 changes: 4 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).parent / "monorepo"))
1 change: 0 additions & 1 deletion main-repo
Submodule main-repo deleted from 9f8b75
21 changes: 20 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
requires = ["poetry_core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[virtualenvs]
create = true
in-project = true

[tool.poetry]
name = "embedbase-qdrant"
version = "1.0.0"
Expand Down Expand Up @@ -47,6 +51,8 @@ coverage = "^6.1.2"
coverage-badge = "^1.1.0"
pytest-html = "^3.1.1"
pytest-cov = "^4.0.0"
httpx = "^0.24.0"
pytest-asyncio = "^0.21.0"

[tool.black]
target-version = ["py38"]
Expand Down
80 changes: 79 additions & 1 deletion qdrant_db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from embedbase.database import VectorDatabase
from abc import ABC, abstractmethod
from typing import Coroutine, List, Optional
from pandas import DataFrame


class Qdrant(VectorDatabase):
Expand All @@ -9,11 +12,86 @@ def __init__(
Qdrant is powering the next generation of AI applications with advanced
and high-performant vector similarity search technology.
Qdrant is a vector database & vector similarity search engine.
Qdrant is a vector database & vector similarity search engine.
It deploys as an API service providing search for the nearest high-dimensional vectors.
With Qdrant, embeddings or neural network encoders can be turned into
full-fledged applications for matching, searching, recommending, and much more!
"""
raise NotImplementedError(
"Qdrant is not yet implemented. Please use another database."
)

async def select(
self,
ids: List[str] = [],
hashes: List[str] = [],
dataset_id: Optional[str] = None,
user_id: Optional[str] = None,
distinct: bool = True,
) -> List[dict]:
"""
:param ids: list of ids
:param hashes: list of hashes
:param dataset_id: dataset id
:param user_id: user id
:param distinct: distinct
:return: list of documents
"""
raise NotImplementedError

async def update(
self,
df: DataFrame,
dataset_id: str,
user_id: Optional[str] = None,
batch_size: Optional[int] = 100,
store_data: bool = True,
) -> Coroutine:
"""
:param df: dataframe
:param dataset_id: dataset id
:param user_id: user id
:param batch_size: batch size
:param store_data: store data in database?
"""
raise NotImplementedError

async def delete(
self, ids: List[str], dataset_id: str, user_id: Optional[str] = None
) -> None:
"""
:param ids: list of ids
:param dataset_id: dataset id
:param user_id: user id
"""
raise NotImplementedError

async def search(
self,
vector: List[float],
top_k: Optional[int],
dataset_ids: List[str],
user_id: Optional[str] = None,
) -> List[dict]:
"""
:param vector: vector
:param top_k: top k
:param dataset_id: dataset id
:param user_id: user id
:return: list of documents
"""
raise NotImplementedError

async def clear(self, dataset_id: str, user_id: Optional[str] = None) -> None:
"""
:param dataset_id: dataset id
:param user_id: user id
"""
raise NotImplementedError

async def get_datasets(self, user_id: Optional[str] = None) -> List[dict]:
"""
:param user_id: user id
:return: list of datasets
"""
raise NotImplementedError
8 changes: 8 additions & 0 deletions test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from monorepo.tests.test_end_to_end import vector_databases
from qdrant_db import Qdrant

# override default vector databases with our integration
vector_databases.clear()
vector_databases.append(Qdrant())

# poetry run pytest test_integration.py

0 comments on commit 3fbe294

Please sign in to comment.