GML-2163-UI-GAP: surface rebuild stage in UI during long ECC phases - add progres…#47
GML-2163-UI-GAP: surface rebuild stage in UI during long ECC phases - add progres…#47prinskumar-tigergraph wants to merge 2 commits into
Conversation
…s callbacks to embed, extract, summarize_communities; cache last ECC status to fix unknown time on timeout
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
| if progress is not None: | ||
| try: | ||
| progress(f"Embedding documents ({n_embed} embedded so far)") | ||
| except Exception: | ||
| pass |
There was a problem hiding this comment.
Suggestion: If progress is an async callback, calling it without awaiting will silently skip the UI update and emit an un-awaited coroutine warning. Capture the return value and await it when it is a coroutine; apply the same pattern to the new progress(...) calls in extract and summarize_communities. [possible issue, importance: 6]
| if progress is not None: | |
| try: | |
| progress(f"Embedding documents ({n_embed} embedded so far)") | |
| except Exception: | |
| pass | |
| if progress is not None: | |
| try: | |
| result = progress(f"Embedding documents ({n_embed} embedded so far)") | |
| if asyncio.iscoroutine(result): | |
| await result | |
| except Exception: | |
| pass |
| except Exception as e: | ||
| LogWriter.error(f"Error during ECC rebuild monitoring for {graphname}: {e}") |
There was a problem hiding this comment.
Suggestion: _last_ecc_status_cache is only cleared on normal completion and timeout, so an unexpected monitor failure can leave stale running status for the graph. Clear the cache in finally before releasing the rebuild lock so later timeout fallbacks do not report an old rebuild as active. [possible issue, importance: 7]
New proposed code:
except Exception as e:
LogWriter.error(f"Error during ECC rebuild monitoring for {graphname}: {e}")
import traceback
LogWriter.error(traceback.format_exc())
finally:
+ _last_ecc_status_cache.pop(graphname, None)
# Release lock only after ALL stages complete (or timeout/error)
release_rebuild_lock(graphname)
LogWriter.info(f"Released global rebuild lock for {graphname}")| cached = _last_ecc_status_cache.get(graphname, {}) | ||
| return { | ||
| **cached, | ||
| "graphname": graphname, | ||
| "is_running": True, | ||
| "status": "unknown", |
There was a problem hiding this comment.
Suggestion: This always overwrites the cached status with "unknown", which can hide the last known rebuild phase from the UI during ECC timeouts. Preserve the cached status when available and only fall back to "unknown" when the cache has no status. [general, importance: 7]
New proposed code:
cached = _last_ecc_status_cache.get(graphname, {})
return {
**cached,
"graphname": graphname,
"is_running": True,
- "status": "unknown",
+ "status": cached.get("status", "unknown"),
"error": "ECC is busy processing, status check timed out. Rebuild likely still in progress."
}
User description
…s callbacks to embed, extract, summarize_communities; cache last ECC status to fix unknown time on timeout
PR Type
Bug fix, Enhancement
Description
Surface long-running rebuild progress
Preserve ECC status during timeouts
Propagate progress callbacks across phases
Diagram Walkthrough
File Walkthrough
graph_rag.py
Add rebuild progress callbacks to GraphRAG phasesecc/app/graphrag/graph_rag.py
progresscallbacks toembed.progresscallbacks toextract.progresscallbacks tosummarize_communities.ui.py
Cache ECC rebuild status for timeout fallbackgraphrag/app/routers/ui.py
_last_ecc_status_cacheper graph.