Skip to content

Commit

Permalink
Fix payload type parsing (#15)
Browse files Browse the repository at this point in the history
* add payload parsing test

* use strict version of premitive types in unions + upd dependencies
  • Loading branch information
generall committed Feb 2, 2022
1 parent 376f6a3 commit 29a705b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ keywords = ["vector", "search", "neural", "matching", "client"]
python = ">=3.7"
httpx = "^0.16.1"
numpy = "^1.19"
pydantic = "^1.7.3"
pydantic = "^1.8"
tqdm = "^4.56.0"
loguru = "^0.5.3"
typing-extensions = "^3.10.0"
Expand Down
15 changes: 8 additions & 7 deletions qdrant_openapi_client/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing_extensions import Literal

from pydantic import BaseModel, Field
from pydantic.types import StrictFloat, StrictInt, StrictStr


class AliasOperationsAnyOf(BaseModel):
Expand Down Expand Up @@ -709,20 +710,20 @@ class WalConfigDiff(BaseModel):
PayloadTypeAnyOf3,
]
PayloadVariantForDouble = Union[
List[float],
float,
List[StrictFloat],
StrictFloat,
]
PayloadVariantForGeoPoint = Union[
GeoPoint,
List[GeoPoint],
]
PayloadVariantForInt64 = Union[
List[int],
int,
List[StrictInt],
StrictInt,
]
PayloadVariantForString = Union[
List[str],
str,
List[StrictStr],
StrictStr,
]
PointInsertOperations = Union[
PointInsertOperationsAnyOf,
Expand All @@ -740,7 +741,7 @@ class WalConfigDiff(BaseModel):
]
WithPayloadInterface = Union[
PayloadSelector,
List[str],
List[StrictStr],
bool,
]
CollectionUpdateOperations = Union[
Expand Down
12 changes: 11 additions & 1 deletion tests/test_qdrant_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def test_qdrant_client_integration():


def test_points_crud():

client = QdrantClient()

client.recreate_collection(
Expand Down Expand Up @@ -192,6 +191,17 @@ def test_has_id_condition():
assert query['must'][0]['has_id'] == [42, 43]


def test_insert_float():

point = PointStruct(
id=123,
payload={'value': 0.123},
vector=np.random.rand(DIM).tolist()
)

assert isinstance(point.payload['value'], float)


if __name__ == '__main__':
test_qdrant_client_integration()
test_points_crud()
Expand Down

0 comments on commit 29a705b

Please sign in to comment.