From e24707c8da4b898c141536f9ad9def52442b5911 Mon Sep 17 00:00:00 2001 From: Igor Ilic Date: Fri, 16 Jan 2026 13:43:01 +0100 Subject: [PATCH 1/3] fix: Resolve issue with parameter caching for engine creation --- .../databases/graph/get_graph_engine.py | 30 ++++++++++++++++++- .../databases/vector/create_vector_engine.py | 24 ++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/cognee/infrastructure/databases/graph/get_graph_engine.py b/cognee/infrastructure/databases/graph/get_graph_engine.py index c37af2102..bd2a6f68d 100644 --- a/cognee/infrastructure/databases/graph/get_graph_engine.py +++ b/cognee/infrastructure/databases/graph/get_graph_engine.py @@ -24,7 +24,6 @@ async def get_graph_engine() -> GraphDBInterface: return graph_client -@lru_cache def create_graph_engine( graph_database_provider, graph_file_path, @@ -35,6 +34,35 @@ def create_graph_engine( graph_database_port="", graph_database_key="", graph_dataset_database_handler="", +): + """ + Wrapper function to call create graph engine with caching. + For a detailed description, see _create_graph_engine. + """ + return _create_graph_engine( + graph_database_provider, + graph_file_path, + graph_database_url, + graph_database_name, + graph_database_username, + graph_database_password, + graph_database_port, + graph_database_key, + graph_dataset_database_handler, + ) + + +@lru_cache +def _create_graph_engine( + graph_database_provider, + graph_file_path, + graph_database_url="", + graph_database_name="", + graph_database_username="", + graph_database_password="", + graph_database_port="", + graph_database_key="", + graph_dataset_database_handler="", ): """ Create a graph engine based on the specified provider type. diff --git a/cognee/infrastructure/databases/vector/create_vector_engine.py b/cognee/infrastructure/databases/vector/create_vector_engine.py index 8a87f0339..cdf65514f 100644 --- a/cognee/infrastructure/databases/vector/create_vector_engine.py +++ b/cognee/infrastructure/databases/vector/create_vector_engine.py @@ -7,7 +7,6 @@ from cognee.infrastructure.databases.graph.config import get_graph_context_confi from functools import lru_cache -@lru_cache def create_vector_engine( vector_db_provider: str, vector_db_url: str, @@ -15,6 +14,29 @@ def create_vector_engine( vector_db_port: str = "", vector_db_key: str = "", vector_dataset_database_handler: str = "", +): + """ + Wrapper function to call create vector engine with caching. + For a detailed description, see _create_vector_engine. + """ + return _create_vector_engine( + vector_db_provider, + vector_db_url, + vector_db_name, + vector_db_port, + vector_db_key, + vector_dataset_database_handler, + ) + + +@lru_cache +def _create_vector_engine( + vector_db_provider: str, + vector_db_url: str, + vector_db_name: str, + vector_db_port: str = "", + vector_db_key: str = "", + vector_dataset_database_handler: str = "", ): """ Create a vector database engine based on the specified provider. From 9a9eacf8c893d8db04d6a44a181400cb798c9639 Mon Sep 17 00:00:00 2001 From: Igor Ilic Date: Fri, 16 Jan 2026 14:11:06 +0100 Subject: [PATCH 2/3] refactor: update test with cache change --- cognee/tests/test_permissions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cognee/tests/test_permissions.py b/cognee/tests/test_permissions.py index 10696441e..9d949c92b 100644 --- a/cognee/tests/test_permissions.py +++ b/cognee/tests/test_permissions.py @@ -41,14 +41,14 @@ async def _reset_engines_and_prune() -> None: except Exception: pass - from cognee.infrastructure.databases.graph.get_graph_engine import create_graph_engine from cognee.infrastructure.databases.relational.create_relational_engine import ( create_relational_engine, ) - from cognee.infrastructure.databases.vector.create_vector_engine import create_vector_engine + from cognee.infrastructure.databases.vector.create_vector_engine import _create_vector_engine + from cognee.infrastructure.databases.graph.get_graph_engine import _create_graph_engine - create_graph_engine.cache_clear() - create_vector_engine.cache_clear() + _create_graph_engine.cache_clear() + _create_vector_engine.cache_clear() create_relational_engine.cache_clear() await cognee.prune.prune_data() From e13877cb65249b5fc2a97f0cf7073f5fdc717b29 Mon Sep 17 00:00:00 2001 From: Igor Ilic Date: Fri, 16 Jan 2026 14:51:30 +0100 Subject: [PATCH 3/3] refactor: Update cache clear calls --- cognee/tests/test_search_db.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cognee/tests/test_search_db.py b/cognee/tests/test_search_db.py index 37b8ae45b..cdb2bbc64 100644 --- a/cognee/tests/test_search_db.py +++ b/cognee/tests/test_search_db.py @@ -48,14 +48,14 @@ async def _reset_engines_and_prune() -> None: # Engine might not exist yet pass - from cognee.infrastructure.databases.graph.get_graph_engine import create_graph_engine - from cognee.infrastructure.databases.vector.create_vector_engine import create_vector_engine + from cognee.infrastructure.databases.graph.get_graph_engine import _create_graph_engine + from cognee.infrastructure.databases.vector.create_vector_engine import _create_vector_engine from cognee.infrastructure.databases.relational.create_relational_engine import ( create_relational_engine, ) - create_graph_engine.cache_clear() - create_vector_engine.cache_clear() + _create_graph_engine.cache_clear() + _create_vector_engine.cache_clear() create_relational_engine.cache_clear() await cognee.prune.prune_data()