From 276eac98536a03b28d5c883c0edae0a37004ddc5 Mon Sep 17 00:00:00 2001 From: gabrielmbmb Date: Wed, 30 Aug 2023 12:56:58 +0200 Subject: [PATCH] feat: update argument from `kind` to `type_` Co-authored-by: alvarobartt --- src/argilla/tasks/datasets/list.py | 13 +++++++------ tests/unit/tasks/datasets/test_list.py | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/argilla/tasks/datasets/list.py b/src/argilla/tasks/datasets/list.py index 4418229797..27785e2538 100644 --- a/src/argilla/tasks/datasets/list.py +++ b/src/argilla/tasks/datasets/list.py @@ -18,16 +18,17 @@ import typer -class DatasetKind(str, Enum): +class DatasetType(str, Enum): feedback = "feedback" other = "other" def list_datasets( workspace: Optional[str] = typer.Option(None, help="List datasets in this workspace"), - kind: Optional[DatasetKind] = typer.Option( + type_: Optional[DatasetType] = typer.Option( None, - help="List datasets of this kind. This option can be used multiple times. By default, all datasets are listed.", + "--type", + help="The type of datasets to be listed. This option can be used multiple times. By default, all datasets are listed.", ), ) -> None: from rich.console import Console @@ -44,16 +45,16 @@ def build_tags_text(tags: Dict[str, str]) -> Markdown: return Markdown(text) table = get_argilla_themed_table(title="Datasets") - for column in ("ID", "Name", "Workspace", "Kind", "Tags", "Creation Date", "Update Date"): + for column in ("ID", "Name", "Workspace", "Type", "Tags", "Creation Date", "Update Date"): table.add_column(column, justify="center") - if kind is None or kind == DatasetKind.feedback: + if type_ is None or type_ == DatasetType.feedback: for dataset in FeedbackDataset.list(workspace): # TODO: add passing value for `Creation Date` and `Update Date` columns once `RemoteFeedbackDataset` has # these attributes table.add_row(str(dataset.id), dataset.name, dataset.workspace.name, "Feedback", None, None, None) - if kind is None or kind == DatasetKind.other: + if type_ is None or type_ == DatasetType.other: for dataset in list_datasets_api(workspace): table.add_row( dataset.id, diff --git a/tests/unit/tasks/datasets/test_list.py b/tests/unit/tasks/datasets/test_list.py index 443acc6977..4a1d24e942 100644 --- a/tests/unit/tasks/datasets/test_list.py +++ b/tests/unit/tasks/datasets/test_list.py @@ -122,25 +122,25 @@ def test_list_datasets_with_workspace(self, cli_runner: "CliRunner", cli: "Typer feedback_dataset_list_mock.assert_called_once_with("unit-test") list_datasets_mock.assert_called_once_with("unit-test") - def test_list_datasets_using_kind_feedback_filter( + def test_list_datasets_using_type_feedback_filter( self, cli_runner: "CliRunner", cli: "Typer", mocker: "MockerFixture" ) -> None: feedback_dataset_list_mock = mocker.patch("argilla.client.feedback.dataset.local.FeedbackDataset.list") list_datasets_mock = mocker.patch("argilla.client.api.list_datasets") - result = cli_runner.invoke(cli, "datasets list --kind feedback") + result = cli_runner.invoke(cli, "datasets list --type feedback") assert result.exit_code == 0 feedback_dataset_list_mock.assert_called_once_with(None) list_datasets_mock.assert_not_called() - def test_list_datasets_using_kind_other_filter( + def test_list_datasets_using_type_other_filter( self, cli_runner: "CliRunner", cli: "Typer", mocker: "MockerFixture" ) -> None: feedback_dataset_list_mock = mocker.patch("argilla.client.feedback.dataset.local.FeedbackDataset.list") list_datasets_mock = mocker.patch("argilla.client.api.list_datasets") - result = cli_runner.invoke(cli, "datasets list --kind other") + result = cli_runner.invoke(cli, "datasets list --type other") assert result.exit_code == 0 feedback_dataset_list_mock.assert_not_called()