From e4a218882044baa282b5ad55079e6bd1aff0c4f4 Mon Sep 17 00:00:00 2001 From: rajeevrajeshuni Date: Sun, 30 Nov 2025 14:08:30 +0530 Subject: [PATCH] revert changes for delete_command --- cognee/cli/commands/delete_command.py | 33 +++++++++------------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/cognee/cli/commands/delete_command.py b/cognee/cli/commands/delete_command.py index df0a1cbe3..1a52d5e1b 100644 --- a/cognee/cli/commands/delete_command.py +++ b/cognee/cli/commands/delete_command.py @@ -1,14 +1,12 @@ import argparse import asyncio -from uuid import UUID +from typing import Optional + from cognee.cli.reference import SupportsCliCommand from cognee.cli import DEFAULT_DOCS_URL import cognee.cli.echo as fmt from cognee.cli.exceptions import CliCommandException, CliCommandInnerException from cognee.modules.data.methods.get_deletion_counts import get_deletion_counts -from cognee.modules.data.methods.delete_dataset_by_name import delete_dataset_by_name -from cognee.modules.data.methods.delete_data_by_user import delete_data_by_user -from cognee.modules.users.methods import get_default_user class DeleteCommand(SupportsCliCommand): @@ -95,29 +93,20 @@ Be careful with deletion operations as they are irreversible. # Run the async delete function async def run_delete(): try: - if args.dataset_name: - # Use delete_datasets_by_name for dataset deletion - user = await get_default_user() - result = await delete_dataset_by_name(args.dataset_name, user.id) - - if result["not_found"]: - fmt.warning(f"Dataset '{args.dataset_name}' not found") - return False - - fmt.success(f"Successfully deleted {result['deleted_count']} dataset(s)") - return True + # NOTE: The underlying cognee.delete() function is currently not working as expected. + # This is a separate bug that this preview feature helps to expose. + if args.all: + await cognee.delete(dataset_name=None, user_id=args.user_id) else: - # For user_id deletion, use the original cognee.delete - result = await delete_data_by_user(UUID(args.user_id)) + await cognee.delete(dataset_name=args.dataset_name, user_id=args.user_id) except Exception as e: raise CliCommandInnerException(f"Failed to delete: {str(e)}") from e - return True - success = asyncio.run(run_delete()) - if success and not args.dataset_name: - fmt.success(f"Successfully deleted {operation}") + asyncio.run(run_delete()) + # This success message may be inaccurate due to the underlying bug, but we leave it for now. + fmt.success(f"Successfully deleted {operation}") except Exception as e: if isinstance(e, CliCommandInnerException): raise CliCommandException(str(e), error_code=1) from e - raise CliCommandException(f"Error deleting data: {str(e)}", error_code=1) from e + raise CliCommandException(f"Error deleting data: {str(e)}", error_code=1) from e \ No newline at end of file