From 88baae9bc6e6903b821b3aa28ffd47159795a780 Mon Sep 17 00:00:00 2001 From: Estelle Scifo Date: Tue, 8 Oct 2024 11:42:36 +0200 Subject: [PATCH] Fix/cypher syntax warning (#170) * Remove Cypher syntax warning log * Better solution, only disable for the KGWriter run method * No comment --- src/neo4j_graphrag/experimental/components/kg_writer.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/neo4j_graphrag/experimental/components/kg_writer.py b/src/neo4j_graphrag/experimental/components/kg_writer.py index dcae6d91..19ebcdd7 100644 --- a/src/neo4j_graphrag/experimental/components/kg_writer.py +++ b/src/neo4j_graphrag/experimental/components/kg_writer.py @@ -193,6 +193,12 @@ async def run(self, graph: Neo4jGraph) -> KGWriterModel: Args: graph (Neo4jGraph): The knowledge graph to upsert into the database. """ + # we disable the notification logger to get rid of the deprecation + # warning about Cypher subqueries. Once the queries are updated + # for Neo4j 5.23, we can remove this line and the 'finally' block + notification_logger = logging.getLogger("neo4j.notifications") + notification_level = notification_logger.level + notification_logger.setLevel(logging.ERROR) try: if inspect.iscoroutinefunction(self.driver.execute_query): await self._async_db_setup() @@ -227,3 +233,5 @@ async def run(self, graph: Neo4jGraph) -> KGWriterModel: except neo4j.exceptions.ClientError as e: logger.exception(e) return KGWriterModel(status="FAILURE", metadata={"error": str(e)}) + finally: + notification_logger.setLevel(notification_level)