feat: adds basic subprocess test
This commit is contained in:
parent
06a16a4aec
commit
98ad492ba7
3 changed files with 14 additions and 16 deletions
|
|
@ -8,7 +8,6 @@ from cognee.infrastructure.databases.graph.kuzu.adapter import KuzuAdapter
|
||||||
async def main():
|
async def main():
|
||||||
adapter = KuzuAdapter("test.db")
|
adapter = KuzuAdapter("test.db")
|
||||||
result = await adapter.query("MATCH (n:Node) RETURN COUNT(n)")
|
result = await adapter.query("MATCH (n:Node) RETURN COUNT(n)")
|
||||||
|
|
||||||
print(f"Reader: Found {result[0][0]} nodes")
|
print(f"Reader: Found {result[0][0]} nodes")
|
||||||
result = await adapter.query("MATCH (n:Node) RETURN COUNT(n)")
|
result = await adapter.query("MATCH (n:Node) RETURN COUNT(n)")
|
||||||
print(f"Reader: Found {result[0][0]} nodes")
|
print(f"Reader: Found {result[0][0]} nodes")
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
from uuid import uuid4
|
|
||||||
from cognee.infrastructure.databases.graph.kuzu.adapter import KuzuAdapter
|
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
from cognee.modules.chunking.models.DocumentChunk import DocumentChunk
|
|
||||||
from cognee.modules.data.processing.document_types import PdfDocument
|
from cognee.modules.data.processing.document_types import PdfDocument
|
||||||
|
from cognee.infrastructure.databases.graph.kuzu.adapter import KuzuAdapter
|
||||||
|
|
||||||
|
|
||||||
def create_node(name):
|
def create_node(name):
|
||||||
|
|
@ -12,22 +10,22 @@ def create_node(name):
|
||||||
id=uuid.uuid4(),
|
id=uuid.uuid4(),
|
||||||
name=name,
|
name=name,
|
||||||
raw_data_location=name,
|
raw_data_location=name,
|
||||||
external_metadata="",
|
external_metadata="test_external_metadata",
|
||||||
mime_type="",
|
mime_type="test_mime",
|
||||||
)
|
)
|
||||||
return document
|
return document
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
adapter = KuzuAdapter("test.db")
|
adapter = KuzuAdapter("test.db")
|
||||||
nodes = [create_node(f"Node{i}") for i in range(2)]
|
nodes = [create_node(f"Node{i}") for i in range(5)]
|
||||||
|
|
||||||
print("Writer: Starting...")
|
print("Writer: Starting...")
|
||||||
await adapter.add_nodes(nodes)
|
await adapter.add_nodes(nodes)
|
||||||
|
|
||||||
print("writer finished...")
|
print("writer finished...")
|
||||||
|
|
||||||
time.sleep(5)
|
time.sleep(10)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
@ -2,14 +2,17 @@ import os
|
||||||
import asyncio
|
import asyncio
|
||||||
import cognee
|
import cognee
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from cognee.infrastructure.databases.graph import get_graph_engine
|
from cognee.infrastructure.databases.graph import get_graph_engine
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from cognee.modules.users.methods import get_default_user
|
from cognee.modules.users.methods import get_default_user
|
||||||
from cognee.shared.logging_utils import get_logger
|
from cognee.shared.logging_utils import get_logger
|
||||||
|
from multiprocessing import Process
|
||||||
|
|
||||||
|
|
||||||
logger = get_logger()
|
logger = get_logger()
|
||||||
|
run
|
||||||
|
|
||||||
async def test_concurrent_subprocess_access():
|
async def test_concurrent_subprocess_access():
|
||||||
data_directory_path = str(
|
data_directory_path = str(
|
||||||
|
|
@ -29,15 +32,13 @@ async def test_concurrent_subprocess_access():
|
||||||
await cognee.prune.prune_data()
|
await cognee.prune.prune_data()
|
||||||
await cognee.prune.prune_system(metadata=True)
|
await cognee.prune.prune_system(metadata=True)
|
||||||
|
|
||||||
text1 = "Dave watches Dexter Resurrection"
|
writer_process = subprocess.Popen([os.sys.executable, "writer.py"])
|
||||||
text2 = "Ana likes apples"
|
|
||||||
text3 = "Bob prefers Cognee over other solutions"
|
|
||||||
|
|
||||||
await cognee.add([text1, text2, text3], dataset_name="edge_ingestion_test")
|
reader_process = subprocess.Popen([os.sys.executable, "reader.py"])
|
||||||
|
|
||||||
user = await get_default_user()
|
# Wait for both processes to complete
|
||||||
|
writer_process.wait()
|
||||||
await cognee.cognify(["edge_ingestion_test"], user=user)
|
reader_process.wait()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue