From 6bab477777de1896d75f342a5b4aea9be5438b4a Mon Sep 17 00:00:00 2001 From: tellet-q <166374656+tellet-q@users.noreply.github.com> Date: Tue, 24 Sep 2024 09:12:04 +0200 Subject: [PATCH] Improve volumes and logging (#202) * Add logging to search requests * Use default volumes instead of bind * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- engine/clients/qdrant/search.py | 20 +++++++++++-------- .../docker-compose.yaml | 5 ----- tools/run_server_container_with_volume.sh | 6 ++---- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/engine/clients/qdrant/search.py b/engine/clients/qdrant/search.py index 1c1d2a84..613212cd 100644 --- a/engine/clients/qdrant/search.py +++ b/engine/clients/qdrant/search.py @@ -25,7 +25,7 @@ def init_client(cls, host, distance, connection_params: dict, search_params: dic host, prefer_grpc=True, limits=httpx.Limits(max_connections=None, max_keepalive_connections=0), - **connection_params + **connection_params, ) cls.search_params = search_params @@ -50,11 +50,15 @@ def search_one(cls, query: Query, top: int) -> List[Tuple[int, float]]: ), ) - res = cls.client.search( - collection_name=QDRANT_COLLECTION_NAME, - query_vector=query_vector, - query_filter=cls.parser.parse(query.meta_conditions), - limit=top, - search_params=rest.SearchParams(**cls.search_params.get("config", {})), - ) + try: + res = cls.client.search( + collection_name=QDRANT_COLLECTION_NAME, + query_vector=query_vector, + query_filter=cls.parser.parse(query.meta_conditions), + limit=top, + search_params=rest.SearchParams(**cls.search_params.get("config", {})), + ) + except Exception as ex: + print(f"Something went wrong during search: {ex}") + raise ex return [(hit.id, hit.score) for hit in res] diff --git a/engine/servers/qdrant-continuous-benchmarks-with-volume/docker-compose.yaml b/engine/servers/qdrant-continuous-benchmarks-with-volume/docker-compose.yaml index 7dc241b4..cccc9b1c 100644 --- a/engine/servers/qdrant-continuous-benchmarks-with-volume/docker-compose.yaml +++ b/engine/servers/qdrant-continuous-benchmarks-with-volume/docker-compose.yaml @@ -22,8 +22,3 @@ services: volumes: qdrant_storage: name: "qdrant_storage" - driver: local - driver_opts: - type: none - device: ${PWD}/qdrant_storage - o: bind diff --git a/tools/run_server_container_with_volume.sh b/tools/run_server_container_with_volume.sh index 5629c845..ad6172f9 100644 --- a/tools/run_server_container_with_volume.sh +++ b/tools/run_server_container_with_volume.sh @@ -36,10 +36,8 @@ if [[ ${QDRANT_VERSION} == docker/* ]] || [[ ${QDRANT_VERSION} == ghcr/* ]]; the fi if [[ "$EXECUTION_MODE" == "init" ]]; then - # create volume qdrant_storage - echo "Initialize qdrant from scratch" - DOCKER_VOLUME_SET_UP="docker volume rm -f qdrant_storage; sudo rm -rf qdrant_storage; mkdir qdrant_storage" - DOCKER_COMPOSE="export QDRANT_VERSION=${QDRANT_VERSION}; export CONTAINER_REGISTRY=${CONTAINER_REGISTRY}; export CONTAINER_MEM_LIMIT=${CONTAINER_MEM_LIMIT}; docker compose down; pkill qdrant; docker rm -f qdrant-continuous || true; docker rmi -f ${CONTAINER_REGISTRY}/qdrant/qdrant:${QDRANT_VERSION} || true ; ${DOCKER_VOLUME_SET_UP}; docker compose up -d; docker container ls -a" + echo "Initialize qdrant from scratch, with qdrant_storage volume" + DOCKER_COMPOSE="export QDRANT_VERSION=${QDRANT_VERSION}; export CONTAINER_REGISTRY=${CONTAINER_REGISTRY}; export CONTAINER_MEM_LIMIT=${CONTAINER_MEM_LIMIT}; docker compose down; pkill qdrant; docker rm -f qdrant-continuous || true; docker rmi -f ${CONTAINER_REGISTRY}/qdrant/qdrant:${QDRANT_VERSION} || true; docker volume rm -f qdrant_storage || true; docker compose up -d; docker container ls -a" else # suggest that volume qdrant_storage exist and start qdrant echo "Reload qdrant with existing data"