Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move project free commands to outside again #952

Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 21 additions & 1 deletion datumaro/cli/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@

# pylint: disable=redefined-builtin

from . import convert, detect_format, download, explain, filter, generate, merge, patch, search
from . import (
convert,
detect_format,
diff,
download,
explain,
filter,
generate,
info,
merge,
patch,
search,
stats,
transform,
validate,
)
from .require_project import get_project_commands

__all__ = [
Expand All @@ -17,11 +32,16 @@ def get_non_project_commands():
return [
("convert", convert, "Convert dataset between formats"),
("detect", detect_format, "Detect the format of a dataset"),
("diff", diff, "Compare datasets"),
("dinfo", info, "Print dataset info"),
("download", download, "Download a publicly available dataset"),
("explain", explain, "Run Explainable AI algorithm for model"),
("filter", filter, "Filter dataset items"),
("generate", generate, "Generate synthetic dataset"),
("merge", merge, "Merge datasets"),
("patch", patch, "Update dataset from another one"),
("search", search, "Search similar datasetitems of query"),
("stats", stats, "Compute dataset statistics"),
("transform", transform, "Modify dataset items"),
("validate", validate, "Validate dataset"),
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from datumaro.util.os_util import rmtree
from datumaro.util.scope import on_error_do, scope_add, scoped

from ....util import MultilineFormatter
from ....util.diff import DiffVisualizer
from ....util.errors import CliException
from ....util.project import generate_next_file_name, load_project, parse_full_revpath
from ..util import MultilineFormatter
from ..util.diff import DiffVisualizer
from ..util.errors import CliException
from ..util.project import generate_next_file_name, load_project, parse_full_revpath


class ComparisonMethod(Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from datumaro.components.errors import DatasetMergeError, MissingObjectError, ProjectNotFoundError
from datumaro.util.scope import scope_add, scoped

from ....util import MultilineFormatter
from ....util.project import load_project, parse_full_revpath
from ..util import MultilineFormatter
from ..util.project import load_project, parse_full_revpath


def build_parser(parser_ctor=argparse.ArgumentParser):
Expand Down
17 changes: 5 additions & 12 deletions datumaro/cli/commands/require_project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,22 @@
#
# SPDX-License-Identifier: MIT

from . import dataset_operations, modification, versioning
from . import modification, versioning


def get_project_commands():
return [
("Project modification:", None, ""),
("add", modification.add, "Add dataset"),
("add", modification.add, "Add dataset"), # TODO: We will deprecated it with import soon.
("create", modification.create, "Create empty project"),
("export", modification.export, "Export dataset in some format"),
("import", modification.import_, "Import dataset"),
("remove", modification.remove, "Remove dataset"),
("", None, ""),
("Project versioning:", None, ""),
("checkout", versioning.checkout, "Switch to another branch or revision"),
("commit", versioning.commit, "Commit changes in tracked files"),
("log", versioning.log, "List history"),
("status", versioning.status, "Display current status"),
("pinfo", versioning.info, "Print project info"),
("", None, ""),
("Dataset operations:", None, ""),
("diff", dataset_operations.diff, "Compare datasets"),
("export", dataset_operations.export, "Export dataset in some format"),
("stats", dataset_operations.stats, "Compute dataset statistics"),
("transform", dataset_operations.transform, "Modify dataset items"),
("validate", dataset_operations.validate, "Validate dataset"),
("dinfo", dataset_operations.info, "Print dataset info"),
("info", versioning.info, "Print project information"),
("status", versioning.status, "Display current branch and revision status"),
]

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#
# SPDX-License-Identifier: MIT

from . import add, create, import_, remove
from . import add, create, export, import_, remove
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from datumaro.util import dump_json_file, str_to_bool
from datumaro.util.scope import scope_add, scoped

from ....util import MultilineFormatter
from ....util.project import generate_next_file_name, load_project, parse_full_revpath
from ..util import MultilineFormatter
from ..util.project import generate_next_file_name, load_project, parse_full_revpath

__all__ = [
"build_parser",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from datumaro.util import str_to_bool
from datumaro.util.scope import scope_add, scoped

from ....util import MultilineFormatter
from ....util.errors import CliException
from ....util.project import load_project, parse_full_revpath
from ..util import MultilineFormatter
from ..util.errors import CliException
from ..util.project import load_project, parse_full_revpath


def build_parser(parser_ctor=argparse.ArgumentParser):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from datumaro.util import dump_json_file
from datumaro.util.scope import scope_add, scoped

from ....util import MultilineFormatter
from ....util.errors import CliException
from ....util.project import generate_next_file_name, load_project, parse_full_revpath
from ..util import MultilineFormatter
from ..util.errors import CliException
from ..util.project import generate_next_file_name, load_project, parse_full_revpath


def build_parser(parser_ctor=argparse.ArgumentParser):
Expand Down
12 changes: 6 additions & 6 deletions datumaro/util/telemetry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ def _get_action_name(command):
# TODO: We should clean these nonsense if-else branches.
if command is commands.require_project.versioning.info.info_command:
return "project_info_result"
elif command is commands.require_project.dataset_operations.stats.stats_command:
elif command is commands.stats.stats_command:
return "project_stats_result"
elif command is contexts.project.migrate_command:
return "project_migrate_result"
elif command is commands.require_project.dataset_operations.export.export_command:
elif command is commands.require_project.modification.export.export_command:
return "project_export_result"
elif command is commands.require_project.dataset_operations.validate.validate_command:
elif command is commands.validate.validate_command:
return "project_validate_result"
elif command is commands.filter.filter_command:
return "project_filter_result"
elif command is commands.require_project.dataset_operations.transform.transform_command:
elif command is commands.transform.transform_command:
return "project_transform_result"
elif command is commands.require_project.modification.import_.import_command:
return "source_add_result"
Expand All @@ -59,13 +59,13 @@ def _get_action_name(command):
return "convert_result"
elif command is commands.require_project.modification.create.create_command:
return "create_result"
elif command is commands.require_project.dataset_operations.diff.diff_command:
elif command is commands.diff.diff_command:
return "diff_result"
elif command is commands.explain.explain_command:
return "explain_result"
elif command is commands.generate.generate_command:
return "generate_result"
elif command is commands.require_project.dataset_operations.info.info_command:
elif command is commands.info.info_command:
return "info_result"
elif command is commands.require_project.versioning.log.log_command:
return "log_result"
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/cli/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def test_can_run_distance_diff(self):
result_dir = osp.join(test_dir, "cmp_result")
run(
self,
"project",
"diff",
dataset1_url + ":coco",
dataset2_url + ":voc",
Expand Down Expand Up @@ -273,7 +272,6 @@ def test_can_run_equality_diff(self):
result_dir = osp.join(test_dir, "cmp_result")
run(
self,
"project",
"diff",
dataset1_url + ":coco",
dataset2_url + ":voc",
Expand Down
18 changes: 8 additions & 10 deletions tests/integration/cli/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ def test_can_list_project_info(self):
run(self, "project", "import", "-f", "coco", "-p", test_dir, coco_dir)

with self.subTest("on project"):
run(self, "project", "pinfo", "-p", test_dir)
run(self, "project", "info", "-p", test_dir)

with self.subTest("on project revision"):
run(self, "project", "pinfo", "-p", test_dir, "HEAD")
run(self, "project", "info", "-p", test_dir, "HEAD")

@mark_requirement(Requirements.DATUM_GENERAL_REQ)
def test_can_list_dataset_info(self):
Expand All @@ -107,19 +107,19 @@ def test_can_list_dataset_info(self):
run(self, "project", "commit", "-m", "first", "-p", test_dir)

with self.subTest("on current project"):
run(self, "project", "dinfo", "-p", test_dir)
run(self, "dinfo", "-p", test_dir)

with self.subTest("on current project revision"):
run(self, "project", "dinfo", "-p", test_dir, "HEAD")
run(self, "dinfo", "-p", test_dir, "HEAD")

with self.subTest("on other project"):
run(self, "project", "dinfo", test_dir)
run(self, "dinfo", test_dir)

with self.subTest("on other project revision"):
run(self, "project", "dinfo", test_dir + "@HEAD")
run(self, "dinfo", test_dir + "@HEAD")

with self.subTest("on dataset"):
run(self, "project", "dinfo", coco_dir + ":coco")
run(self, "dinfo", coco_dir + ":coco")

def test_can_use_vcs(self):
with TestDir() as test_dir:
Expand Down Expand Up @@ -147,7 +147,6 @@ def test_can_use_vcs(self):

run(
self,
"project",
"transform",
"-p",
project_dir,
Expand Down Expand Up @@ -298,10 +297,9 @@ def test_can_chain_transforms_in_working_tree_without_hashing(self):
source_url,
)
run(self, "filter", "-p", project_dir, "-e", '/item/annotation[label="b"]')
run(self, "project", "transform", "-p", project_dir, "-t", "rename", "--", "-e", "|2|qq|")
run(self, "transform", "-p", project_dir, "-t", "rename", "--", "-e", "|2|qq|")
run(
self,
"project",
"transform",
"-p",
project_dir,
Expand Down
4 changes: 0 additions & 4 deletions tests/integration/cli/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def test_can_transform_dataset_inplace(self):

run(
self,
"project",
"transform",
"-t",
"remap_labels",
Expand Down Expand Up @@ -72,7 +71,6 @@ def test_transform_fails_on_inplace_update_without_overwrite(self):

run(
self,
"project",
"transform",
"-t",
"random_split",
Expand Down Expand Up @@ -112,7 +110,6 @@ def test_transform_fails_on_inplace_update_of_stage(self):
with self.subTest("without overwrite"):
run(
self,
"project",
"transform",
"-p",
project_dir,
Expand All @@ -126,7 +123,6 @@ def test_transform_fails_on_inplace_update_of_stage(self):
with self.assertRaises(ReadonlyDatasetError):
run(
self,
"project",
"transform",
"-p",
project_dir,
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/cli/test_voc_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ def test_preparing_dataset_for_train_model(self):

run(
self,
"project",
"transform",
"-p",
test_dir,
Expand Down Expand Up @@ -724,7 +723,6 @@ def test_label_projection_with_masks(self):

run(
self,
"project",
"transform",
"-p",
test_dir,
Expand Down
1 change: 0 additions & 1 deletion tests/integration/cli/test_yolo_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ def test_can_delete_labels_from_yolo_dataset(self):

run(
self,
"project",
"transform",
"-p",
test_dir,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_telemetry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import types
from unittest import TestCase, mock

from datumaro.cli.commands.require_project.dataset_operations.info import info_command
from datumaro.cli.commands.info import info_command
from datumaro.util.telemetry_utils import (
send_command_exception_info,
send_command_failure_info,
Expand Down