-
Notifications
You must be signed in to change notification settings - Fork 122
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
feature: Facets #759
feature: Facets #759
Conversation
7f0be8c
to
12dc515
Compare
def convert_facet_value(cls, model: grpc.FacetValue) -> rest.FacetValue: | ||
name = model.WhichOneof("variant") | ||
if name is None: | ||
raise ValueError(f"invalid FacetValue model: {model}") | ||
|
||
val = getattr(model, name) | ||
return val | ||
|
||
@classmethod | ||
def convert_facet_value_hit(cls, model: grpc.FacetHit) -> rest.FacetValueHit: | ||
return rest.FacetValueHit( | ||
value=cls.convert_facet_value(model.value), | ||
count=model.count, | ||
) | ||
|
||
@classmethod | ||
def convert_facet_response(cls, model: grpc.FacetResponse) -> rest.FacetResponse: | ||
return rest.FacetResponse( | ||
hits=[cls.convert_facet_value_hit(hit) for hit in model.hits], | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- lacks conversion tests
- lacks rest to grpc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are implementing the inverse conversions even for the structs which we are not using in order to increase test coverage. E.g. scored point, update result
@@ -1261,7 +1261,7 @@ def recommend_groups( | |||
with_lookup = RestToGrpc.convert_with_lookup(with_lookup) | |||
|
|||
if isinstance(with_lookup, str): | |||
with_lookup = grpc.WithLookup(lookup_index=with_lookup) | |||
with_lookup = grpc.WithLookup(collection=with_lookup) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasn't anyone ever used it? :'(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷
hits = [ | ||
models.FacetValueHit(value=value, count=count) | ||
for value, count in sorted( | ||
facet_hits.items(), | ||
# order by count descending, then by value ascending | ||
key=lambda x: (-x[1], x[0]), | ||
)[:limit] | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there is a facet request on a field which is not one of supported type (int, str), e.g. with a boolean, then we'll get an ugly pydantic error like
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 2 validation errors for FacetValueHit
value.int
Input should be a valid integer [type=int_type, input_value=True, input_type=bool]
For further information visit https://errors.pydantic.dev/2.9/v/int_type
value.str
Input should be a valid string [type=string_type, input_value=True, input_type=bool]
For further information visit https://errors.pydantic.dev/2.9/v/string_type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this was already sanitized above. Did you create a failing test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that bool is a subclass of int, which is why it was getting through isinstance
.
I now fixed it by using
if type(v) not in get_args_subscribed(types.FacetValue):
continue
d0b9d39
to
1c600f5
Compare
- qdrant base - qdrant client - conversions
bd123a1
to
d8ccef6
Compare
Just updated for testing bool facets. Right now CI fails because dev build is not yet ready, I'll rerun in a few hours |
* update rest client * update grpc client with grpcio 1.65.4 * update grpc client with grpcio==1.49.1 * generate grpc client with grpcio==1.48.2 * generate grpc client with grpcio==1.66.1 and mypy-protobuf extension * add mypy-protobuf to pyproject * relax version for grpcio, but keep grpcio-tools at 1.48.2 * improve generation script * fix bash script comment Co-authored-by: George <[email protected]> * use old grpcio to generate client * rollbakc mypy-protobuf * regenerate with distance matrix * new: update clients (#774) * new: update clients * rollback grpcio version * feature: Facets (#759) * facet in local_collection.py * replace usages of calculate_payload_mask * - qdrant remote - qdrant base - qdrant client - conversions * congruence tests + local mode fixes * generate async client * add type stubs and misc fixes * fix mypy in Python 3.8 * generate async client * review remarks * gen async client * update for bool facets * Feature: Distance Matrix API (#769) * add remote impls * add client impl * regen async client * start local * regen async * local mode * start congruence * Fix local mode * regen async of course * test filtering * fix min samples count * simplify comparaison loop * simplify samples loop * add rest/gRPC conversion tests * fix conversions + tests --------- Co-authored-by: George <[email protected]> Co-authored-by: generall <[email protected]> Co-authored-by: Arnaud Gourlay <[email protected]>
* update rest client * update grpc client with grpcio 1.65.4 * update grpc client with grpcio==1.49.1 * generate grpc client with grpcio==1.48.2 * generate grpc client with grpcio==1.66.1 and mypy-protobuf extension * add mypy-protobuf to pyproject * relax version for grpcio, but keep grpcio-tools at 1.48.2 * improve generation script * fix bash script comment Co-authored-by: George <[email protected]> * use old grpcio to generate client * rollbakc mypy-protobuf * regenerate with distance matrix * new: update clients (#774) * new: update clients * rollback grpcio version * feature: Facets (#759) * facet in local_collection.py * replace usages of calculate_payload_mask * - qdrant remote - qdrant base - qdrant client - conversions * congruence tests + local mode fixes * generate async client * add type stubs and misc fixes * fix mypy in Python 3.8 * generate async client * review remarks * gen async client * update for bool facets * Feature: Distance Matrix API (#769) * add remote impls * add client impl * regen async client * start local * regen async * local mode * start congruence * Fix local mode * regen async of course * test filtering * fix min samples count * simplify comparaison loop * simplify samples loop * add rest/gRPC conversion tests * fix conversions + tests --------- Co-authored-by: George <[email protected]> Co-authored-by: generall <[email protected]> Co-authored-by: Arnaud Gourlay <[email protected]>
Needs #758
Adds
facet
functionality in both remote and local modeWIP:
All Submissions:
dev
branch. Did you create your branch fromdev
?New Feature Submissions:
pre-commit
withpip3 install pre-commit
and set up hooks withpre-commit install
?Changes to Core Features: