Skip to content

Commit

Permalink
Add default value for target in prune cli (#1253)
Browse files Browse the repository at this point in the history
<!-- Contributing guide:
https://github.com/openvinotoolkit/datumaro/blob/develop/CONTRIBUTING.md
-->

### Summary

<!--
Resolves #111 and #222.
Depends on #1000 (for series of dependent commits).

This PR introduces this capability to make the project better in this
and that.

- Added this feature
- Removed that feature
- Fixed the problem #1234
-->
- Fix prune cli #1225 
- Remove unnecessary line for dataset saving

### How to test
<!-- Describe the testing procedure for reviewers, if changes are
not fully covered by unit tests or manual testing can be complicated.
-->
- Use existed cli test

### Checklist
<!-- Put an 'x' in all the boxes that apply -->
- [ ] I have added unit tests to cover my changes.​
- [ ] I have added integration tests to cover my changes.​
- [X] I have added the description of my changes into
[CHANGELOG](https://github.com/openvinotoolkit/datumaro/blob/develop/CHANGELOG.md).​
- [ ] I have updated the
[documentation](https://github.com/openvinotoolkit/datumaro/tree/develop/docs)
accordingly

### License

- [ ] I submit _my code changes_ under the same [MIT
License](https://github.com/openvinotoolkit/datumaro/blob/develop/LICENSE)
that covers the project.
  Feel free to contact the maintainers if that's a concern.
- [ ] I have updated the license header for each file (see an example
below).

```python
# Copyright (C) 2023 Intel Corporation
#
# SPDX-License-Identifier: MIT
```
  • Loading branch information
sooahleex authored Feb 1, 2024
1 parent a819dbb commit acc491d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(<https://github.com/openvinotoolkit/datumaro/pull/1244>)
- Fix input tensor shape in model interpreter for OpenVINO 2023.3
(<https://github.com/openvinotoolkit/datumaro/pull/1251>)
- Add default value for target in prune cli
(<https://github.com/openvinotoolkit/datumaro/pull/1253>)

## 16/11/2023 - Release 1.5.1
### Enhancements
Expand Down
15 changes: 11 additions & 4 deletions src/datumaro/cli/commands/prune.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import argparse
import logging as log
import os.path as osp

from datumaro.components.algorithms.hash_key_inference.prune import Prune
from datumaro.components.errors import ProjectNotFoundError
Expand Down Expand Up @@ -45,7 +46,13 @@ def build_parser(parser_ctor=argparse.ArgumentParser):
formatter_class=MultilineFormatter,
)

parser.add_argument("target", nargs="?", help="Target dataset revpath (default: project)")
parser.add_argument(
"target",
nargs="?",
default="project",
metavar="revpath",
help="Target dataset revpath (default: project)",
)
parser.add_argument("-m", "--method", dest="method", help="Method to apply to the dataset")
parser.add_argument(
"-r", "--ratio", type=float, dest="ratio", help="How much to remain dataset after pruning"
Expand Down Expand Up @@ -110,12 +117,12 @@ def prune_command(args):
source_dataset = [parse_full_revpath(target, project)[0] for target in targets][0]

prune = Prune(source_dataset, cluster_method=args.method, hash_type=args.hash_type)

source_dataset.save(source_dataset.data_path, save_media=True, save_hashkey_meta=True)

result = prune.get_pruned(args.ratio)

dst_dir = args.dst_dir or source_dataset.data_path
dst_dir = (
dst_dir if dst_dir else osp.join(args.project_dir, list(project.working_tree.sources)[0])
)
result.save(dst_dir, save_media=True)

log.info("Results have been saved to '%s'" % dst_dir)

0 comments on commit acc491d

Please sign in to comment.