Skip to content

Commit

Permalink
Fix/cypher syntax warning (#170)
Browse files Browse the repository at this point in the history
* Remove Cypher syntax warning log

* Better solution, only disable for the KGWriter run method

* No comment
  • Loading branch information
stellasia authored Oct 8, 2024
1 parent caffe2c commit 88baae9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/neo4j_graphrag/experimental/components/kg_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)

0 comments on commit 88baae9

Please sign in to comment.