Files
qdrant-client/tools/generate_grpc_client.sh
George ff7f584d33 new: update models, remove init_from and locks (#1100)
* new: update models, remove init_from and locks

* deprecate: remove init from tests

* deprecate: remove lock tests

* new: convert ascii_folding

* fix: fix type stub

* new: convert acorn

* new: convert shard key with fallback

* new: update grpcio and grpcio tools in generator (#1106)

* new: update grpcio and grpcio tools in generator

* fix: bind grpcio and tools versions to 1.62.0 in generator

* Remove deprecated methods (#1103)

* deprecate: remove old api methods

* deprecate: remove type stub for removed methods

* deprecate: remove old api methods from test_qdrant_client

* deprecate: replace search with query points in test_in_memory

* deprecate: replace search methods in fastembed mixin with query points

* deprecate: replace old api methods in test async qdrant client

* deprecate: replace search with query points in test delete points

* deprecate: replace discover and context with query points in test_discovery

* deprecate: replace recommend_groups with query_points_groups in test_group_recommend

* deprecate: replace search_groups in test_group_search

* deprecate: replace recommend with query points in test_recommendation

* deprecate: replace search with query points in test search

* deprecate: replace context and discover with query points in test sparse discovery

* deprecate: replace search with query points in test sparse idf search

* deprecate: replace recommend with query points in test sparse recommend

* deprecate: replace search with query points in test sparse search

* deprecate: replace missing search request with query request in qdrant_fastembed

* deprecate: replace search with query points in test multivector search queries

* deprecate: replace upload records with upload points in test_updates

* deprecate: remove redundant structs (#1104)

* deprecate: remove redundant structs

* fix: do not use removed conversions in local mode

* fix: remove redundant conversions, simplify types.QueryRequest

* deprecate: replace old style grpc vector conversion to a new one (#1105)

* deprecate: replace old style grpc vector conversion to a new one

* fix: ignore union attr in conversion

* review fixes

---------

Co-authored-by: generall <andrey@vasnetsov.com>

---------

Co-authored-by: generall <andrey@vasnetsov.com>

---------

Co-authored-by: generall <andrey@vasnetsov.com>

* new: deprecate add, query, query_batch in fastembed mixin (#1102)

* new: deprecate add, query, query_batch in fastembed mixin

* 1.16 -> 1.17

---------

Co-authored-by: generall <andrey@vasnetsov.com>

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2025-11-11 21:17:08 +07:00

74 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
TEMP_ENV=$(mktemp -d)
VENV_DIR="$TEMP_ENV/grpc_generator_venv"
QDRANT_PATH=$(mktemp -d)
trap "rm -rf \"$TEMP_ENV\"; rm -rf \"$QDRANT_PATH\"" EXIT
if [[ "$(python --version 2>&1 | awk '{print $2}')" == "3.10.10" ]]; then
PYTHON_BIN="python"
elif [[ "$(python3 --version 2>&1 | awk '{print $2}')" == "3.10.10" ]]; then
PYTHON_BIN="python3"
elif [[ "$(python3.10 --version 2>&1 | awk '{print $2}')" == "3.10.10" ]]; then
PYTHON_BIN="python3.10"
fi
if [[ -z "$PYTHON_BIN" ]]; then
echo "Error: No suitable Python 3.10.10 installation found among {python, python3, python3.10}" >&2
exit 1
fi
"$PYTHON_BIN" -m venv "$VENV_DIR"
source "$VENV_DIR/bin/activate"
pip install --upgrade pip
pip install "grpcio==1.62.0" # as of 1.63.0 grpc complaining that our minimal supported version 1.48 is too old
pip install "grpcio-tools==1.62.0" # as of 1.63.0 grpc complaining that our minimal supported version 1.48 is too old
pip install "mypy-protobuf==3.3.0" # ^3.3.0
cd "$QDRANT_PATH"
git clone --sparse --filter=blob:none --depth=1 -b dev git@github.com:qdrant/qdrant.git
cd qdrant
git sparse-checkout add lib/api/src/grpc/proto
PROTO_DIR="$(pwd)/lib/api/src/grpc/proto"
cd "$PROJECT_ROOT"
CLIENT_DIR="qdrant_client/proto"
cp "$PROTO_DIR"/*.proto "$CLIENT_DIR/"
rm -f $CLIENT_DIR/collections_internal_service.proto
rm -f $CLIENT_DIR/points_internal_service.proto
rm -f $CLIENT_DIR/qdrant_internal_service.proto
rm -f $CLIENT_DIR/shard_snapshots_service.proto
rm -f $CLIENT_DIR/raft_service.proto
rm -f $CLIENT_DIR/health_check.proto
# Clean qdrant.proto references to those removed files
cat $CLIENT_DIR/qdrant.proto \
| grep -v 'collections_internal_service.proto' \
| grep -v 'points_internal_service.proto' \
| grep -v 'qdrant_internal_service.proto' \
| grep -v 'shard_snapshots_service.proto' \
| grep -v 'raft_service.proto' \
| grep -v 'health_check.proto' \
> $CLIENT_DIR/qdrant_tmp.proto
mv "$CLIENT_DIR/qdrant_tmp.proto" "$CLIENT_DIR/qdrant.proto"
"$VENV_DIR/bin/python" -m grpc_tools.protoc \
--proto_path=qdrant_client/proto/ \
-I ./qdrant_client/grpc \
./qdrant_client/proto/*.proto \
--python_out=./qdrant_client/grpc \
--grpc_python_out=./qdrant_client/grpc \
--mypy_out=./qdrant_client/grpc
# maybe I'll remove this crutch when google makes normal imports for issue from 2016
# https://github.com/protocolbuffers/protobuf/issues/1491
sed -i -re 's/^import (\w*)_pb2/from . import \1_pb2/g' ./qdrant_client/grpc/*.py
deactivate