Skip to content

Commit 1ccbc62

Browse files
authored
Enable daily cron for search engine population and make delete operations non-blocking (#765)
Uncomment the cron schedule so the search engine is populated daily at 07:05 UTC. Remove the `wait_for_task_completion` decorator from Meilisearch delete functions (`delete_embedding_db`, `clear_embedding_db`, `delete_documents_from_db`) so they fire-and-forget instead of blocking until the task finishes. Made-with: Cursor
1 parent ef8190d commit 1ccbc62

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

.github/workflows/populate_search_engine.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Populate Search Engine
22

33
on:
4-
# schedule:
5-
# - cron: "5 7 * * *" # every day at 07:05
4+
schedule:
5+
- cron: "5 7 * * *" # every day at 07:05
66
# to run this workflow manually from the Actions tab
77
workflow_dispatch:
88

src/doc_builder/meilisearch_helper.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,15 @@ def update_db_settings(client: Client, index_name: str):
161161
return client, task_info
162162

163163

164-
@wait_for_task_completion
165164
def delete_embedding_db(client: Client, index_name: str):
166165
index = client.index(index_name)
167-
task_info = index.delete()
168-
return client, task_info
166+
index.delete()
169167

170168

171-
@wait_for_task_completion
172169
def clear_embedding_db(client: Client, index_name: str):
173170
"""Delete all documents from an index without deleting the index itself."""
174171
index = client.index(index_name)
175-
task_info = index.delete_all_documents()
176-
return client, task_info
172+
index.delete_all_documents()
177173

178174

179175
def get_all_document_ids(client: Client, index_name: str) -> set[str]:
@@ -199,12 +195,10 @@ def get_all_document_ids(client: Client, index_name: str) -> set[str]:
199195
return all_ids
200196

201197

202-
@wait_for_task_completion
203198
def delete_documents_from_db(client: Client, index_name: str, doc_ids: list[str]):
204199
"""Delete a batch of documents by ID from a Meilisearch index."""
205200
index = client.index(index_name)
206-
task_info = index.delete_documents(doc_ids)
207-
return client, task_info
201+
index.delete_documents(doc_ids)
208202

209203

210204
def sanitize_for_id(text):

0 commit comments

Comments
 (0)