Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to GRPC version 1 Classic client #563

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/docker-compose-azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:1.21.1
image: semitechnologies/weaviate:preview-make-proto-naming-consistent-4b98dfa
ports:
- 8081:8081
restart: on-failure:0
Expand Down
4 changes: 2 additions & 2 deletions ci/docker-compose-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: '3.4'
services:
weaviate-node-1:
image: semitechnologies/weaviate:1.21.1
image: semitechnologies/weaviate:preview-make-proto-naming-consistent-4b98dfa
restart: on-failure:0
ports:
- "8087:8080"
Expand All @@ -25,7 +25,7 @@ services:
- '8080'
- --scheme
- http
image: semitechnologies/weaviate:1.21.1
image: semitechnologies/weaviate:preview-make-proto-naming-consistent-4b98dfa
ports:
- 8088:8080
- 6061:6060
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-compose-okta-cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:1.21.1
image: semitechnologies/weaviate:preview-make-proto-naming-consistent-4b98dfa
ports:
- 8082:8082
restart: on-failure:0
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-compose-okta-users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:1.21.1
image: semitechnologies/weaviate:preview-make-proto-naming-consistent-4b98dfa
ports:
- 8083:8083
restart: on-failure:0
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-compose-openai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
- '8086'
- --scheme
- http
image: semitechnologies/weaviate:1.21.1
image: semitechnologies/weaviate:preview-make-proto-naming-consistent-4b98dfa
ports:
- 8086:8086
restart: on-failure:0
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-compose-wcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:1.21.1
image: semitechnologies/weaviate:preview-make-proto-naming-consistent-4b98dfa
ports:
- 8085:8085
restart: on-failure:0
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:1.21.1
image: semitechnologies/weaviate:preview-make-proto-naming-consistent-4b98dfa
ports:
- "8080:8080"
- "50051:50051"
Expand Down
4 changes: 2 additions & 2 deletions integration/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import weaviate

GIT_HASH = "5f2df4d"
SERVER_VERSION = "1.21.1"
GIT_HASH = "4b98dfa"
SERVER_VERSION = "1.21.3"
NODE_NAME = "node1"
NUM_OBJECT = 10

Expand Down
3 changes: 3 additions & 0 deletions weaviate/connect/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@
)
from weaviate.warnings import _Warnings


try:
import grpc # type: ignore
from weaviate_grpc import weaviate_pb2_grpc

has_grpc = True

except ImportError:
has_grpc = False


JSONPayload = Union[dict, list]
Session = Union[requests.sessions.Session, OAuth2Session]
TIMEOUT_TYPE_RETURN = Tuple[NUMBERS, NUMBERS]
Expand Down
40 changes: 20 additions & 20 deletions weaviate/gql/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from weaviate.warnings import _Warnings

try:
from weaviate_grpc import weaviate_pb2
from weaviate_grpc import search_get_v1_pb2
import grpc # type: ignore
except ImportError:
pass
Expand Down Expand Up @@ -1837,19 +1837,19 @@ def do(self) -> dict:
metadata = (("authorization", access_token),)

try:
res, _ = self._connection.grpc_stub.Search.with_call( # type: ignore
weaviate_pb2.SearchRequest(
class_name=self._class_name,
res, _ = self._connection.grpc_stub.SearchV1.with_call( # type: ignore
search_get_v1_pb2.SearchRequestV1(
collection=self._class_name,
limit=self._limit,
near_vector=weaviate_pb2.NearVectorParams(
near_vector=search_get_v1_pb2.NearVector(
vector=self._near_clause.content["vector"],
certainty=self._near_clause.content.get("certainty", None),
distance=self._near_clause.content.get("distance", None),
)
if self._near_clause is not None
and isinstance(self._near_clause, NearVector)
else None,
near_object=weaviate_pb2.NearObjectParams(
near_object=search_get_v1_pb2.NearObject(
id=self._near_clause.content["id"],
certainty=self._near_clause.content.get("certainty", None),
distance=self._near_clause.content.get("distance", None),
Expand All @@ -1858,23 +1858,23 @@ def do(self) -> dict:
and isinstance(self._near_clause, NearObject)
else None,
properties=self._convert_references_to_grpc(self._properties),
additional_properties=weaviate_pb2.AdditionalProperties(
metadata=search_get_v1_pb2.MetadataRequest(
uuid=self._additional_dataclass.uuid,
vector=self._additional_dataclass.vector,
creationTimeUnix=self._additional_dataclass.creationTimeUnix,
lastUpdateTimeUnix=self._additional_dataclass.lastUpdateTimeUnix,
creation_time_unix=self._additional_dataclass.creationTimeUnix,
last_update_time_unix=self._additional_dataclass.lastUpdateTimeUnix,
distance=self._additional_dataclass.distance,
explainScore=self._additional_dataclass.explainScore,
explain_score=self._additional_dataclass.explainScore,
score=self._additional_dataclass.score,
)
if self._additional_dataclass is not None
else None,
bm25_search=weaviate_pb2.BM25SearchParams(
bm25_search=search_get_v1_pb2.BM25(
properties=self._bm25.properties, query=self._bm25.query
)
if self._bm25 is not None
else None,
hybrid_search=weaviate_pb2.HybridSearchParams(
hybrid_search=search_get_v1_pb2.Hybrid(
properties=self._hybrid.properties,
query=self._hybrid.query,
alpha=self._hybrid.alpha,
Expand All @@ -1889,7 +1889,7 @@ def do(self) -> dict:
objects = []
for result in res.results:
obj = self._convert_references_to_grpc_result(result.properties)
additional = self._extract_additional_properties(result.additional_properties)
additional = self._extract_additional_properties(result.metadata)
if len(additional) > 0:
obj["_additional"] = additional
objects.append(obj)
Expand All @@ -1905,7 +1905,7 @@ def do(self) -> dict:
return super().do()

def _extract_additional_properties(
self, props: "weaviate_pb2.ResultAdditionalProps"
self, props: "search_get_v1_pb2.MetadataResult"
) -> Dict[str, str]:
additional_props: Dict[str, Any] = {}
if self._additional_dataclass is None:
Expand Down Expand Up @@ -1938,7 +1938,7 @@ def _extract_additional_properties(
return additional_props

def _convert_references_to_grpc_result(
self, properties: "weaviate_pb2.ResultProperties"
self, properties: "search_get_v1_pb2.PropertiesResult"
) -> Dict:
result: Dict[str, Any] = {}
for name, non_ref_prop in properties.non_ref_properties.items():
Expand All @@ -1953,14 +1953,14 @@ def _convert_references_to_grpc_result(

def _convert_references_to_grpc(
self, properties: List[Union[LinkTo, str]]
) -> "weaviate_pb2.Properties":
return weaviate_pb2.Properties(
) -> "search_get_v1_pb2.PropertiesRequest":
return search_get_v1_pb2.PropertiesRequest(
non_ref_properties=[prop for prop in properties if isinstance(prop, str)],
ref_properties=[
weaviate_pb2.RefProperties(
linked_class=prop.linked_class,
search_get_v1_pb2.RefPropertiesRequest(
target_collection=prop.linked_class,
reference_property=prop.link_on,
linked_properties=self._convert_references_to_grpc(prop.properties),
properties=self._convert_references_to_grpc(prop.properties),
)
for prop in properties
if isinstance(prop, LinkTo)
Expand Down
Empty file removed weaviate_grpc/__init__.py
Empty file.
35 changes: 35 additions & 0 deletions weaviate_grpc/base_pb2.py

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

50 changes: 50 additions & 0 deletions weaviate_grpc/base_pb2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from google.protobuf.internal import containers as _containers
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Optional as _Optional

DESCRIPTOR: _descriptor.FileDescriptor

class ConsistencyLevel(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []
CONSISTENCY_LEVEL_UNSPECIFIED: _ClassVar[ConsistencyLevel]
CONSISTENCY_LEVEL_ONE: _ClassVar[ConsistencyLevel]
CONSISTENCY_LEVEL_QUORUM: _ClassVar[ConsistencyLevel]
CONSISTENCY_LEVEL_ALL: _ClassVar[ConsistencyLevel]
CONSISTENCY_LEVEL_UNSPECIFIED: ConsistencyLevel
CONSISTENCY_LEVEL_ONE: ConsistencyLevel
CONSISTENCY_LEVEL_QUORUM: ConsistencyLevel
CONSISTENCY_LEVEL_ALL: ConsistencyLevel

class NumberArrayProperties(_message.Message):
__slots__ = ["values", "prop_name"]
VALUES_FIELD_NUMBER: _ClassVar[int]
PROP_NAME_FIELD_NUMBER: _ClassVar[int]
values: _containers.RepeatedScalarFieldContainer[float]
prop_name: str
def __init__(self, values: _Optional[_Iterable[float]] = ..., prop_name: _Optional[str] = ...) -> None: ...

class IntArrayProperties(_message.Message):
__slots__ = ["values", "prop_name"]
VALUES_FIELD_NUMBER: _ClassVar[int]
PROP_NAME_FIELD_NUMBER: _ClassVar[int]
values: _containers.RepeatedScalarFieldContainer[int]
prop_name: str
def __init__(self, values: _Optional[_Iterable[int]] = ..., prop_name: _Optional[str] = ...) -> None: ...

class TextArrayProperties(_message.Message):
__slots__ = ["values", "prop_name"]
VALUES_FIELD_NUMBER: _ClassVar[int]
PROP_NAME_FIELD_NUMBER: _ClassVar[int]
values: _containers.RepeatedScalarFieldContainer[str]
prop_name: str
def __init__(self, values: _Optional[_Iterable[str]] = ..., prop_name: _Optional[str] = ...) -> None: ...

class BooleanArrayProperties(_message.Message):
__slots__ = ["values", "prop_name"]
VALUES_FIELD_NUMBER: _ClassVar[int]
PROP_NAME_FIELD_NUMBER: _ClassVar[int]
values: _containers.RepeatedScalarFieldContainer[bool]
prop_name: str
def __init__(self, values: _Optional[_Iterable[bool]] = ..., prop_name: _Optional[str] = ...) -> None: ...
4 changes: 4 additions & 0 deletions weaviate_grpc/base_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

41 changes: 41 additions & 0 deletions weaviate_grpc/batch_pb2.py

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

Loading