Skip to content

Commit ddde11d

Browse files
authored
Fix log issue when importing celeba and align celeba dataset (#919)
<!-- 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 --> When import `celeba` or `align_celeba` dataset without format like `dm.Dataset.import_from(path=...)`, we met error like below. The example is the case for importing `align_celeba` dataset. ``` ERROR:root:Cannot find celeba's images directory at tests/assets/align_celeba_dataset/dataset/Img/img_celeba ``` ### How to test <!-- Describe the testing procedure for reviewers, if changes are not fully covered by unit tests or manual testing can be complicated. --> ### 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 ```
1 parent 8cf70ba commit ddde11d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
(<https://github.com/openvinotoolkit/datumaro/pull/891>)
2424
- Fix negated `is_encrypted`
2525
(<https://github.com/openvinotoolkit/datumaro/pull/907>)
26+
- Fix log issue when importing celeba and align celeba dataset
27+
(<https://github.com/openvinotoolkit/datumaro/pull/919>)
2628

2729
## 28/03/2023 - Release 1.1.1
2830
### Bug fixes

datumaro/plugins/data_formats/celeba/celeba.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#
33
# SPDX-License-Identifier: MIT
44

5-
import logging as log
65
import os.path as osp
76

87
from datumaro.components.annotation import (
@@ -236,7 +235,10 @@ class CelebaImporter(Importer):
236235

237236
@classmethod
238237
def detect(cls, context: FormatDetectionContext) -> FormatDetectionConfidence:
239-
super().detect(context)
238+
try:
239+
super().detect(context)
240+
except DatasetImportError as e:
241+
context.fail(str(e))
240242
return FormatDetectionConfidence.MEDIUM
241243

242244
@classmethod
@@ -248,19 +250,17 @@ def find_sources(cls, path):
248250
)
249251

250252
if len(sources) > 1:
251-
log.error(
253+
raise DatasetImportError(
252254
f"{cls.NAME} label file ({cls.PATH_CLS.LABELS_FILE}) must be unique "
253255
f"but the found sources have multiple duplicates. sources = {sources}"
254256
)
255-
return []
256257

257258
for source in sources:
258259
anno_dir = osp.dirname(source["url"])
259260
root_dir = osp.dirname(anno_dir)
260261
img_dir = osp.join(root_dir, cls.PATH_CLS.IMAGES_DIR)
261262
if not osp.exists(img_dir):
262-
log.error(f"Cannot find {cls.NAME}'s images directory at {img_dir}")
263-
return []
263+
raise DatasetImportError(f"Cannot find {cls.NAME}'s images directory at {img_dir}")
264264
source["url"] = root_dir
265265

266266
return sources

0 commit comments

Comments
 (0)