Optimize log message
This commit is contained in:
@@ -1377,6 +1377,7 @@ class PGGraphStorage(BaseGraphStorage):
|
|||||||
if isinstance(node_dict, str):
|
if isinstance(node_dict, str):
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
|
||||||
node_dict = json.loads(node_dict)
|
node_dict = json.loads(node_dict)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
logger.warning(f"Failed to parse node string: {node_dict}")
|
logger.warning(f"Failed to parse node string: {node_dict}")
|
||||||
@@ -1433,6 +1434,7 @@ class PGGraphStorage(BaseGraphStorage):
|
|||||||
if isinstance(result, str):
|
if isinstance(result, str):
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
|
||||||
result = json.loads(result)
|
result = json.loads(result)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
logger.warning(f"Failed to parse edge string: {result}")
|
logger.warning(f"Failed to parse edge string: {result}")
|
||||||
@@ -1650,9 +1652,12 @@ class PGGraphStorage(BaseGraphStorage):
|
|||||||
if isinstance(node_dict, str):
|
if isinstance(node_dict, str):
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
|
||||||
node_dict = json.loads(node_dict)
|
node_dict = json.loads(node_dict)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
logger.warning(f"Failed to parse node string in batch: {node_dict}")
|
logger.warning(
|
||||||
|
f"Failed to parse node string in batch: {node_dict}"
|
||||||
|
)
|
||||||
|
|
||||||
# Remove the 'base' label if present in a 'labels' property
|
# Remove the 'base' label if present in a 'labels' property
|
||||||
if "labels" in node_dict:
|
if "labels" in node_dict:
|
||||||
@@ -1811,9 +1816,12 @@ class PGGraphStorage(BaseGraphStorage):
|
|||||||
if isinstance(edge_props, str):
|
if isinstance(edge_props, str):
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
|
||||||
edge_props = json.loads(edge_props)
|
edge_props = json.loads(edge_props)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
logger.warning(f"Failed to parse edge properties string: {edge_props}")
|
logger.warning(
|
||||||
|
f"Failed to parse edge properties string: {edge_props}"
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
edges_dict[(result["source"], result["target"])] = edge_props
|
edges_dict[(result["source"], result["target"])] = edge_props
|
||||||
@@ -1826,9 +1834,12 @@ class PGGraphStorage(BaseGraphStorage):
|
|||||||
if isinstance(edge_props, str):
|
if isinstance(edge_props, str):
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
|
||||||
edge_props = json.loads(edge_props)
|
edge_props = json.loads(edge_props)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
logger.warning(f"Failed to parse edge properties string: {edge_props}")
|
logger.warning(
|
||||||
|
f"Failed to parse edge properties string: {edge_props}"
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
edges_dict[(result["source"], result["target"])] = edge_props
|
edges_dict[(result["source"], result["target"])] = edge_props
|
||||||
|
@@ -994,10 +994,14 @@ class LightRAG:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Log error and update pipeline status
|
# Log error and update pipeline status
|
||||||
error_msg = f"Failed to extrat document {doc_id}: {traceback.format_exc()}"
|
logger.error(traceback.format_exc())
|
||||||
|
error_msg = f"Failed to extrat document {current_file_number}/{total_files}: {file_path}"
|
||||||
logger.error(error_msg)
|
logger.error(error_msg)
|
||||||
async with pipeline_status_lock:
|
async with pipeline_status_lock:
|
||||||
pipeline_status["latest_message"] = error_msg
|
pipeline_status["latest_message"] = error_msg
|
||||||
|
pipeline_status["history_messages"].append(
|
||||||
|
traceback.format_exc()
|
||||||
|
)
|
||||||
pipeline_status["history_messages"].append(error_msg)
|
pipeline_status["history_messages"].append(error_msg)
|
||||||
|
|
||||||
# Cancel other tasks as they are no longer meaningful
|
# Cancel other tasks as they are no longer meaningful
|
||||||
@@ -1080,10 +1084,14 @@ class LightRAG:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Log error and update pipeline status
|
# Log error and update pipeline status
|
||||||
error_msg = f"Merging stage failed in document {doc_id}: {traceback.format_exc()}"
|
logger.error(traceback.format_exc())
|
||||||
|
error_msg = f"Merging stage failed in document {current_file_number}/{total_files}: {file_path}"
|
||||||
logger.error(error_msg)
|
logger.error(error_msg)
|
||||||
async with pipeline_status_lock:
|
async with pipeline_status_lock:
|
||||||
pipeline_status["latest_message"] = error_msg
|
pipeline_status["latest_message"] = error_msg
|
||||||
|
pipeline_status["history_messages"].append(
|
||||||
|
traceback.format_exc()
|
||||||
|
)
|
||||||
pipeline_status["history_messages"].append(error_msg)
|
pipeline_status["history_messages"].append(error_msg)
|
||||||
|
|
||||||
# Persistent llm cache
|
# Persistent llm cache
|
||||||
|
Reference in New Issue
Block a user