stevezhang
commited on
Commit
·
3cc6ea4
1
Parent(s):
1e7527b
refactor(lightrag): Optimize error handling and logging
Browse files[During operation] Failure to properly log exception details
- Use traceback.format_exc() to capture comprehensive error traces when processing documents
- Log verbose error context upon failures in entity/relationship extraction
- Enhance system stability and debuggability by expanding exception catching and structured logging
- lightrag/lightrag.py +6 -2
lightrag/lightrag.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from __future__ import annotations
|
2 |
|
|
|
3 |
import asyncio
|
4 |
import configparser
|
5 |
import os
|
@@ -959,7 +960,8 @@ class LightRAG:
|
|
959 |
)
|
960 |
except Exception as e:
|
961 |
# Log error and update pipeline status
|
962 |
-
error_msg = f"Failed to process document {doc_id}: {
|
|
|
963 |
logger.error(error_msg)
|
964 |
async with pipeline_status_lock:
|
965 |
pipeline_status["latest_message"] = error_msg
|
@@ -1076,7 +1078,9 @@ class LightRAG:
|
|
1076 |
llm_response_cache=self.llm_response_cache,
|
1077 |
)
|
1078 |
except Exception as e:
|
1079 |
-
logger.error(
|
|
|
|
|
1080 |
raise e
|
1081 |
|
1082 |
async def _insert_done(
|
|
|
1 |
from __future__ import annotations
|
2 |
|
3 |
+
import traceback
|
4 |
import asyncio
|
5 |
import configparser
|
6 |
import os
|
|
|
960 |
)
|
961 |
except Exception as e:
|
962 |
# Log error and update pipeline status
|
963 |
+
error_msg = f"Failed to process document {doc_id}: {traceback.format_exc()}"
|
964 |
+
|
965 |
logger.error(error_msg)
|
966 |
async with pipeline_status_lock:
|
967 |
pipeline_status["latest_message"] = error_msg
|
|
|
1078 |
llm_response_cache=self.llm_response_cache,
|
1079 |
)
|
1080 |
except Exception as e:
|
1081 |
+
logger.error(
|
1082 |
+
f"Failed to extract entities and relationships : {traceback.format_exc()} 。"
|
1083 |
+
)
|
1084 |
raise e
|
1085 |
|
1086 |
async def _insert_done(
|