yangdx
commited on
Commit
·
e14243c
1
Parent(s):
121ecc4
Add API endpoint to retrieve document indexing pipeline status
Browse files• GET /pipeline_status endpoint added
• Returns current pipeline processing state
lightrag/api/routers/document_routes.py
CHANGED
@@ -653,6 +653,35 @@ def create_document_routes(
|
|
653 |
logging.error(traceback.format_exc())
|
654 |
raise HTTPException(status_code=500, detail=str(e))
|
655 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
656 |
@router.get("", dependencies=[Depends(optional_api_key)])
|
657 |
async def documents() -> DocsStatusesResponse:
|
658 |
"""
|
|
|
653 |
logging.error(traceback.format_exc())
|
654 |
raise HTTPException(status_code=500, detail=str(e))
|
655 |
|
656 |
+
@router.get("/pipeline_status", dependencies=[Depends(optional_api_key)])
|
657 |
+
async def get_pipeline_status():
|
658 |
+
"""
|
659 |
+
Get the current status of the document indexing pipeline.
|
660 |
+
|
661 |
+
This endpoint returns information about the current state of the document processing pipeline,
|
662 |
+
including whether it's busy, the current job name, when it started, how many documents
|
663 |
+
are being processed, how many batches there are, and which batch is currently being processed.
|
664 |
+
|
665 |
+
Returns:
|
666 |
+
dict: A dictionary containing the pipeline status information
|
667 |
+
"""
|
668 |
+
try:
|
669 |
+
from lightrag.kg.shared_storage import get_namespace_data
|
670 |
+
pipeline_status = get_namespace_data("pipeline_status")
|
671 |
+
|
672 |
+
# Convert to regular dict if it's a Manager.dict
|
673 |
+
status_dict = dict(pipeline_status)
|
674 |
+
|
675 |
+
# Format the job_start time if it exists
|
676 |
+
if status_dict.get("job_start"):
|
677 |
+
status_dict["job_start"] = str(status_dict["job_start"])
|
678 |
+
|
679 |
+
return status_dict
|
680 |
+
except Exception as e:
|
681 |
+
logging.error(f"Error getting pipeline status: {str(e)}")
|
682 |
+
logging.error(traceback.format_exc())
|
683 |
+
raise HTTPException(status_code=500, detail=str(e))
|
684 |
+
|
685 |
@router.get("", dependencies=[Depends(optional_api_key)])
|
686 |
async def documents() -> DocsStatusesResponse:
|
687 |
"""
|