Skip to content

Commit

Permalink
feat: update argument from kind to type_
Browse files Browse the repository at this point in the history
Co-authored-by: alvarobartt <[email protected]>
  • Loading branch information
gabrielmbmb and alvarobartt committed Aug 30, 2023
1 parent 63aea36 commit 276eac9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions src/argilla/tasks/datasets/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/tasks/datasets/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 276eac9

Please sign in to comment.