-
Notifications
You must be signed in to change notification settings - Fork 1k
test: fix weighted edges example #1745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Please make sure all the checkboxes are checked:
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe PR introduces backend access control with multi-user database isolation, adds a custom pipeline execution API, extends the Edge model with descriptive text labels, refactors data indexing workflows, and implements session persistence functionality. Configuration changes default backend access control to enabled, with multi-user support validation. New tests validate session persistence, edge text handling, and indexing changes. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant API as persist_sessions_in_knowledge_graph_pipeline
participant AuthZ as Authorization Check
participant Context as Global Context
participant MemifyPipeline as Memify Pipeline
participant Graph as Knowledge Graph
User->>API: Call with session_ids, dataset
API->>AuthZ: Check user write access to dataset
AuthZ-->>API: Access granted/denied
alt Access Denied
API-->>User: CogneeValidationError
else Access Granted
API->>Context: Set dataset & owner context
API->>API: Build extraction tasks (extract_sessions)
API->>API: Build enrichment tasks (cognify_session)
API->>MemifyPipeline: Run pipeline with tasks & empty data
MemifyPipeline->>Graph: Persist sessions as nodes/edges
MemifyPipeline-->>API: Result
API-->>User: Return pipeline result
end
sequenceDiagram
participant Caller
participant CustomPipeline as run_custom_pipeline
participant Executor as Pipeline Executor
participant TaskRunner as Task Runner
participant DataStores as Data Stores
Caller->>CustomPipeline: tasks, data, dataset, user, configs
CustomPipeline->>Executor: Resolve executor (background flag)
CustomPipeline->>CustomPipeline: Set global context (dataset, user)
CustomPipeline->>Executor: Invoke with tasks, data, DB configs
Executor->>TaskRunner: Execute task sequence
TaskRunner->>DataStores: Apply operations
DataStores-->>TaskRunner: Results
TaskRunner-->>Executor: Task completion
Executor-->>CustomPipeline: Return result
CustomPipeline-->>Caller: Pipeline result
sequenceDiagram
participant Extract as extract_user_sessions
participant Auth as Current User Context
participant Cache as Cache Engine
participant Yield as Caller
Yield->>Extract: Call with session_ids
Extract->>Auth: Get current user
alt User not found
Extract-->>Yield: CogneeSystemError
else
Extract->>Cache: Get cache engine
alt Cache unavailable
Extract-->>Yield: CogneeSystemError
else
loop For each session_id
Extract->>Cache: Retrieve Q&A pairs
Extract->>Extract: Format session string
Extract-->>Yield: Yield session data
end
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Key areas requiring extra attention:
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (3 warnings)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cognee/tests/test_add_docling_document.py (1)
42-52: Handle both enabled and disabled backend access control states.This test hardcodes access to
answer[0]["search_result"][0], which only exists whenbackend_access_control_enabled()is True. When backend access control is disabled (or whenmulti_user_support_possible()returns False), the search results are returned directly without the"search_result"wrapper, causing a KeyError.Update the assertions to conditionally handle both cases, matching the pattern used in
test_search_db.py:from cognee.context_global_variables import backend_access_control_enabled # After each cognee.search() call: if backend_access_control_enabled(): lowercase_answer = answer[0]["search_result"][0].lower() else: lowercase_answer = answer[0].lower()
🧹 Nitpick comments (7)
cognee/tests/test_feedback_enrichment.py (1)
171-174: Consider refactoring to pytest pattern.This test uses a standalone script structure with
asyncio.run(main())instead of pytest's async test pattern. According to the coding guidelines, async tests should usepytest.mark.asyncio.Consider refactoring to:
-if __name__ == "__main__": - import asyncio - - asyncio.run(main()) +import pytest + +@pytest.mark.asyncio +async def test_feedback_enrichment(): + """End-to-end integration test for feedback enrichment feature.""" + # Move the main() function body hereThis would:
- Enable test discovery and execution via
pytest- Improve CI/CD integration
- Provide better test reporting and fixtures support
As per coding guidelines.
examples/python/run_custom_pipeline_example.py (1)
15-84: Consider adding error handling for production-ready examples.The example demonstrates the API well but lacks error handling for common failures (LLM API errors, database connection issues, etc.). While this keeps the example concise, consider adding at least a try-except block around the pipeline operations to show best practices.
Example pattern:
async def main(): + try: # Create a clean slate for cognee -- reset data and system state print("Resetting cognee data...") await cognee.prune.prune_data() # ... rest of the code ... + except Exception as e: + logger.error(f"Pipeline execution failed: {e}") + raisecognee/tests/unit/infrastructure/databases/test_index_data_points.py (1)
12-27: Test coverage is good but consider edge cases.The test validates the happy path well. Consider adding tests for:
- Empty data_points list
- Data points with no index_fields
- Data points with multiple index_fields
- Batch size smaller than data points count
Example:
@pytest.mark.asyncio async def test_index_data_points_with_empty_list(): """Test that index_data_points handles empty list gracefully.""" mock_vector_engine = AsyncMock() with patch.dict( index_data_points.__globals__, {"get_vector_engine": lambda: mock_vector_engine}, ): result = await index_data_points([]) assert result == [] assert mock_vector_engine.create_vector_index.await_count == 0cognee/tests/test_search_db.py (1)
150-150: Move import to module level.The import of
backend_access_control_enabledis placed inside the function. Per Python conventions, imports should be at the module level unless there's a specific reason (e.g., avoiding circular imports or optional dependencies).Apply this diff to move the import to the top of the file:
from cognee.modules.retrieval.graph_summary_completion_retriever import ( GraphSummaryCompletionRetriever, ) from cognee.shared.logging_utils import get_logger from cognee.modules.search.types import SearchType from collections import Counter +from cognee.context_global_variables import backend_access_control_enabled logger = get_logger()And remove it from line 150:
- - from cognee.context_global_variables import backend_access_control_enabled - if backend_access_control_enabled():cognee/modules/search/methods/search.py (1)
159-202: Consider removing unnecessaryelseclause (optional).The
elseclause at line 159 is technically unnecessary since theifblock at line 159 returns. Removing it would reduce indentation and align with Pylint's suggestion.However, the current structure makes the two branches explicit, which may improve readability. This is a style preference, and the current code is acceptable.
cognee/modules/chunking/models/DocumentChunk.py (1)
35-35: Update the docstring to reflect the new tuple type.The docstring at line 25 states that
containsis "A list of entities or events contained within the chunk" but the type now includestuple[Edge, Entity]. Please update the docstring to document this new capability.Apply this diff to update the docstring:
- - contains: A list of entities or events contained within the chunk (default is None). + - contains: A list of entities, events, or (Edge, Entity) tuples contained within the chunk (default is None).cognee/tests/unit/infrastructure/databases/test_index_graph_edges.py (1)
62-67: Remove unused mock from patch dict.Line 66 includes
"get_vector_engine": lambda: AsyncMock()in the patch dict, but this mock is not used in the test. The test validates initialization failure viaget_graph_engine, so the vector engine mock appears to be leftover code.Apply this diff to remove the unused mock:
with patch.dict( index_graph_edges.__globals__, { "get_graph_engine": AsyncMock(side_effect=Exception("Graph engine failed")), - "get_vector_engine": lambda: AsyncMock(), }, ):
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (7)
.github/workflows/e2e_tests.ymlis excluded by!**/*.yml.github/workflows/examples_tests.ymlis excluded by!**/*.yml.github/workflows/search_db_tests.ymlis excluded by!**/*.yml.github/workflows/test_different_operating_systems.ymlis excluded by!**/*.yml.github/workflows/test_suites.ymlis excluded by!**/*.yml.github/workflows/weighted_edges_tests.ymlis excluded by!**/*.ymldocker-compose.ymlis excluded by!**/*.yml
📒 Files selected for processing (45)
.env.template(1 hunks)cognee/__init__.py(1 hunks)cognee/api/client.py(2 hunks)cognee/context_global_variables.py(3 hunks)cognee/infrastructure/databases/vector/create_vector_engine.py(1 hunks)cognee/infrastructure/engine/models/Edge.py(2 hunks)cognee/memify_pipelines/persist_sessions_in_knowledge_graph.py(1 hunks)cognee/modules/chunking/models/DocumentChunk.py(2 hunks)cognee/modules/graph/cognee_graph/CogneeGraph.py(1 hunks)cognee/modules/graph/utils/expand_with_nodes_and_edges.py(2 hunks)cognee/modules/graph/utils/resolve_edges_to_text.py(1 hunks)cognee/modules/retrieval/utils/brute_force_triplet_search.py(1 hunks)cognee/modules/run_custom_pipeline/__init__.py(1 hunks)cognee/modules/run_custom_pipeline/run_custom_pipeline.py(1 hunks)cognee/modules/search/methods/search.py(3 hunks)cognee/modules/users/methods/get_authenticated_user.py(1 hunks)cognee/modules/users/methods/get_default_user.py(1 hunks)cognee/tasks/memify/__init__.py(1 hunks)cognee/tasks/memify/cognify_session.py(1 hunks)cognee/tasks/memify/extract_user_sessions.py(1 hunks)cognee/tasks/storage/index_data_points.py(1 hunks)cognee/tasks/storage/index_graph_edges.py(3 hunks)cognee/tests/test_add_docling_document.py(1 hunks)cognee/tests/test_conversation_history.py(2 hunks)cognee/tests/test_edge_ingestion.py(1 hunks)cognee/tests/test_feedback_enrichment.py(1 hunks)cognee/tests/test_library.py(1 hunks)cognee/tests/test_load.py(1 hunks)cognee/tests/test_relational_db_migration.py(1 hunks)cognee/tests/test_search_db.py(1 hunks)cognee/tests/unit/api/test_conditional_authentication_endpoints.py(6 hunks)cognee/tests/unit/infrastructure/databases/test_index_data_points.py(1 hunks)cognee/tests/unit/infrastructure/databases/test_index_graph_edges.py(2 hunks)cognee/tests/unit/modules/memify_tasks/test_cognify_session.py(1 hunks)cognee/tests/unit/modules/memify_tasks/test_extract_user_sessions.py(1 hunks)cognee/tests/unit/modules/users/test_conditional_authentication.py(0 hunks)entrypoint.sh(1 hunks)examples/python/agentic_reasoning_procurement_example.py(1 hunks)examples/python/code_graph_example.py(2 hunks)examples/python/conversation_session_persistence_example.py(1 hunks)examples/python/feedback_enrichment_minimal_example.py(0 hunks)examples/python/memify_coding_agent_example.py(1 hunks)examples/python/relational_database_migration_example.py(1 hunks)examples/python/run_custom_pipeline_example.py(1 hunks)examples/python/simple_example.py(0 hunks)
💤 Files with no reviewable changes (3)
- examples/python/simple_example.py
- examples/python/feedback_enrichment_minimal_example.py
- cognee/tests/unit/modules/users/test_conditional_authentication.py
🧰 Additional context used
📓 Path-based instructions (5)
{cognee,cognee-mcp,distributed,examples,alembic}/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
{cognee,cognee-mcp,distributed,examples,alembic}/**/*.py: Use 4-space indentation; name modules and functions in snake_case; name classes in PascalCase (Python)
Adhere to ruff rules, including import hygiene and configured line length (100)
Keep Python lines ≤ 100 characters
Files:
cognee/tests/test_library.pycognee/tests/unit/api/test_conditional_authentication_endpoints.pycognee/modules/users/methods/get_authenticated_user.pycognee/modules/graph/cognee_graph/CogneeGraph.pyexamples/python/agentic_reasoning_procurement_example.pycognee/tasks/storage/index_data_points.pycognee/modules/retrieval/utils/brute_force_triplet_search.pycognee/tests/unit/infrastructure/databases/test_index_graph_edges.pycognee/tests/test_edge_ingestion.pycognee/tests/unit/modules/memify_tasks/test_extract_user_sessions.pyexamples/python/conversation_session_persistence_example.pycognee/modules/search/methods/search.pycognee/modules/chunking/models/DocumentChunk.pycognee/tests/test_feedback_enrichment.pyexamples/python/relational_database_migration_example.pycognee/tests/test_search_db.pycognee/modules/users/methods/get_default_user.pycognee/tests/test_relational_db_migration.pycognee/infrastructure/databases/vector/create_vector_engine.pyexamples/python/code_graph_example.pycognee/context_global_variables.pycognee/tests/test_add_docling_document.pycognee/infrastructure/engine/models/Edge.pycognee/tests/unit/modules/memify_tasks/test_cognify_session.pycognee/tasks/memify/cognify_session.pycognee/__init__.pyexamples/python/memify_coding_agent_example.pyexamples/python/run_custom_pipeline_example.pycognee/tasks/memify/extract_user_sessions.pycognee/api/client.pycognee/modules/run_custom_pipeline/run_custom_pipeline.pycognee/modules/run_custom_pipeline/__init__.pycognee/tests/test_conversation_history.pycognee/tests/unit/infrastructure/databases/test_index_data_points.pycognee/modules/graph/utils/resolve_edges_to_text.pycognee/memify_pipelines/persist_sessions_in_knowledge_graph.pycognee/tasks/memify/__init__.pycognee/modules/graph/utils/expand_with_nodes_and_edges.pycognee/tests/test_load.pycognee/tasks/storage/index_graph_edges.py
cognee/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
cognee/**/*.py: Public APIs in the core library should be type-annotated where practical
Prefer explicit, structured error handling and use shared logging utilities from cognee.shared.logging_utils
Files:
cognee/tests/test_library.pycognee/tests/unit/api/test_conditional_authentication_endpoints.pycognee/modules/users/methods/get_authenticated_user.pycognee/modules/graph/cognee_graph/CogneeGraph.pycognee/tasks/storage/index_data_points.pycognee/modules/retrieval/utils/brute_force_triplet_search.pycognee/tests/unit/infrastructure/databases/test_index_graph_edges.pycognee/tests/test_edge_ingestion.pycognee/tests/unit/modules/memify_tasks/test_extract_user_sessions.pycognee/modules/search/methods/search.pycognee/modules/chunking/models/DocumentChunk.pycognee/tests/test_feedback_enrichment.pycognee/tests/test_search_db.pycognee/modules/users/methods/get_default_user.pycognee/tests/test_relational_db_migration.pycognee/infrastructure/databases/vector/create_vector_engine.pycognee/context_global_variables.pycognee/tests/test_add_docling_document.pycognee/infrastructure/engine/models/Edge.pycognee/tests/unit/modules/memify_tasks/test_cognify_session.pycognee/tasks/memify/cognify_session.pycognee/__init__.pycognee/tasks/memify/extract_user_sessions.pycognee/api/client.pycognee/modules/run_custom_pipeline/run_custom_pipeline.pycognee/modules/run_custom_pipeline/__init__.pycognee/tests/test_conversation_history.pycognee/tests/unit/infrastructure/databases/test_index_data_points.pycognee/modules/graph/utils/resolve_edges_to_text.pycognee/memify_pipelines/persist_sessions_in_knowledge_graph.pycognee/tasks/memify/__init__.pycognee/modules/graph/utils/expand_with_nodes_and_edges.pycognee/tests/test_load.pycognee/tasks/storage/index_graph_edges.py
cognee/tests/**/test_*.py
📄 CodeRabbit inference engine (AGENTS.md)
cognee/tests/**/test_*.py: Name test files as test_*.py
Use pytest.mark.asyncio for async tests
Tests should avoid external state; rely on fixtures and CI-provided env vars when providers are required
Files:
cognee/tests/test_library.pycognee/tests/unit/api/test_conditional_authentication_endpoints.pycognee/tests/unit/infrastructure/databases/test_index_graph_edges.pycognee/tests/test_edge_ingestion.pycognee/tests/unit/modules/memify_tasks/test_extract_user_sessions.pycognee/tests/test_feedback_enrichment.pycognee/tests/test_search_db.pycognee/tests/test_relational_db_migration.pycognee/tests/test_add_docling_document.pycognee/tests/unit/modules/memify_tasks/test_cognify_session.pycognee/tests/test_conversation_history.pycognee/tests/unit/infrastructure/databases/test_index_data_points.pycognee/tests/test_load.py
cognee/tests/unit/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Place unit tests under cognee/tests/unit/
Files:
cognee/tests/unit/api/test_conditional_authentication_endpoints.pycognee/tests/unit/infrastructure/databases/test_index_graph_edges.pycognee/tests/unit/modules/memify_tasks/test_extract_user_sessions.pycognee/tests/unit/modules/memify_tasks/test_cognify_session.pycognee/tests/unit/infrastructure/databases/test_index_data_points.py
examples/python/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
When adding public APIs, provide or update targeted examples under examples/python/
Files:
examples/python/agentic_reasoning_procurement_example.pyexamples/python/conversation_session_persistence_example.pyexamples/python/relational_database_migration_example.pyexamples/python/code_graph_example.pyexamples/python/memify_coding_agent_example.pyexamples/python/run_custom_pipeline_example.py
🧠 Learnings (8)
📚 Learning: 2025-10-27T09:21:14.154Z
Learnt from: CR
Repo: topoteretes/cognee PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-27T09:21:14.154Z
Learning: Applies to cognee/tests/**/test_*.py : Tests should avoid external state; rely on fixtures and CI-provided env vars when providers are required
Applied to files:
cognee/tests/unit/api/test_conditional_authentication_endpoints.py
📚 Learning: 2024-11-13T16:17:17.646Z
Learnt from: hajdul88
Repo: topoteretes/cognee PR: 196
File: cognee/modules/graph/cognee_graph/CogneeGraphElements.py:82-90
Timestamp: 2024-11-13T16:17:17.646Z
Learning: In `cognee/modules/graph/cognee_graph/CogneeGraphElements.py`, within the `Edge` class, nodes and edges can have different dimensions, and it's acceptable for them not to match.
Applied to files:
cognee/modules/graph/cognee_graph/CogneeGraph.pycognee/modules/chunking/models/DocumentChunk.pycognee/modules/graph/utils/expand_with_nodes_and_edges.py
📚 Learning: 2024-11-13T16:06:32.576Z
Learnt from: hajdul88
Repo: topoteretes/cognee PR: 196
File: cognee/modules/graph/cognee_graph/CogneeGraph.py:32-38
Timestamp: 2024-11-13T16:06:32.576Z
Learning: In `CogneeGraph.py`, within the `CogneeGraph` class, it's intentional to add skeleton edges in both the `add_edge` method and the `project_graph_from_db` method to ensure that edges are added to the graph and to the nodes.
Applied to files:
cognee/modules/graph/cognee_graph/CogneeGraph.pycognee/modules/retrieval/utils/brute_force_triplet_search.pycognee/infrastructure/engine/models/Edge.pycognee/modules/graph/utils/expand_with_nodes_and_edges.py
📚 Learning: 2024-12-04T18:37:55.092Z
Learnt from: hajdul88
Repo: topoteretes/cognee PR: 251
File: cognee/tests/infrastructure/databases/test_index_graph_edges.py:0-0
Timestamp: 2024-12-04T18:37:55.092Z
Learning: In the `index_graph_edges` function, both graph engine and vector engine initialization failures are handled within the same try-except block, so a single test covers both cases.
Applied to files:
cognee/tests/unit/infrastructure/databases/test_index_graph_edges.pycognee/tests/unit/infrastructure/databases/test_index_data_points.pycognee/tasks/storage/index_graph_edges.py
📚 Learning: 2025-10-27T09:21:14.154Z
Learnt from: CR
Repo: topoteretes/cognee PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-27T09:21:14.154Z
Learning: Applies to cognee/tests/**/test_*.py : Use pytest.mark.asyncio for async tests
Applied to files:
cognee/tests/unit/modules/memify_tasks/test_extract_user_sessions.pycognee/tests/unit/modules/memify_tasks/test_cognify_session.py
📚 Learning: 2024-11-13T14:55:05.912Z
Learnt from: 0xideas
Repo: topoteretes/cognee PR: 205
File: cognee/tests/unit/processing/chunks/chunk_by_paragraph_test.py:7-7
Timestamp: 2024-11-13T14:55:05.912Z
Learning: When changes are made to the chunking implementation in `cognee/tasks/chunks`, the ground truth values in the corresponding tests in `cognee/tests/unit/processing/chunks` need to be updated accordingly.
Applied to files:
cognee/modules/chunking/models/DocumentChunk.py
📚 Learning: 2025-10-27T09:21:14.154Z
Learnt from: CR
Repo: topoteretes/cognee PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-27T09:21:14.154Z
Learning: Applies to cognee/tests/unit/**/*.py : Place unit tests under cognee/tests/unit/
Applied to files:
cognee/tests/unit/modules/memify_tasks/test_cognify_session.py
📚 Learning: 2025-10-27T09:21:14.154Z
Learnt from: CR
Repo: topoteretes/cognee PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-27T09:21:14.154Z
Learning: Applies to examples/python/**/*.py : When adding public APIs, provide or update targeted examples under examples/python/
Applied to files:
examples/python/run_custom_pipeline_example.py
🧬 Code graph analysis (28)
cognee/tests/test_library.py (1)
cognee/modules/search/types/SearchType.py (1)
SearchType(4-19)
cognee/modules/users/methods/get_authenticated_user.py (1)
cognee/context_global_variables.py (1)
backend_access_control_enabled(36-50)
cognee/tasks/storage/index_data_points.py (5)
cognee/infrastructure/databases/vector/get_vector_engine.py (1)
get_vector_engine(5-7)cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py (2)
create_vector_index(292-295)index_data_points(297-309)cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py (2)
create_vector_index(248-249)index_data_points(251-263)cognee/infrastructure/databases/vector/chromadb/ChromaDBAdapter.py (2)
create_vector_index(285-295)index_data_points(297-319)cognee/infrastructure/databases/vector/embeddings/EmbeddingEngine.py (1)
get_batch_size(38-45)
cognee/tests/unit/infrastructure/databases/test_index_graph_edges.py (1)
cognee/tasks/storage/index_graph_edges.py (1)
index_graph_edges(42-77)
cognee/tests/unit/modules/memify_tasks/test_extract_user_sessions.py (2)
cognee/tasks/memify/extract_user_sessions.py (1)
extract_user_sessions(12-73)cognee/exceptions/exceptions.py (1)
CogneeSystemError(38-49)
examples/python/conversation_session_persistence_example.py (5)
cognee/api/v1/visualize/visualize.py (1)
visualize_graph(14-27)cognee/memify_pipelines/persist_sessions_in_knowledge_graph.py (1)
persist_sessions_in_knowledge_graph_pipeline(19-55)cognee/modules/search/types/SearchType.py (1)
SearchType(4-19)cognee/modules/users/methods/get_default_user.py (1)
get_default_user(13-36)cognee/shared/logging_utils.py (1)
get_logger(212-224)
cognee/modules/search/methods/search.py (1)
cognee/context_global_variables.py (1)
backend_access_control_enabled(36-50)
cognee/modules/chunking/models/DocumentChunk.py (2)
cognee/infrastructure/engine/models/Edge.py (1)
Edge(5-38)cognee/modules/engine/models/Event.py (1)
Event(8-16)
cognee/tests/test_search_db.py (1)
cognee/context_global_variables.py (1)
backend_access_control_enabled(36-50)
cognee/modules/users/methods/get_default_user.py (1)
cognee/modules/users/models/User.py (1)
User(13-40)
cognee/context_global_variables.py (2)
cognee/infrastructure/databases/vector/config.py (1)
get_vectordb_context_config(84-90)cognee/infrastructure/databases/graph/config.py (1)
get_graph_context_config(140-148)
cognee/tests/unit/modules/memify_tasks/test_cognify_session.py (2)
cognee/tasks/memify/cognify_session.py (1)
cognify_session(9-40)cognee/exceptions/exceptions.py (2)
CogneeValidationError(52-63)CogneeSystemError(38-49)
cognee/tasks/memify/cognify_session.py (2)
cognee/exceptions/exceptions.py (2)
CogneeValidationError(52-63)CogneeSystemError(38-49)cognee/shared/logging_utils.py (3)
get_logger(212-224)info(205-205)debug(209-209)
cognee/__init__.py (1)
cognee/modules/run_custom_pipeline/run_custom_pipeline.py (1)
run_custom_pipeline(14-69)
examples/python/run_custom_pipeline_example.py (8)
cognee/modules/users/methods/get_default_user.py (1)
get_default_user(13-36)cognee/shared/logging_utils.py (1)
setup_logging(288-555)cognee/modules/pipelines/tasks/task.py (1)
Task(5-97)cognee/modules/search/types/SearchType.py (1)
SearchType(4-19)cognee/tasks/ingestion/ingest_data.py (1)
ingest_data(25-199)cognee/tasks/ingestion/resolve_data_directories.py (1)
resolve_data_directories(10-84)cognee/modules/run_custom_pipeline/run_custom_pipeline.py (1)
run_custom_pipeline(14-69)cognee/api/v1/cognify/cognify.py (1)
get_default_tasks(246-297)
cognee/tasks/memify/extract_user_sessions.py (3)
cognee/exceptions/exceptions.py (1)
CogneeSystemError(38-49)cognee/infrastructure/databases/cache/get_cache_engine.py (1)
get_cache_engine(54-67)cognee/shared/logging_utils.py (2)
get_logger(212-224)info(205-205)
cognee/api/client.py (1)
cognee/shared/logging_utils.py (2)
setup_logging(288-555)info(205-205)
cognee/modules/run_custom_pipeline/run_custom_pipeline.py (3)
cognee/shared/logging_utils.py (1)
get_logger(212-224)cognee/modules/pipelines/tasks/task.py (1)
Task(5-97)cognee/modules/pipelines/layers/pipeline_execution_mode.py (1)
get_pipeline_executor(117-127)
cognee/modules/run_custom_pipeline/__init__.py (1)
cognee/modules/run_custom_pipeline/run_custom_pipeline.py (1)
run_custom_pipeline(14-69)
cognee/tests/test_conversation_history.py (3)
cognee/infrastructure/databases/graph/get_graph_engine.py (1)
get_graph_engine(10-24)cognee/memify_pipelines/persist_sessions_in_knowledge_graph.py (1)
persist_sessions_in_knowledge_graph_pipeline(19-55)cognee/infrastructure/databases/vector/get_vector_engine.py (1)
get_vector_engine(5-7)
cognee/tests/unit/infrastructure/databases/test_index_data_points.py (2)
cognee/tasks/storage/index_data_points.py (1)
index_data_points(10-65)cognee/infrastructure/engine/models/DataPoint.py (1)
DataPoint(20-220)
cognee/modules/graph/utils/resolve_edges_to_text.py (2)
cognee/infrastructure/engine/models/Edge.py (1)
Edge(5-38)cognee/modules/retrieval/graph_completion_retriever.py (1)
resolve_edges_to_text(60-74)
cognee/memify_pipelines/persist_sessions_in_knowledge_graph.py (6)
cognee/context_global_variables.py (2)
set_database_global_context_variables(53-113)set_session_user_context_variable(23-24)cognee/exceptions/exceptions.py (1)
CogneeValidationError(52-63)cognee/modules/data/methods/get_authorized_existing_datasets.py (1)
get_authorized_existing_datasets(11-39)cognee/modules/pipelines/tasks/task.py (1)
Task(5-97)cognee/tasks/memify/extract_user_sessions.py (1)
extract_user_sessions(12-73)cognee/tasks/memify/cognify_session.py (1)
cognify_session(9-40)
cognee/tasks/memify/__init__.py (2)
cognee/tasks/memify/cognify_session.py (1)
cognify_session(9-40)cognee/tasks/memify/extract_user_sessions.py (1)
extract_user_sessions(12-73)
entrypoint.sh (1)
cognee/shared/logging_utils.py (2)
debug(209-209)error(207-207)
cognee/modules/graph/utils/expand_with_nodes_and_edges.py (1)
cognee/infrastructure/engine/models/Edge.py (1)
Edge(5-38)
cognee/tests/test_load.py (3)
cognee/modules/search/types/SearchType.py (1)
SearchType(4-19)cognee/shared/logging_utils.py (1)
get_logger(212-224)cognee/api/v1/config/config.py (2)
data_root_directory(36-38)system_root_directory(18-33)
cognee/tasks/storage/index_graph_edges.py (4)
cognee/modules/engine/utils/generate_edge_id.py (1)
generate_edge_id(4-5)cognee/infrastructure/databases/graph/get_graph_engine.py (1)
get_graph_engine(10-24)cognee/tasks/storage/index_data_points.py (1)
index_data_points(10-65)cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py (1)
index_data_points(251-263)
🪛 Pylint (4.0.2)
cognee/tests/unit/api/test_conditional_authentication_endpoints.py
[error] 1-1: Unrecognized option found: suggestion-mode
(E0015)
cognee/tests/unit/modules/memify_tasks/test_extract_user_sessions.py
[error] 1-1: Unrecognized option found: suggestion-mode
(E0015)
examples/python/conversation_session_persistence_example.py
[error] 1-1: Unrecognized option found: suggestion-mode
(E0015)
cognee/modules/search/methods/search.py
[refactor] 159-202: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it
(R1705)
cognee/context_global_variables.py
[refactor] 38-49: Unnecessary "elif" after "return", remove the leading "el" from "elif"
(R1705)
cognee/infrastructure/engine/models/Edge.py
[error] 1-1: Unrecognized option found: suggestion-mode
(E0015)
cognee/tests/unit/modules/memify_tasks/test_cognify_session.py
[error] 1-1: Unrecognized option found: suggestion-mode
(E0015)
cognee/tasks/memify/cognify_session.py
[error] 1-1: Unrecognized option found: suggestion-mode
(E0015)
examples/python/run_custom_pipeline_example.py
[error] 1-1: Unrecognized option found: suggestion-mode
(E0015)
cognee/tasks/memify/extract_user_sessions.py
[error] 1-1: Unrecognized option found: suggestion-mode
(E0015)
cognee/modules/run_custom_pipeline/run_custom_pipeline.py
[error] 1-1: Unrecognized option found: suggestion-mode
(E0015)
[refactor] 14-14: Too many arguments (9/5)
(R0913)
[refactor] 14-14: Too many positional arguments (9/5)
(R0917)
cognee/tests/unit/infrastructure/databases/test_index_data_points.py
[error] 1-1: Unrecognized option found: suggestion-mode
(E0015)
[refactor] 7-7: Too few public methods (0/2)
(R0903)
cognee/modules/graph/utils/resolve_edges_to_text.py
[error] 1-1: Unrecognized option found: suggestion-mode
(E0015)
cognee/memify_pipelines/persist_sessions_in_knowledge_graph.py
[error] 1-1: Unrecognized option found: suggestion-mode
(E0015)
cognee/tasks/storage/index_graph_edges.py
[error] 1-1: Unrecognized option found: suggestion-mode
(E0015)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Test Weighted Edges with Different Graph Databases (kuzu)
- GitHub Check: Test Weighted Edges Examples
- GitHub Check: Test Weighted Edges with Different Graph Databases (neo4j)
🔇 Additional comments (27)
examples/python/relational_database_migration_example.py (1)
34-36: The review comment is based on incorrect assumptions about how the code works.The code is handling the environment variable correctly:
Import-time check concern is invalid: The
backend_access_control_enabled()function incognee/context_global_variables.pyusesos.environ.get("ENABLE_BACKEND_ACCESS_CONTROL", None)and performs comparison with.lower() == "true", which is called at runtime when functions execute, not during module import. Setting the environment variable before callingmain()is sufficient.String "false" handling is correct: The existing code uses
.lower() == "true"for comparison, which safely handles string values. Setting"false"results in"false".lower() == "true"evaluating toFalse, which is the intended behavior. This pattern is also used in alembic migrations (b9274c27a25a_kuzu_11_migration.py:27), confirming it's an established and correct pattern throughout the codebase.The code in the example is consistent with how this feature is used elsewhere, including in tests and migrations. No changes are needed.
Likely an incorrect or invalid review comment.
examples/python/memify_coding_agent_example.py (1)
92-93: Verify that this file should be included in this PR.The PR title is "test: fix weighted edges example", but this file is
memify_coding_agent_example.py. Additionally, the PR description mentions changing OpenAI API keys, but the actual change modifies the search result structure to use nested indexing. Please confirm that:
- This file should be part of this PR
- The PR title and description accurately reflect all changes being made
cognee/tests/test_feedback_enrichment.py (1)
136-136: No issues found. The dataset parameter change is correct and intentional.The verification confirms this is a successful fix, not a bug:
- Git history shows commit "45bb3130 fix: Use same dataset name accross cognee calls," confirming intent
- All Cognee API calls (
add,cognify,memify) now consistently use the same dataset ("feedback_enrichment_test"), improving clarity- The test prunes data upfront, preventing contamination across operations—aligning with the retrieved learning pattern
memifyis designed to operate on existing knowledge graphs; using the same dataset is correctThe code is working as intended.
entrypoint.sh (1)
46-51: LGTM! Good containerization practices.The use of
execensures proper signal handling and makes the server process PID 1, while logging to stdout/stderr (--access-logfile -and--error-logfile -) follows containerization best practices.examples/python/run_custom_pipeline_example.py (2)
1-8: LGTM! Clean imports.Import structure follows Python conventions and includes necessary dependencies for the example.
9-13: Good documentation for setup prerequisites.Clear instructions for users to configure their environment before running the example.
cognee/tests/unit/infrastructure/databases/test_index_data_points.py (1)
7-9: LGTM! TestDataPoint class is appropriately minimal for testing.The Pylint warning about too few public methods (R0903) is a false positive for test fixtures and data classes.
cognee/modules/run_custom_pipeline/__init__.py (1)
1-1: LGTM! Standard module initialization.Clean re-export pattern that makes
run_custom_pipelineavailable as part of the public API.cognee/__init__.py (1)
22-22: LGTM! New public API properly exposed with example.The addition of
run_custom_pipelineto the public API is clean and follows the existing pattern. An example has been provided atexamples/python/run_custom_pipeline_example.pyas per coding guidelines.Based on learnings
.env.template (1)
172-174: Verify if this breaking change is documented and intentional for this PR.Changing
ENABLE_BACKEND_ACCESS_CONTROLfromfalsetotrueby default is a breaking change, but it includes a runtime safeguard. The code incognee/context_global_variables.pyexplicitly raises anEnvironmentErrorwith a clear message if unsupported databases are used, preventing silent breakage.However:
- No migration guide or breaking change documentation was found in the repository (no CHANGELOG, release notes, or migration docs).
- The PR description doesn't mention this change—it references fixing a weighted edges example and OpenAI key changes.
- The .env.template comment acknowledges users should "disable mode when using not supported graph/vector databases," but doesn't indicate this was previously the default.
Verify that:
- This change is intentional for this PR and aligns with its stated objectives.
- Migration documentation will be added to release notes or a migration guide for users with unsupported database providers.
- The error message is sufficiently clear for users encountering this on startup.
examples/python/agentic_reasoning_procurement_example.py (1)
171-171: Ensure the nested result structure matches the search implementation.The change from
results[category][0]toresults[category][0]["search_result"][0]aligns with backend access control changes. Verify this example still runs correctly with the new structure.cognee/modules/retrieval/utils/brute_force_triplet_search.py (1)
74-74: LGTM!The addition of
edge_textto the edge properties projection aligns with the Edge model enhancement and ensures the new field is available in the memory fragment.cognee/modules/graph/cognee_graph/CogneeGraph.py (1)
174-177: LGTM!The edge distance lookup now correctly prefers
edge_textwhen available and gracefully falls back torelationship_type. This maintains backward compatibility while supporting the new edge text functionality.cognee/modules/search/methods/search.py (1)
11-11: LGTM!The refactoring to use
backend_access_control_enabled()centralizes the access control logic and improves maintainability by replacing scattered environment variable checks with a dedicated function.Also applies to: 77-77
cognee/modules/users/methods/get_authenticated_user.py (1)
8-8: LGTM!The integration of
backend_access_control_enabled()correctly combines with the existingREQUIRE_AUTHENTICATIONenvironment variable, ensuring authentication is required when either condition is true.Also applies to: 14-17
cognee/tasks/memify/__init__.py (1)
3-4: LGTM!The package-level exports follow Python conventions and properly expose the new session-related functionality.
cognee/tests/unit/infrastructure/databases/test_index_graph_edges.py (2)
7-33: LGTM!The test correctly validates the new delegation pathway to
index_data_pointsand verifies that edge datapoints contain therelationship_nameattribute.
37-56: LGTM!The test appropriately validates the empty relationships case by asserting
index_data_pointsis called with an empty list.cognee/tests/test_edge_ingestion.py (1)
55-80: LGTM!The new test block thoroughly validates the
edge_textfeature by:
- Ensuring contains edges exist for verification
- Checking edge_text field presence in edge properties
- Validating edge_text format includes expected components (relationship_name, entity_name, entity_description)
- Confirming entity names appear in the edge_text content
The test logic is sound and provides good coverage for the edge_text feature introduced in this PR.
cognee/modules/graph/utils/expand_with_nodes_and_edges.py (2)
3-3: LGTM!The Edge import is correctly added to support the new tuple-based contains structure.
250-266: Verify backward compatibility for consumers of DocumentChunk.contains.The change from appending plain
entity_nodeobjects to appending(Edge(...), entity_node)tuples is a structural breaking change. Code that iterates overdata_chunk.containsexpectingEntityobjects will need updates to handle the new tuple format.Run the following script to identify code that may be affected:
cognee/infrastructure/engine/models/Edge.py (3)
1-1: LGTM!The
field_validatorimport is correctly added to support the new edge_text validation logic.
21-23: LGTM!The docstring example clearly demonstrates the intended usage of
edge_textfor rich embedding representation in the contains relationship.
30-38: LGTM!The
edge_textfield and its validator are well-implemented:
- The validator uses
mode="before"to auto-populate edge_text from relationship_type when not explicitly provided- The fallback logic is clean and maintains backward compatibility
- This enables rich edge descriptions for embeddings while keeping the API simple
cognee/tests/test_conversation_history.py (2)
19-19: LGTM!The
get_graph_engineimport is appropriately added to support the new graph validation assertions.
23-23: LGTM!The
Counterimport is used effectively to aggregate node type counts for graph validation.cognee/context_global_variables.py (1)
36-51: Nice safety gates around access control.Defaulting to capability detection while guarding the env override keeps multi-user enforcement predictable. Looks good.
Description
Changed the key used for openai, since we changed the keys in the secrets.
Type of Change
Screenshots/Videos (if applicable)
Pre-submission Checklist
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.