fix: Resolve issue with parameter caching for engine creation (#2004)
<!-- .github/pull_request_template.md --> ## Description Resolve issues with parameter caching for engine creation by making sure parameters are always called in the same order with the default values fixed ## Acceptance Criteria <!-- * Key requirements to the new feature or modification; * Proof that the changes work and meet the requirements; * Include instructions on how to verify the changes. Describe how to test it locally; * Proof that it's sufficiently tested. --> ## Type of Change <!-- Please check the relevant option --> - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [ ] Other (please specify): ## Screenshots/Videos (if applicable) <!-- Add screenshots or videos to help explain your changes --> ## Pre-submission Checklist <!-- Please check all boxes that apply before submitting your PR --> - [ ] **I have tested my changes thoroughly before submitting this PR** - [ ] **This PR contains minimal changes necessary to address the issue/feature** - [ ] My code follows the project's coding standards and style guidelines - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added necessary documentation (if applicable) - [ ] All new and existing tests pass - [ ] I have searched existing PRs to ensure this change hasn't been submitted already - [ ] I have linked any relevant issues in the description - [ ] My commits have clear and descriptive messages ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin.
This commit is contained in:
commit
ba94d1270c
4 changed files with 60 additions and 10 deletions
|
|
@ -24,7 +24,6 @@ async def get_graph_engine() -> GraphDBInterface:
|
||||||
return graph_client
|
return graph_client
|
||||||
|
|
||||||
|
|
||||||
@lru_cache
|
|
||||||
def create_graph_engine(
|
def create_graph_engine(
|
||||||
graph_database_provider,
|
graph_database_provider,
|
||||||
graph_file_path,
|
graph_file_path,
|
||||||
|
|
@ -35,6 +34,35 @@ def create_graph_engine(
|
||||||
graph_database_port="",
|
graph_database_port="",
|
||||||
graph_database_key="",
|
graph_database_key="",
|
||||||
graph_dataset_database_handler="",
|
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.
|
Create a graph engine based on the specified provider type.
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ from cognee.infrastructure.databases.graph.config import get_graph_context_confi
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
|
||||||
|
|
||||||
@lru_cache
|
|
||||||
def create_vector_engine(
|
def create_vector_engine(
|
||||||
vector_db_provider: str,
|
vector_db_provider: str,
|
||||||
vector_db_url: str,
|
vector_db_url: str,
|
||||||
|
|
@ -15,6 +14,29 @@ def create_vector_engine(
|
||||||
vector_db_port: str = "",
|
vector_db_port: str = "",
|
||||||
vector_db_key: str = "",
|
vector_db_key: str = "",
|
||||||
vector_dataset_database_handler: 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.
|
Create a vector database engine based on the specified provider.
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,14 @@ async def _reset_engines_and_prune() -> None:
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from cognee.infrastructure.databases.graph.get_graph_engine import create_graph_engine
|
|
||||||
from cognee.infrastructure.databases.relational.create_relational_engine import (
|
from cognee.infrastructure.databases.relational.create_relational_engine import (
|
||||||
create_relational_engine,
|
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_graph_engine.cache_clear()
|
||||||
create_vector_engine.cache_clear()
|
_create_vector_engine.cache_clear()
|
||||||
create_relational_engine.cache_clear()
|
create_relational_engine.cache_clear()
|
||||||
|
|
||||||
await cognee.prune.prune_data()
|
await cognee.prune.prune_data()
|
||||||
|
|
|
||||||
|
|
@ -48,14 +48,14 @@ async def _reset_engines_and_prune() -> None:
|
||||||
# Engine might not exist yet
|
# Engine might not exist yet
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from cognee.infrastructure.databases.graph.get_graph_engine import create_graph_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.vector.create_vector_engine import _create_vector_engine
|
||||||
from cognee.infrastructure.databases.relational.create_relational_engine import (
|
from cognee.infrastructure.databases.relational.create_relational_engine import (
|
||||||
create_relational_engine,
|
create_relational_engine,
|
||||||
)
|
)
|
||||||
|
|
||||||
create_graph_engine.cache_clear()
|
_create_graph_engine.cache_clear()
|
||||||
create_vector_engine.cache_clear()
|
_create_vector_engine.cache_clear()
|
||||||
create_relational_engine.cache_clear()
|
create_relational_engine.cache_clear()
|
||||||
|
|
||||||
await cognee.prune.prune_data()
|
await cognee.prune.prune_data()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue