fix: move datasets import in delete cli command

This commit is contained in:
Boris Arzentar 2025-10-14 15:43:29 +02:00
parent 82daeee6b9
commit 2ea24dae4d
No known key found for this signature in database
GPG key ID: D5CC274C784807B7
3 changed files with 3 additions and 5 deletions

View file

@ -5,6 +5,7 @@ from cognee.cli.reference import SupportsCliCommand
from cognee.cli import DEFAULT_DOCS_URL from cognee.cli import DEFAULT_DOCS_URL
import cognee.cli.echo as fmt import cognee.cli.echo as fmt
from cognee.cli.exceptions import CliCommandException, CliCommandInnerException from cognee.cli.exceptions import CliCommandException, CliCommandInnerException
from cognee.api.v1.datasets.datasets import datasets as cognee_datasets
from cognee.modules.data.methods import get_datasets_by_name from cognee.modules.data.methods import get_datasets_by_name
from cognee.modules.data.methods.get_deletion_counts import get_deletion_counts from cognee.modules.data.methods.get_deletion_counts import get_deletion_counts
@ -34,9 +35,6 @@ Be careful with deletion operations as they are irreversible.
def execute(self, args: argparse.Namespace) -> None: def execute(self, args: argparse.Namespace) -> None:
try: try:
# Import cognee here to avoid circular imports
from cognee.api.v1.datasets.datasets import datasets as cognee_datasets
# Validate arguments # Validate arguments
if not any( if not any(
[ [

View file

@ -286,7 +286,7 @@ class TestDeleteCommand:
assert "force" in actions assert "force" in actions
@patch("cognee.modules.data.methods.get_deletion_counts.get_user") @patch("cognee.modules.data.methods.get_deletion_counts.get_user")
@patch("cognee.api.v1.datasets.datasets.datasets.delete_dataset") @patch("cognee.cli.commands.delete_command.cognee_datasets.delete_dataset")
@patch("cognee.cli.commands.delete_command.fmt.confirm") @patch("cognee.cli.commands.delete_command.fmt.confirm")
@patch("cognee.cli.commands.delete_command.asyncio.run", side_effect=_mock_run) @patch("cognee.cli.commands.delete_command.asyncio.run", side_effect=_mock_run)
def test_execute_delete_dataset_with_confirmation( def test_execute_delete_dataset_with_confirmation(

View file

@ -381,7 +381,7 @@ class TestDeleteCommandEdgeCases:
"""Test edge cases for DeleteCommand""" """Test edge cases for DeleteCommand"""
@patch("cognee.cli.commands.delete_command.asyncio.run", side_effect=_mock_run) @patch("cognee.cli.commands.delete_command.asyncio.run", side_effect=_mock_run)
@patch("cognee.api.v1.datasets.datasets.datasets.delete_all") @patch("cognee.cli.commands.delete_command.cognee_datasets.delete_all")
@patch("cognee.cli.commands.delete_command.fmt.confirm") @patch("cognee.cli.commands.delete_command.fmt.confirm")
def test_delete_all_with_user_id(self, fmt_confirm_mock, delete_all_mock, async_run_mock): def test_delete_all_with_user_id(self, fmt_confirm_mock, delete_all_mock, async_run_mock):
"""Test delete command with both --all and --user-id""" """Test delete command with both --all and --user-id"""