Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: Move unique dataset id generation function to module
  • Loading branch information
dexters1 committed May 13, 2025
commit f6a689efdfa476d2f88573d789e1b49f96523f3f
11 changes: 4 additions & 7 deletions cognee-mcp/src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from contextlib import redirect_stdout
import mcp.types as types
from mcp.server import FastMCP
from cognee.api.v1.datasets.datasets import datasets as cognee_datasets
from cognee.modules.pipelines.operations.get_pipeline_status import get_pipeline_status
from cognee.modules.data.methods import get_unique_dataset_id
from cognee.modules.users.methods import get_default_user
from cognee.api.v1.cognify.code_graph_pipeline import run_code_graph_pipeline
from cognee.modules.search.types import SearchType
Expand Down Expand Up @@ -143,9 +144,7 @@ async def cognify_status():
"""Get status of cognify pipeline"""
with redirect_stdout(sys.stderr):
user = await get_default_user()
status = await cognee_datasets.get_status(
[await cognee_datasets.get_unique_dataset_id("main_dataset", user)]
)
status = await get_pipeline_status([await get_unique_dataset_id("main_dataset", user)])
return [types.TextContent(type="text", text=str(status))]


Expand All @@ -154,9 +153,7 @@ async def codify_status():
"""Get status of codify pipeline"""
with redirect_stdout(sys.stderr):
user = await get_default_user()
status = await cognee_datasets.get_status(
[await cognee_datasets.get_unique_dataset_id("codebase", user)]
)
status = await get_pipeline_status([await get_unique_dataset_id("codebase", user)])
return [types.TextContent(type="text", text=str(status))]


Expand Down
7 changes: 1 addition & 6 deletions cognee/api/v1/datasets/datasets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from uuid import UUID, uuid5, NAMESPACE_OID
from uuid import UUID
from cognee.modules.users.methods import get_default_user
from cognee.modules.ingestion import discover_directory_datasets
from cognee.modules.users.models import User
from cognee.modules.pipelines.operations.get_pipeline_status import get_pipeline_status


Expand All @@ -13,10 +12,6 @@ async def list_datasets():
user = await get_default_user()
return await get_datasets(user.id)

@staticmethod
async def get_unique_dataset_id(dataset_name: str, user: User) -> UUID:
return uuid5(NAMESPACE_OID, f"{dataset_name}{str(user.id)}")

@staticmethod
def discover_datasets(directory_path: str):
return list(discover_directory_datasets(directory_path).keys())
Expand Down
1 change: 1 addition & 0 deletions cognee/modules/data/methods/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .get_datasets_by_name import get_datasets_by_name
from .get_dataset_data import get_dataset_data
from .get_data import get_data
from .get_unique_dataset_id import get_unique_dataset_id

# Delete
from .delete_dataset import delete_dataset
Expand Down
6 changes: 6 additions & 0 deletions cognee/modules/data/methods/get_unique_dataset_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from uuid import UUID, uuid5, NAMESPACE_OID
from cognee.modules.users.models import User


async def get_unique_dataset_id(dataset_name: str, user: User) -> UUID:
return uuid5(NAMESPACE_OID, f"{dataset_name}{str(user.id)}")