Fix delete graphrag not take effect in UI#14879
Conversation
📝 WalkthroughWalkthroughThe ChangesGraphRAG Knowledge Graph Deletion Cleanup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
api/apps/services/dataset_api_service.py (1)
437-460: ⚡ Quick winConsider adding logging for observability.
The
delete_index()function logs its operations (lines 811, 830), but this function has no logging. Adding a log statement would improve debugging and monitoring, especially since this change fixes a UI consistency bug.📝 Suggested logging addition
def delete_knowledge_graph(dataset_id: str, tenant_id: str): """ Delete knowledge graph for a dataset. :param dataset_id: dataset ID :param tenant_id: tenant ID :return: (success, result) or (success, error_message) """ if not KnowledgebaseService.accessible(dataset_id, tenant_id): return False, "No authorization." _, kb = KnowledgebaseService.get_by_id(dataset_id) + + logging.info("delete_knowledge_graph: dataset=%s tenant=%s", dataset_id, tenant_id) + from rag.nlp import search from rag.graphrag.phase_markers import clear_phase_markers settings.docStoreConn.delete({"knowledge_graph_kwd": ["graph", "subgraph", "entity", "relation", "community_report"]}, search.index_name(kb.tenant_id), dataset_id) # Wiping the graph invalidates any phase-completion markers used to # short-circuit resolution / community detection on resume. clear_phase_markers(dataset_id) KnowledgebaseService.update_by_id( kb.id, {"graphrag_task_id": "", "graphrag_task_finish_at": None}, ) + logging.info("delete_knowledge_graph: cleared GraphRAG artifacts, phase markers, and task state for dataset=%s", dataset_id) return True, TrueAs per coding guidelines: "Add logging for new flows"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api/apps/services/dataset_api_service.py` around lines 437 - 460, Add observability to delete_knowledge_graph by logging key steps and outcomes: before calling settings.docStoreConn.delete log an info with dataset_id, tenant_id and kb.id indicating the delete is starting; on successful completion log an info confirming deletion and that phase markers were cleared and graphrag_task fields reset; on exceptions around settings.docStoreConn.delete catch and log an error with the exception and context (dataset_id, tenant_id, kb.id) and return the existing False,error path. Use the module's existing logger (e.g., logger.info / logger.error) and reference the function delete_knowledge_graph, KnowledgebaseService, settings.docStoreConn.delete, and clear_phase_markers to locate where to add these logs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@api/apps/services/dataset_api_service.py`:
- Around line 437-460: Add observability to delete_knowledge_graph by logging
key steps and outcomes: before calling settings.docStoreConn.delete log an info
with dataset_id, tenant_id and kb.id indicating the delete is starting; on
successful completion log an info confirming deletion and that phase markers
were cleared and graphrag_task fields reset; on exceptions around
settings.docStoreConn.delete catch and log an error with the exception and
context (dataset_id, tenant_id, kb.id) and return the existing False,error path.
Use the module's existing logger (e.g., logger.info / logger.error) and
reference the function delete_knowledge_graph, KnowledgebaseService,
settings.docStoreConn.delete, and clear_phase_markers to locate where to add
these logs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: aee9ad94-3659-4c2b-91c1-aaae0526fffb
📒 Files selected for processing (1)
api/apps/services/dataset_api_service.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14879 +/- ##
=======================================
Coverage 94.16% 94.16%
=======================================
Files 10 10
Lines 703 703
Branches 112 112
=======================================
Hits 662 662
Misses 25 25
Partials 16 16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
Fix delete graphrag not take effect in UI
Type of change