Skip to content

Commit

Permalink
Improve volumes and logging (#202)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
tellet-q and pre-commit-ci[bot] authored Sep 24, 2024
1 parent 6e0f4b3 commit 6bab477
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
20 changes: 12 additions & 8 deletions engine/clients/qdrant/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,3 @@ services:
volumes:
qdrant_storage:
name: "qdrant_storage"
driver: local
driver_opts:
type: none
device: ${PWD}/qdrant_storage
o: bind
6 changes: 2 additions & 4 deletions tools/run_server_container_with_volume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6bab477

Please sign in to comment.