fix: memgraph adapter (#899)
<!-- .github/pull_request_template.md --> ## Description <!-- Provide a clear description of the changes in this PR --> ## 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:
parent
35c554f337
commit
e0aa7c9a61
2 changed files with 34 additions and 13 deletions
26
.github/workflows/test_memgraph.yml
vendored
26
.github/workflows/test_memgraph.yml
vendored
|
|
@ -1,9 +1,9 @@
|
||||||
name: test | memgraph
|
name: test | memgraph
|
||||||
|
|
||||||
# on:
|
on:
|
||||||
# workflow_dispatch:
|
workflow_dispatch:
|
||||||
# pull_request:
|
pull_request:
|
||||||
# types: [labeled, synchronize]
|
types: [labeled, synchronize]
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
|
|
@ -17,13 +17,15 @@ jobs:
|
||||||
name: test
|
name: test
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
defaults:
|
services:
|
||||||
run:
|
memgraph:
|
||||||
shell: bash
|
image: memgraph/memgraph-mage:latest
|
||||||
|
ports:
|
||||||
|
- 7687:7687
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out
|
- name: Check out
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
|
|
@ -38,7 +40,7 @@ jobs:
|
||||||
installer-parallel: true
|
installer-parallel: true
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: poetry install -E memgraph --no-interaction
|
run: poetry install -E neo4j
|
||||||
|
|
||||||
- name: Run default Memgraph
|
- name: Run default Memgraph
|
||||||
env:
|
env:
|
||||||
|
|
@ -51,7 +53,7 @@ jobs:
|
||||||
EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }}
|
EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }}
|
||||||
EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }}
|
EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }}
|
||||||
EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }}
|
EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }}
|
||||||
GRAPH_DATABASE_URL: ${{ secrets.MEMGRAPH_API_URL }}
|
GRAPH_DATABASE_URL: "bolt://localhost:7687"
|
||||||
GRAPH_DATABASE_PASSWORD: ${{ secrets.MEMGRAPH_API_KEY }}
|
GRAPH_DATABASE_PASSWORD: "memgraph"
|
||||||
GRAPH_DATABASE_USERNAME: " "
|
GRAPH_DATABASE_USERNAME: "memgraph"
|
||||||
run: poetry run python ./cognee/tests/test_memgraph.py
|
run: poetry run python ./cognee/tests/test_memgraph.py
|
||||||
|
|
|
||||||
|
|
@ -614,7 +614,7 @@ class MemgraphAdapter(GraphDBInterface):
|
||||||
|
|
||||||
return [result["successor"] for result in results]
|
return [result["successor"] for result in results]
|
||||||
|
|
||||||
async def get_neighbours(self, node_id: str) -> List[Dict[str, Any]]:
|
async def get_neighbors(self, node_id: str) -> List[Dict[str, Any]]:
|
||||||
"""
|
"""
|
||||||
Get both predecessors and successors of a node.
|
Get both predecessors and successors of a node.
|
||||||
|
|
||||||
|
|
@ -634,6 +634,25 @@ class MemgraphAdapter(GraphDBInterface):
|
||||||
|
|
||||||
return predecessors + successors
|
return predecessors + successors
|
||||||
|
|
||||||
|
async def get_node(self, node_id: str) -> Optional[Dict[str, Any]]:
|
||||||
|
"""Get a single node by ID."""
|
||||||
|
query = """
|
||||||
|
MATCH (node {id: $node_id})
|
||||||
|
RETURN node
|
||||||
|
"""
|
||||||
|
results = await self.query(query, {"node_id": node_id})
|
||||||
|
return results[0]["node"] if results else None
|
||||||
|
|
||||||
|
async def get_nodes(self, node_ids: List[str]) -> List[Dict[str, Any]]:
|
||||||
|
"""Get multiple nodes by their IDs."""
|
||||||
|
query = """
|
||||||
|
UNWIND $node_ids AS id
|
||||||
|
MATCH (node {id: id})
|
||||||
|
RETURN node
|
||||||
|
"""
|
||||||
|
results = await self.query(query, {"node_ids": node_ids})
|
||||||
|
return [result["node"] for result in results]
|
||||||
|
|
||||||
async def get_connections(self, node_id: UUID) -> list:
|
async def get_connections(self, node_id: UUID) -> list:
|
||||||
"""
|
"""
|
||||||
Retrieve connections for a given node, including both predecessors and successors.
|
Retrieve connections for a given node, including both predecessors and successors.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue