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

Enhance the error message for datum stats to be more user friendly #1069

Merged
merged 3 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(<https://github.com/openvinotoolkit/datumaro/pull/1047>)
- Refactor Launcher and ModelInterpreter
(<https://github.com/openvinotoolkit/datumaro/pull/1055>)
- Enhance the error message for datum stats to be more user friendly
(<https://github.com/openvinotoolkit/datumaro/pull/1069>)

### Bug fixes
- Fix warnings in test_visualizer.py
Expand Down
19 changes: 17 additions & 2 deletions src/datumaro/cli/commands/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import argparse
import logging as log

from datumaro.components.errors import ProjectNotFoundError
from datumaro.cli.util.errors import CliException, WrongRevpathError
from datumaro.components.errors import ConflictingCategoriesError, ProjectNotFoundError
from datumaro.components.operations import compute_ann_statistics, compute_image_statistics
from datumaro.util import dump_json_file, str_to_bool
from datumaro.util.scope import scope_add, scoped
Expand Down Expand Up @@ -87,7 +88,21 @@ def stats_command(args):
if args.project_dir:
raise

dataset, target_project = parse_full_revpath(args.target, project)
try:
dataset, target_project = parse_full_revpath(args.target, project)
except WrongRevpathError as e:
for p in e.problems:
if isinstance(p, ConflictingCategoriesError):
src_names = [src for src in project.working_tree.sources]
raise CliException(
"There are more than two sources with heterogeneous categories in the project. "
"This prevents computing the statistics of the merged one. "
f"Please specify one of the sources in the project ({src_names}), "
f"such as `datum stats {src_names[0]}`"
) from e

raise e

if target_project:
scope_add(target_project)

Expand Down