-
Notifications
You must be signed in to change notification settings - Fork 586
feat: Add Memgraph integration #751
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
feat: Add Memgraph integration #751
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 WalkthroughThis change introduces support for the Memgraph graph database within the Cognee infrastructure. It adds a new Changes
Sequence Diagram(s)sequenceDiagram
participant TestScript
participant Cognee
participant MemgraphAdapter
participant MemgraphDB
TestScript->>Cognee: Configure with Memgraph provider
TestScript->>Cognee: Add dataset (file, string)
TestScript->>Cognee: Run cognify on dataset
Cognee->>MemgraphAdapter: Add nodes/edges
MemgraphAdapter->>MemgraphDB: Execute Cypher queries
TestScript->>Cognee: Get vector engine and search
Cognee->>MemgraphAdapter: Query nodes/edges
MemgraphAdapter->>MemgraphDB: Execute search queries
TestScript->>Cognee: Get user and search history
Cognee->>MemgraphAdapter: Query search history
TestScript->>Cognee: Prune data and system metadata
Cognee->>MemgraphAdapter: Delete nodes/edges
MemgraphAdapter->>MemgraphDB: Execute deletion queries
TestScript->>MemgraphAdapter: Validate graph is empty
MemgraphAdapter->>MemgraphDB: Check node/edge count
Possibly related PRs
Suggested reviewers
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 6
🧹 Nitpick comments (3)
cognee/infrastructure/databases/graph/memgraph/adapter.py (1)
539-544
: Drop redundantf
‑prefix to silence Ruff F541There are no placeholders in the string.
-node_labels_query = f""" +node_labels_query = """🧰 Tools
🪛 Ruff (0.8.2)
539-544: f-string without any placeholders
Remove extraneous
f
prefix(F541)
cognee/infrastructure/databases/graph/get_graph_engine.py (1)
70-80
: Normalise provider name to lowercase for consistencyOther branches compare the lower‑cased value (
"neo4j"
,"falkordb"
,
etc.). Using the raw string for Memgraph causes a mismatch when the config
holds"Memgraph"
or"MEMGRAPH"
.- elif graph_database_provider == "memgraph": + elif graph_database_provider.lower() == "memgraph":cognee/tests/test_memgraph.py (1)
1-107
: Consider converting the script into a proper test caseThe file contains a standalone
async main()
and uses bareassert
statements. Adapting it topytest
orunittest.IsolatedAsyncioTestCase
would:
- integrate with existing CI tooling,
- provide nicer reporting (
assert
rewrites, xfail/skip markers),- allow easy parametrisation for different graph back‑ends.
This is optional but will improve maintainability and observability of
future regressions.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
.github/workflows/test_memgraph.yml
is excluded by!**/*.yml
📒 Files selected for processing (3)
cognee/infrastructure/databases/graph/get_graph_engine.py
(1 hunks)cognee/infrastructure/databases/graph/memgraph/adapter.py
(1 hunks)cognee/tests/test_memgraph.py
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
cognee/infrastructure/databases/graph/get_graph_engine.py (1)
cognee/infrastructure/databases/graph/memgraph/adapter.py (1)
MemgraphAdapter
(19-687)
🪛 Ruff (0.8.2)
cognee/infrastructure/databases/graph/memgraph/adapter.py
184-184: Do not use mutable data structures for argument defaults
Replace with None
; initialize within function
(B006)
429-429: Do not use mutable data structures for argument defaults
Replace with None
; initialize within function
(B006)
539-544: f-string without any placeholders
Remove extraneous f
prefix
(F541)
The merge-base changed after approval.
|
GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
---|---|---|---|---|---|
9573981 | Triggered | Generic Password | 84479ba | .github/workflows/relational_db_migration_tests.yml | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 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.
@matea16 Thanks for the contribution! I left couple of comments and please look at coderabbit suggestions.
Description
This PR adds support for the Memgraph graph database following the graph database integration guide:
MemgraphAdapter
for interfacing with Memgraph.get_graph_engine.py
to return MemgraphAdapter when appropriate.test_memgraph.py.
.github/workflows/test_memgraph.yml.
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.