Skip to content

Commit

Permalink
Tsk 757 add support for tuple in payload (#763)
Browse files Browse the repository at this point in the history
* Add support for tuple in payload for grpc

* chore: delete health_check_pb2_grpc.py

* chore: Modify payload test case to test tuple datatype

* chore: Removed test case for tuple
We cannot test tuple as the return value is listvalue, so i only kept the list

* chore: Remove excess prints in info endpoint

* chore: Added tuple in random payload generator

* feat: convert the tuple payload of local mode to list for congruence
  • Loading branch information
hh-space-invader authored and joein committed Sep 16, 2024
1 parent fa6b201 commit 169094b
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 71 deletions.
1 change: 0 additions & 1 deletion qdrant_client/async_qdrant_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -2831,6 +2831,5 @@ async def info(self) -> types.VersionInfo:
version_info = self.grpc_root.HealthCheck(grpc.HealthCheckRequest())
return GrpcToRest.convert_health_check_reply(version_info)
version_info = await self.rest.service_api.root()
print(version_info)
assert version_info is not None, "Healthcheck returned None"
return version_info
2 changes: 1 addition & 1 deletion qdrant_client/conversions/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def json_to_value(payload: Any) -> Value:
return Value(double_value=payload)
if isinstance(payload, str):
return Value(string_value=payload)
if isinstance(payload, list):
if isinstance(payload, (list, tuple)):
return Value(list_value=ListValue(values=[json_to_value(v) for v in payload]))
if isinstance(payload, dict):
return Value(
Expand Down
66 changes: 0 additions & 66 deletions qdrant_client/grpc/health_check_pb2_grpc.py

This file was deleted.

3 changes: 1 addition & 2 deletions qdrant_client/local/local_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@

def to_jsonable_python(x: Any) -> Any:
try:
json.dumps(x, allow_nan=True)
return x
return json.loads(json.dumps(x, allow_nan=True))
except Exception:
return json.loads(json.dumps(x, allow_nan=True, default=_to_jsonable_python))

Expand Down
1 change: 0 additions & 1 deletion qdrant_client/qdrant_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -3204,6 +3204,5 @@ def info(self) -> types.VersionInfo:
version_info = self.grpc_root.HealthCheck(grpc.HealthCheckRequest())
return GrpcToRest.convert_health_check_reply(version_info)
version_info = self.rest.service_api.root()
print(version_info)
assert version_info is not None, "Healthcheck returned None"
return version_info
1 change: 1 addition & 0 deletions tests/fixtures/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def one_random_payload_please(idx: int) -> Dict[str, Any]:
],
"two_words": [random_real_word(), random_real_word()],
"city": random_city(),
"rand_tuple": tuple(random.randint(0, 100) for _ in range(random.randint(1, 5))),
}

if random.random() < 0.5:
Expand Down

0 comments on commit 169094b

Please sign in to comment.