Skip to content

Commit

Permalink
v0.10.0 (#71)
Browse files Browse the repository at this point in the history
* generate gRPC client

* generate REST client

* draft

* wip

* fix conversion test

* old api compatible

* clean deprecated

* batch search + reco tests

* multi-vector test

* full-text filtering

* Fast protobuf (#67)

* generate grpc client

use new grpc client in qdrant methods

fix grpc parallel issue

remove betterproto

remove betterproto

remove betterproto type annotation

extend test coverage

upd protobuf to master

* rm eventloop

* upd version

* shortcut for models

* v0.10.1 compatibility hotfix: make deprecated ram_data_size optional

Co-authored-by: Andrey Vasnetsov <[email protected]>
  • Loading branch information
agourlay and generall authored Sep 19, 2022
1 parent c9deb3e commit ddd2421
Show file tree
Hide file tree
Showing 44 changed files with 3,725 additions and 2,185 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ client = QdrantClient(host="localhost", port=6333)

Create a new collection
```python
from qdrant_client.http.models import Distance
from qdrant_client.http.models import Distance, VectorParams

client.recreate_collection(
collection_name="my_collection",
vector_size=100,
distance=Distance.COSINE
vectors_config=VectorParams(size=100, distance=Distance.COSINE),
)
```

Expand Down
83 changes: 42 additions & 41 deletions poetry.lock

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

5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "qdrant_client"
version = "0.9.7"
version = "0.10.0"
description = "Client library for the Qdrant vector search engine"
authors = ["Andrey Vasnetsov <[email protected]>"]
packages = [
Expand All @@ -22,8 +22,7 @@ tqdm = "^4.56.0"
loguru = "^0.5.3"
typing-extensions = "^4.0.0"
grpcio = { version = "^1.46.0", allow-prereleases = true }
betterproto = { version = "2.0.0b4", allow-prereleases = true }
nest-asyncio = "^1.5.5"
grpcio-tools = "^1.48.0"

[tool.poetry.dev-dependencies]
pytest = "^7.1"
Expand Down
22 changes: 1 addition & 21 deletions qdrant_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
__version__ = '0.1.0'
__version__ = '0.10.0'

from .qdrant_client import QdrantClient


def _in_ipython() -> bool:
"""
Check whether we're in an ipython environment, including jupyter notebooks.
"""
try:
eval('__IPYTHON__')
except NameError:
return False
else: # pragma: no cover
return True


if _in_ipython(): # pragma: no cover
# Python asyncio design is mediocre, it is not possible to await for a future, if there is another loop running.
# Ipython uses asyncio, which makes it impossible to run other async functions, so we need to monkey-patch it.
# It might be dangerous to do this in production, so we are doing it for Jupyter notebooks only.
import nest_asyncio
nest_asyncio.apply()
29 changes: 29 additions & 0 deletions qdrant_client/connection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import Optional

import grpc


def get_channel(host: str, port: int, ssl: bool, metadata: Optional[list] = None) -> grpc.Channel:
if ssl:

if metadata:
def metadata_callback(context, callback):
# for more info see grpc docs
callback(metadata, None)

# build ssl credentials using the cert the same as before
cert_creds = grpc.ssl_channel_credentials()

# now build meta data credentials
auth_creds = grpc.metadata_call_credentials(metadata_callback)

# combine the cert credentials and the macaroon auth credentials
# such that every call is properly encrypted and authenticated
creds = grpc.composite_channel_credentials(cert_creds, auth_creds)
else:
creds = grpc.ssl_channel_credentials()

# finally pass in the combined credentials when creating a channel
return grpc.secure_channel(f'{host}:{port}', creds)
else:
return grpc.insecure_channel(f'{host}:{port}')
16 changes: 9 additions & 7 deletions qdrant_client/conversions/common_types.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
from typing import Union, Type, List, Optional

import betterproto
from pydantic import BaseModel
from typing import Union, List

from qdrant_client import grpc as grpc
from qdrant_client.http import models as rest
from qdrant_client import grpc

Filter = Union[rest.Filter, grpc.Filter]
SearchParams = Union[rest.SearchParams, grpc.SearchParams]
PayloadSelector = Union[rest.PayloadSelector, grpc.WithPayloadSelector]
Distance = Union[rest.Distance, grpc.Distance]
Distance = Union[rest.Distance, int] # type(grpc.Distance) == int
HnswConfigDiff = Union[rest.HnswConfigDiff, grpc.HnswConfigDiff]
OptimizersConfigDiff = Union[rest.OptimizersConfigDiff, grpc.OptimizersConfigDiff]
WalConfigDiff = Union[rest.WalConfigDiff, grpc.WalConfigDiff]
PointId = Union[int, str, grpc.PointId]
PayloadSchemaType = Union[rest.PayloadSchemaType, grpc.PayloadSchemaType]
PayloadSchemaType = Union[rest.PayloadSchemaType, rest.PayloadSchemaParams, int] # type(grpc.PayloadSchemaType) == int
Points = Union[rest.Batch, List[Union[rest.PointStruct, grpc.PointStruct]]]
PointsSelector = Union[rest.PointsSelector, grpc.PointsSelector]
AliasOperations = Union[
Expand All @@ -32,3 +29,8 @@
CollectionInfo = rest.CollectionInfo
CountResult = rest.CountResult
SnapshotDescription = rest.SnapshotDescription
NamedVector = rest.NamedVector
VectorParams = rest.VectorParams

SearchRequest = Union[rest.SearchRequest, grpc.SearchPoints]
RecommendRequest = Union[rest.RecommendRequest, grpc.RecommendPoints]
Loading

0 comments on commit ddd2421

Please sign in to comment.