Skip to content

Commit 9806375

Browse files
authored
release updates (#194)
* Adds qdrant check for filter attributs * Submodule update
1 parent 3e4596d commit 9806375

File tree

5 files changed

+45
-13
lines changed

5 files changed

+45
-13
lines changed

controller/embedding/connector.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from util import service_requests
55
import requests
6+
from graphql import GraphQLError
67

78
BASE_URI = os.getenv("EMBEDDING_SERVICE")
89
NEURAL_SEARCH_BASE_URI = os.getenv("NEURAL_SEARCH")
@@ -44,15 +45,29 @@ def request_re_embed_records(
4445

4546
def update_attribute_payloads_for_neural_search(
4647
project_id: str, embedding_id: str, record_ids: Optional[List[str]] = None
47-
) -> None:
48+
) -> bool:
4849
url = f"{NEURAL_SEARCH_BASE_URI}/update_attribute_payloads"
4950
data = {
5051
"project_id": project_id,
5152
"embedding_id": embedding_id,
5253
}
5354
if record_ids:
5455
data["record_ids"] = record_ids
55-
service_requests.post_call_or_raise(url, data)
56+
try:
57+
service_requests.post_call_or_raise(url, data)
58+
return True
59+
except GraphQLError:
60+
print("couldn't update attribute payloads for neural search", flush=True)
61+
return False
62+
63+
64+
def collection_on_qdrant(project_id: str, embedding_id: str) -> bool:
65+
url = f"{NEURAL_SEARCH_BASE_URI}/collection/exist"
66+
data = {
67+
"project_id": project_id,
68+
"embedding_id": embedding_id,
69+
}
70+
return service_requests.get_call_or_raise(url, data)["exists"]
5671

5772

5873
def update_label_payloads_for_neural_search(

controller/embedding/manager.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,17 @@ def __recreate_embedding(project_id: str, embedding_id: str) -> Embedding:
262262

263263
def update_embedding_payload(
264264
project_id: str, embedding_id: str, filter_attributes: List[str]
265-
) -> None:
265+
) -> bool:
266266
notification.send_organization_update(
267267
project_id=project_id,
268268
message=f"upload_embedding_payload:{str(embedding_id)}:start",
269269
)
270-
embedding.update_embedding_filter_attributes(
271-
project_id, embedding_id, filter_attributes, with_commit=True
272-
)
273-
connector.update_attribute_payloads_for_neural_search(project_id, embedding_id)
270+
if connector.update_attribute_payloads_for_neural_search(project_id, embedding_id):
271+
embedding.update_embedding_filter_attributes(
272+
project_id, embedding_id, filter_attributes, with_commit=True
273+
)
274+
return True
275+
return False
274276

275277

276278
def update_label_payloads_for_neural_search(

graphql_api/mutation/embedding.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,14 @@ def mutate(
9999
):
100100
auth.check_demo_access(info)
101101
auth.check_project_access(info, project_id)
102-
manager.update_embedding_payload(project_id, embedding_id, filter_attributes)
103-
notification.send_organization_update(
104-
project_id, f"embedding_updated:{embedding_id}"
102+
went_through = manager.update_embedding_payload(
103+
project_id, embedding_id, filter_attributes
105104
)
106-
return UpdateEmbeddingPayload(ok=True)
105+
if went_through:
106+
notification.send_organization_update(
107+
project_id, f"embedding_updated:{embedding_id}"
108+
)
109+
return UpdateEmbeddingPayload(ok=went_through)
107110

108111

109112
class EmbeddingMutation(graphene.ObjectType):

graphql_api/types.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
resolve_inter_annotator_matrix_classification,
2727
resolve_inter_annotator_matrix_extraction,
2828
)
29+
from controller.embedding.connector import collection_on_qdrant
2930

3031

3132
class User(SQLAlchemyObjectType):
@@ -152,6 +153,7 @@ class Meta:
152153
dimension = graphene.Int()
153154
count = graphene.Int()
154155
progress = graphene.Float()
156+
on_qdrant = graphene.Boolean()
155157

156158
def resolve_count(self, info):
157159
return embedding.get_tensor_count(self.id)
@@ -175,9 +177,18 @@ def resolve_progress(self, info):
175177
return 0.0
176178
else:
177179
return min(
178-
0.1 + (Embedding.resolve_count(self, info) / len(self.project.records) * 0.9), 0.99
180+
0.1
181+
+ (
182+
Embedding.resolve_count(self, info)
183+
/ len(self.project.records)
184+
* 0.9
185+
),
186+
0.99,
179187
)
180188

189+
def resolve_on_qdrant(self, info):
190+
return collection_on_qdrant(str(self.project_id), str(self.id))
191+
181192

182193
class Project(SQLAlchemyObjectType):
183194
class Meta:
@@ -667,6 +678,7 @@ class Encoder(graphene.ObjectType):
667678
applicability = graphene.JSONString()
668679
platform = graphene.String()
669680

681+
670682
class UploadTask(SQLAlchemyObjectType):
671683
class Meta:
672684
model = models.UploadTask

0 commit comments

Comments
 (0)