diff --git a/cognee/modules/graph/cognee_graph/CogneeGraph.py b/cognee/modules/graph/cognee_graph/CogneeGraph.py index dab8371b9..b53367e8d 100644 --- a/cognee/modules/graph/cognee_graph/CogneeGraph.py +++ b/cognee/modules/graph/cognee_graph/CogneeGraph.py @@ -1,5 +1,4 @@ -import numpy as np - +import logging from typing import List, Dict, Union from cognee.exceptions import InvalidValueError @@ -8,7 +7,8 @@ from cognee.infrastructure.databases.graph.graph_db_interface import GraphDBInte from cognee.modules.graph.cognee_graph.CogneeGraphElements import Node, Edge from cognee.modules.graph.cognee_graph.CogneeAbstractGraph import CogneeAbstractGraph import heapq -import asyncio + +logger = logging.getLogger(__name__) class CogneeGraph(CogneeAbstractGraph): @@ -40,7 +40,7 @@ class CogneeGraph(CogneeAbstractGraph): edge.node1.add_skeleton_edge(edge) edge.node2.add_skeleton_edge(edge) else: - print(f"Edge {edge} already exists in the graph.") + logger.debug(f"Edge {edge} already exists in the graph.") def get_node(self, node_id: str) -> Node: return self.nodes.get(node_id, None) diff --git a/cognee/modules/visualization/cognee_network_visualization.py b/cognee/modules/visualization/cognee_network_visualization.py index df06b2094..e92f7783f 100644 --- a/cognee/modules/visualization/cognee_network_visualization.py +++ b/cognee/modules/visualization/cognee_network_visualization.py @@ -21,10 +21,19 @@ async def cognee_network_visualization(graph_data): node_info["id"] = str(node_id) node_info["color"] = color_map.get(node_info.get("pydantic_type", "default"), "#D3D3D3") node_info["name"] = node_info.get("name", str(node_id)) - del node_info[ - "updated_at" - ] #:TODO: We should decide what properties to show on the nodes and edges, we dont necessarily need all. - del node_info["created_at"] + + try: + del node_info[ + "updated_at" + ] #:TODO: We should decide what properties to show on the nodes and edges, we dont necessarily need all. + except KeyError: + pass + + try: + del node_info["created_at"] + except KeyError: + pass + nodes_list.append(node_info) G.add_node(node_id, **node_info) diff --git a/cognee/tasks/repo_processor/get_local_dependencies.py b/cognee/tasks/repo_processor/get_local_dependencies.py index 600ff25a5..c04bdbaf2 100644 --- a/cognee/tasks/repo_processor/get_local_dependencies.py +++ b/cognee/tasks/repo_processor/get_local_dependencies.py @@ -79,6 +79,9 @@ def _update_code_entity(script: jedi.Script, code_entity: Dict[str, any]) -> Non except AssertionError as e: # TODO: See if there is a way to handle AttributeError properly logger.error(f"Failed to analyze code entity {code_entity['name']}: {e}") + except ValueError as e: + # TODO: See if there is a way to handle ValueError properly + logger.error(f"Failed to analyze code entity {code_entity['name']}: {e}") except Exception as e: # logging.warning(f"Failed to analyze code entity {code_entity['name']}: {e}") logger.error(f"Failed to analyze code entity {code_entity['name']}: {e}")