Skip to content

Conversation

dexters1
Copy link
Collaborator

Description

Fix issue with failing versions gh actions

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.

@dexters1 dexters1 requested a review from borisarzentar April 29, 2025 21:11
@dexters1 dexters1 self-assigned this Apr 29, 2025
Copy link

Please make sure all the checkboxes are checked:

  • I have tested these changes locally.
  • I have reviewed the code changes.
  • I have added end-to-end and unit tests (if applicable).
  • I have updated the documentation and README.md file (if necessary).
  • I have removed unnecessary code and debug statements.
  • PR title is clear and follows the convention.
  • I have tagged reviewers or team members for feedback.

Copy link
Contributor

coderabbitai bot commented Apr 29, 2025

Walkthrough

This update introduces several changes across the codebase. The MCP server implementation is refactored to use the FastMCP class with explicit async tool functions and a new startup pattern, replacing the previous generic dispatcher. Exception classes are enhanced with configurable logging behavior. Type annotations in the NetworkX graph adapter are updated to use UUID for node identifiers. Logging levels in the graph database interface are adjusted, and schema handling in the SQL adapter is simplified. The PGVector adapter and its exception handling are refined. A test is modified to skip a frequently failing case, and the Dockerfile is updated to install all dependencies, including development ones.

Changes

File(s) Change Summary
Dockerfile Installs build-essential; Poetry installs all dependencies including dev.
cognee-mcp/src/server.py Refactored to use FastMCP with explicit async tool registration, new startup logic, and removed generic tool dispatcher.
cognee/exceptions/exceptions.py
cognee/infrastructure/databases/vector/exceptions/exceptions.py
Exception constructors now support configurable logging (log, log_level); fixed default name in CollectionNotFoundError.
cognee/infrastructure/databases/graph/graph_db_interface.py Logging for certain errors changed from error to debug in the graph changes recorder.
cognee/infrastructure/databases/graph/networkx/adapter.py Type annotations for node IDs changed from str to UUID in multiple async methods.
cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py Schema list in delete_database is now hardcoded to ["public", "public_staging"]; minor comment fix.
cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py CollectionNotFoundError raised with log_level="DEBUG"; closest_items explicitly initialized.
cognee/tests/test_neo4j.py Natural language search test commented out due to instability; assertion count adjusted.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FastMCP
    participant ToolFunction
    User->>FastMCP: Calls tool (e.g., cognify, codify, search, prune)
    FastMCP->>ToolFunction: Invokes async tool function
    ToolFunction-->>FastMCP: Launches background task or returns result
    FastMCP-->>User: Returns immediate response or result
Loading

Possibly related PRs

  • Add mcp to cognee #370: Adds the initial MCP server implementation with a different structure and tool handling; both PRs modify MCP server code but with distinct approaches.
  • feat: Add data visualization for Anthropic #432: Adds a new "visualize" tool and image functions to the MCP server file; both PRs touch the same file but focus on different tool registration aspects.
  • Feat/cognee mcp #400: Refactors MCP server code and tool registration; both PRs involve changes to the MCP server and tool handling patterns.

Suggested labels

run-checks

Poem

In the warren where the servers hop,
FastMCP now leads the crop.
Async tools in tidy rows,
With logging set the way it goes.
UUIDs bound in graphy thread,
And Docker builds with all dependencies fed.
🐇 Cheers to code that leaps ahead!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d7df18 and f1dbd69.

⛔ Files ignored due to path filters (7)
  • .github/actions/cognee_setup/action.yml is excluded by !**/*.yml
  • .github/workflows/python_version_tests.yml is excluded by !**/*.yml
  • cognee-mcp/pyproject.toml is excluded by !**/*.toml
  • cognee-mcp/uv.lock is excluded by !**/*.lock, !**/*.lock
  • poetry.lock is excluded by !**/*.lock, !**/*.lock
  • pyproject.toml is excluded by !**/*.toml
  • uv.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (9)
  • Dockerfile (2 hunks)
  • cognee-mcp/src/server.py (3 hunks)
  • cognee/exceptions/exceptions.py (1 hunks)
  • cognee/infrastructure/databases/graph/graph_db_interface.py (2 hunks)
  • cognee/infrastructure/databases/graph/networkx/adapter.py (7 hunks)
  • cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py (2 hunks)
  • cognee/infrastructure/databases/vector/exceptions/exceptions.py (1 hunks)
  • cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py (2 hunks)
  • cognee/tests/test_neo4j.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py (1)
cognee/infrastructure/databases/vector/exceptions/exceptions.py (1)
  • CollectionNotFoundError (5-14)
cognee-mcp/src/server.py (8)
cognee/shared/logging_utils.py (3)
  • get_logger (137-158)
  • get_log_file_location (333-340)
  • error (127-128)
cognee/api/v1/cognify/code_graph_pipeline.py (2)
  • run_code_graph_pipeline (35-82)
  • main (87-102)
cognee/modules/search/methods/search.py (1)
  • search (25-51)
cognee/api/v1/search/routers/get_search_router.py (1)
  • search (36-47)
cognee/modules/search/types/SearchType.py (1)
  • SearchType (4-13)
cognee/modules/storage/utils/__init__.py (1)
  • JSONEncoder (11-20)
cognee/shared/data_models.py (1)
  • TextContent (211-213)
cognee-mcp/src/client.py (1)
  • run (31-48)
cognee/exceptions/exceptions.py (1)
cognee/shared/logging_utils.py (4)
  • error (127-128)
  • warning (124-125)
  • info (121-122)
  • debug (133-134)
🪛 Ruff (0.8.2)
cognee-mcp/src/server.py

46-46: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: End-to-End Tests / Run Telemetry Test
  • GitHub Check: End-to-End Tests / Run Telemetry Pipeline Test
  • GitHub Check: End-to-End Tests / Server Start Test
  • GitHub Check: End-to-End Tests / S3 Bucket Test
  • GitHub Check: End-to-End Tests / Deletion Test
  • GitHub Check: Basic Tests / Run Unit Tests
  • GitHub Check: End-to-End Tests / Deduplication Test
  • GitHub Check: Basic Tests / Run Simple Examples
  • GitHub Check: Basic Tests / Run Basic Graph Tests
  • GitHub Check: Basic Tests / Run Integration Tests
🔇 Additional comments (8)
Dockerfile (2)

32-32: Added essential build tools to support compilation.

The addition of build-essential is beneficial as it provides necessary compilation tools that might be required by certain Python packages with C extensions. This ensures that any dependencies requiring compilation can be properly installed.


44-44:

❌ Incorrect review comment

Development dependencies are now installed in the Docker image.

Removing the --without dev flag means all dependencies, including development ones, are now installed. This may increase the Docker image size but ensures that all tools required for GitHub Actions will be available.

Consider if development dependencies are actually needed in your production Docker image:


🏁 Script executed:

#!/bin/bash
# Check what development dependencies are being added
cat pyproject.toml | grep -A 100 "\[tool.poetry.group.dev.dependencies\]" | grep "^[a-zA-Z]"

Length of output: 141


🏁 Script executed:

#!/bin/bash
# Locate pyproject.toml in the repo
echo "Searching for pyproject.toml..."
project_file=$(fd pyproject.toml | head -n1)

if [ -z "$project_file" ]; then
  echo "pyproject.toml not found in the repository."
  exit 0
fi

echo "Found pyproject.toml at: $project_file"
echo "Inspecting dev dependencies group..."
grep -n '\[tool.poetry.group.dev.dependencies\]' -A50 "$project_file" || echo "No dev dependencies group found."

Length of output: 243


🏁 Script executed:

#!/bin/bash
# List all TOML files in the repo
echo "=== TOML files in repository ==="
find . -type f -iname '*.toml' || echo "(none)"

# Search for Poetry configuration in TOML files
echo; echo "=== [tool.poetry] sections ==="
grep -R -n "\[tool.poetry" -- '*.toml' || echo "(none found)"

echo; echo "=== Dev-dependencies groups ==="
grep -R -n "\[tool.poetry.*dev" -- '*.toml' || echo "(none found)"

# Locate and inspect Dockerfile around Poetry install
echo; echo "=== Dockerfile snippet ==="
docker_file=$(fd Dockerfile | head -n1)
if [ -n "$docker_file" ]; then
  echo "Found Dockerfile at: $docker_file"
  sed -n '1,100p' "$docker_file"
else
  echo "Dockerfile not found"
fi

Length of output: 2136


No Poetry dev-dependencies group found – dev dependencies won’t be installed

I searched the repo for any pyproject.toml or [tool.poetry]/[tool.poetry.group.dev.dependencies] sections and found none (only ruff.toml exists). Therefore, removing --without dev has no impact—there are no dev-dependency groups to install. The original note about development dependencies increasing image size isn’t applicable here.

Likely an incorrect or invalid review comment.

cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py (1)

332-334:

✅ Verification successful

Simplified schema handling in database deletion.

Replaced dynamic schema retrieval with a hardcoded list of schemas (["public", "public_staging"]) to be more explicit about which schemas are affected when deleting the database.

Let's verify there are no other schemas in use that would need to be included:


🏁 Script executed:

#!/bin/bash
# Search for any other schema references in the codebase
rg "schema.*=(?!.*('public'|\"public\"|'public_staging'|\"public_staging\"))" --pcre2

Length of output: 6165


The dynamic‐vs‐static split looks correct, but let’s pull in the surrounding implementations to be sure we’re not missing other schema names:


🏁 Script executed:

#!/bin/bash
set -eux
# Show the get_schema_list implementation
rg -n -B2 -A20 "async def get_schema_list" cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py

# Show the “Drop all tables” section where the hardcoded list lives
rg -n -B3 -A10 "# Drop all tables" cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py

Length of output: 2133


No missing schemas detected – deletion targets are correct

I searched the entire codebase for other schema names and only “public” and “public_staging” are ever used when reflecting or dropping tables. The hard-coded list in SqlAlchemyAdapter.py (lines 332–334) therefore covers all schemas in use for deletion.

cognee/exceptions/exceptions.py (2)

15-16: Enhanced exception logging configurability.

Added parameters to control exception logging behavior:

  • log: Controls whether the exception should be logged (defaults to True)
  • log_level: Controls the severity level for logging (defaults to "ERROR")

This allows for more fine-grained control over exception logging throughout the application.


23-30:

❓ Verification inconclusive

Implemented configurable log levels for exceptions.

The implementation correctly handles the various log levels (ERROR, WARNING, INFO, DEBUG) based on the provided parameters. This enhances the flexibility of the error handling system.

Let's check where these new parameters are being used in the codebase:


🏁 Script executed:

#!/bin/bash
# Find instances where log or log_level parameters are specified in exception raising
rg "raise \w+Error\(.*log(_level)?=" --include="*.py"

Length of output: 497


🏁 Script executed:

#!/bin/bash
# Find all exception raises specifying log or log_level in Python files
rg -g '*.py' "raise .*Error\(.*log(_level)?=" -n

Length of output: 50


Verify usage of the new log/log_level parameters
It appears there are no calls in the codebase that pass the newly added log or log_level arguments when raising exceptions. Please confirm that:

  • Exceptions are meant to be raised with these logging flags (or update documentation/tests accordingly)
  • Any existing exception‐raising sites are updated to leverage the configurable log levels
cognee/tests/test_neo4j.py (1)

90-90: Hard-coded history length may break easily

assert len(history) == 6 assumes an implicit contract between earlier API calls and history-logging internals.
If another search variant is added/removed the test will fail for the wrong reason.
Consider asserting minimum length or enumerating expected event types instead.

cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py (1)

271-273: Redundant pre-initialisation of closest_items

closest_items is immediately reassigned by session.execute().
The guard only helps if an exception occurs before assignment, in which case you return anyway.
Can be removed to keep the code clean.

cognee/infrastructure/databases/vector/exceptions/exceptions.py (1)

9-15: Constructor signature looks good

Changing the default name and adding log/log_level makes the class consistent with other errors.
No issues spotted.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dexters1 dexters1 changed the base branch from main to dev April 29, 2025 21:11
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 5

🧹 Nitpick comments (4)
cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py (1)

187-189: Exception chaining missing (raise … from e)

You wrapped the internal failure in CollectionNotFoundError but the original stack-trace is lost.
Either re-raise the caught exception (raise) or chain it:

-                raise CollectionNotFoundError(
-                    f"Collection '{collection_name}' not found!", log_level="DEBUG"
-                )
+                raise CollectionNotFoundError(
+                    f"Collection '{collection_name}' not found!", log_level="DEBUG"
+                ) from None

This satisfies Ruff B904 and keeps signal/noise balanced.

cognee-mcp/src/server.py (3)

42-46: Preserve root cause when re-raising

cognify_task swallows the original exception context, hindering debugging.

-            except Exception as e:
-                logger.error("Cognify process failed.")
-                raise ValueError(f"Failed to cognify: {str(e)}")
+            except Exception as e:
+                logger.error("Cognify process failed.")
+                raise ValueError(f"Failed to cognify: {e}") from e

Same pattern applies to other tasks that may raise.

🧰 Tools
🪛 Ruff (0.8.2)

46-46: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


56-60: log_file may be None

get_log_file_location() returns None if no FileHandler is configured, so the user sees an
unhelpful message (…file at: None).
Fallback to a default string or guard against None.


171-191: Graceful shutdown and signal handling

asyncio.run() inside a try/except logs startup errors but does not handle
KeyboardInterrupt or SIGTERM, which matter for containerised deployments.
Consider using asyncio.run(main(), debug=False) inside a proper signal handler
or rely on FastMCP’s own graceful shutdown utilities.

🛑 Comments failed to post (5)
cognee/infrastructure/databases/graph/graph_db_interface.py (1)

61-61: 🛠️ Refactor suggestion

Reduced log noise by changing error messages to debug level.

Changed the logging level from ERROR to DEBUG for relationship errors and session commit errors in the record_graph_changes decorator. This reduces log noise since these errors might be expected in certain scenarios and don't necessarily indicate critical problems.

Consider making this configurable like the recent changes to the exception classes. This would provide consistent error handling across the codebase:

-logger.debug(f"Error adding relationship: {e}")
+logger.log(log_level, f"Error adding relationship: {e}")

Where log_level could be a parameter of the decorator or determined contextually.

Also applies to: 81-81, 88-88

🤖 Prompt for AI Agents (early access)
In cognee/infrastructure/databases/graph/graph_db_interface.py at lines 61, 81, and 88, the logging level for errors in the record_graph_changes decorator was changed from ERROR to DEBUG to reduce log noise. To improve consistency and flexibility, refactor the decorator to accept a configurable log_level parameter that defaults to DEBUG but can be set to other levels as needed. Update the logging calls to use this parameter instead of a hardcoded level.
cognee/tests/test_neo4j.py (1)

77-86: 🛠️ Refactor suggestion

Use unittest.skip instead of commenting-out flaky test

Commenting code hides drift and makes future maintenance harder.
Mark the flaky case as skipped so it still shows up in test reports and can be re-enabled later.

-    # NOTE: Due to the test failing often on weak LLM models we've removed this test for now
-    # search_results = await cognee.search(
-    #     query_type=SearchType.NATURAL_LANGUAGE,
-    #     query_text=f"Find nodes connected to node with name {random_node_name}",
-    # )
-    # assert len(search_results) != 0, "Query related natural language don't exist."
-    # print("\nExtracted results are:\n")
-    # for result in search_results:
-    #     print(f"{result}\n")
+    @unittest.skip("Temporarily disabled – flaky on weaker LLM models")
+    async def _natural_language_search():
+        search_results = await cognee.search(
+            query_type=SearchType.NATURAL_LANGUAGE,
+            query_text=f"Find nodes connected to node with name {random_node_name}",
+        )
+        self.assertTrue(search_results, "Natural-language search returned no results.")

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents (early access)
In cognee/tests/test_neo4j.py around lines 77 to 86, the flaky test is currently commented out, which hides it from test reports and complicates maintenance. Replace the commented-out test code with a proper test function decorated with unittest.skip, providing a reason for skipping. This way, the test remains visible in reports and can be easily re-enabled later.
cognee-mcp/src/server.py (2)

78-86: 🛠️ Refactor suggestion

Background task errors are lost

asyncio.create_task() is fire-and-forget; unhandled exceptions in codify_task
are only logged via the default loop exception handler.
Capture the task and add task.add_done_callback to log/propagate failures:

-    asyncio.create_task(codify_task(repo_path))
+    task = asyncio.create_task(codify_task(repo_path))
+    task.add_done_callback(
+        lambda t: logger.error(f"Codify task failed: {t.exception()}") if t.exception() else None
+    )

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents (early access)
In cognee-mcp/src/server.py around lines 78 to 86, the current use of asyncio.create_task() for the codify_task is fire-and-forget, causing any exceptions in the background task to be lost and only logged by the default loop handler. To fix this, capture the created task in a variable and add a done callback function that checks for exceptions and logs or propagates them appropriately, ensuring background task errors are not silently ignored.

111-120: ⚠️ Potential issue

Potential IndexError for empty result set

search_results[0] assumes at least one item. If the query misses you’ll raise
IndexError, which is mapped to an unhelpful MCP error.

-            elif (
-                search_type.upper() == "GRAPH_COMPLETION" or search_type.upper() == "RAG_COMPLETION"
-            ):
-                return search_results[0]
+            elif search_type.upper() in {"GRAPH_COMPLETION", "RAG_COMPLETION"}:
+                return search_results[0] if search_results else "No results found."
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

                query_type=SearchType[search_type.upper()], query_text=search_query
            )

            if search_type.upper() == "CODE":
                return json.dumps(search_results, cls=JSONEncoder)
            elif search_type.upper() in {"GRAPH_COMPLETION", "RAG_COMPLETION"}:
                return search_results[0] if search_results else "No results found."
            elif search_type.upper() == "CHUNKS":
                # ...
🤖 Prompt for AI Agents (early access)
In cognee-mcp/src/server.py around lines 111 to 120, the code accesses search_results[0] without checking if search_results is empty, risking an IndexError. To fix this, add a condition to verify that search_results contains at least one item before accessing the first element. If it is empty, handle the case gracefully by returning an appropriate response or error message instead of directly accessing search_results[0].
cognee/infrastructure/databases/graph/networkx/adapter.py (1)

45-45: 💡 Verification agent

🧩 Analysis chain

Consistent type updates for node identifiers

The type annotations have been updated from str to UUID for node identifiers across multiple methods in the NetworkXAdapter class. This change improves type safety and enforces consistent use of UUID objects throughout the graph operations.

However, I noticed some inconsistency in the codebase - some methods still use str type annotations for node identifiers, such as:

  • add_edge (lines 75-81)
  • add_edges (line 93)
  • has_edge (line 62)

Consider updating the type annotations in these methods as well to maintain consistency across the entire adapter class:

-    async def has_edge(self, from_node: str, to_node: str, edge_label: str) -> bool:
+    async def has_edge(self, from_node: UUID, to_node: UUID, edge_label: str) -> bool:

-    async def add_edge(
-        self,
-        from_node: str,
-        to_node: str,
-        relationship_name: str,
-        edge_properties: Dict[str, Any] = {},
-    ) -> None:
+    async def add_edge(
+        self,
+        from_node: UUID,
+        to_node: UUID,
+        relationship_name: str,
+        edge_properties: Dict[str, Any] = {},
+    ) -> None:

-    async def add_edges(self, edges: list[tuple[str, str, str, dict]]) -> None:
+    async def add_edges(self, edges: list[tuple[UUID, UUID, str, dict]]) -> None:

Also applies to: 139-139, 177-177, 183-183, 218-218, 267-267, 278-278, 624-624, 629-629


🏁 Script executed:

#!/bin/bash
# Check for mixed usage of string and UUID node identifiers in the codebase

echo "Checking for NetworkXAdapter method calls with mixed node ID types..."

# Find places where the adapter methods are called
rg -A 1 "networkx_adapter\.(has_node|get_edges|extract_node|extract_nodes|get_neighbors|get_node|get_nodes)" --type py

echo -e "\nChecking for UUID imports and conversions..."
rg -A 3 "from uuid import UUID" --type py | head -20

echo -e "\nChecking for ID parsing or conversion..."
rg -A 1 "parse_id|UUID\(" --type py | head -20

Length of output: 4059


🏁 Script executed:

#!/bin/bash
# Inspect NetworkXAdapter method signatures for edge-related methods
echo "has_edge signature:"
rg -n -A0 "async def has_edge" cognee/infrastructure/databases/graph/networkx/adapter.py || echo "has_edge not found"

echo -e "\nadd_edge signature:"
rg -n -A3 "async def add_edge" cognee/infrastructure/databases/graph/networkx/adapter.py || echo "add_edge not found"

echo -e "\nadd_edges signature:"
rg -n -A0 "async def add_edges" cognee/infrastructure/databases/graph/networkx/adapter.py || echo "add_edges not found"

Length of output: 922


Ensure UUID Consistency for Edge-Related Methods

The has_node method now correctly uses UUID for identifiers, but the following methods in cognee/infrastructure/databases/graph/networkx/adapter.py still accept str:

• Line 62 – has_edge(self, from_node: str, to_node: str, edge_label: str) -> bool
• Lines 75–81 – add_edge(self, from_node: str, to_node: str, relationship_name: str, edge_properties: Dict[str, Any] = {}) -> None
• Line 93 – add_edges(self, edges: list[tuple[str, str, str, dict]]) -> None

Please update their signatures to use UUID for node identifiers:

-    async def has_edge(self, from_node: str, to_node: str, edge_label: str) -> bool:
+    async def has_edge(self, from_node: UUID, to_node: UUID, edge_label: str) -> bool:

-    async def add_edge(
-        self,
-        from_node: str,
-        to_node: str,
-        relationship_name: str,
-        edge_properties: Dict[str, Any] = {},
-    ) -> None:
+    async def add_edge(
+        self,
+        from_node: UUID,
+        to_node: UUID,
+        relationship_name: str,
+        edge_properties: Dict[str, Any] = {},
+    ) -> None:

-    async def add_edges(self, edges: list[tuple[str, str, str, dict]]) -> None:
+    async def add_edges(self, edges: list[tuple[UUID, UUID, str, dict]]) -> None:

This will enforce consistent use of UUID across all graph operations.

🤖 Prompt for AI Agents (early access)
In cognee/infrastructure/databases/graph/networkx/adapter.py around lines 62, 75-81, and 93, the methods has_edge, add_edge, and add_edges currently use str type annotations for node identifiers. Update these method signatures to use UUID instead of str for all node identifier parameters to maintain consistent type usage across the class. This involves changing from_node and to_node parameters in has_edge and add_edge, and the corresponding tuple elements in add_edges, to UUID type annotations.

@dexters1 dexters1 requested a review from Vasilije1990 April 29, 2025 23:50
@dexters1 dexters1 changed the title Fix versions gh actions Fix versions gh actions [COG-2025] Apr 29, 2025
@borisarzentar borisarzentar merged commit 66ecd35 into dev Apr 30, 2025
50 of 51 checks passed
@borisarzentar borisarzentar deleted the fix-versions-tests branch April 30, 2025 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants