Skip to content

Commit

Permalink
Allow direct matching of files without extension in _find_sources_rec…
Browse files Browse the repository at this point in the history
…ursive (cvat-ai#378)

* small fix in _find_sources_recursive

* Add tests

Co-authored-by: Maxim Zhiltsov <[email protected]>
  • Loading branch information
yasakova-anastasia and Maxim Zhiltsov authored Jul 28, 2021
1 parent f11071f commit 990df27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datumaro/components/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def _find_sources_recursive(cls, path: str, ext: Optional[str],
ext = '.' + ext
ext = ext.lower()

if (ext and path.lower().endswith(ext) and osp.isfile(path)) or \
if (path.lower().endswith(ext) and osp.isfile(path)) or \
(not ext and dirname and osp.isdir(path) and \
os.sep + osp.normpath(dirname.lower()) + os.sep in \
osp.abspath(path.lower()) + os.sep):
Expand Down
10 changes: 10 additions & 0 deletions tests/test_cifar_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ def test_can_import_10(self):
def test_can_detect_10(self):
self.assertTrue(CifarImporter.detect(DUMMY_10_DATASET_DIR))

@mark_requirement(Requirements.DATUM_GENERAL_REQ)
def test_can_detect_10_subset(self):
self.assertTrue(CifarImporter.detect(
osp.join(DUMMY_10_DATASET_DIR, 'data_batch_1')))

@mark_requirement(Requirements.DATUM_GENERAL_REQ)
def test_can_import_100(self):
# Unless simple dataset merge can't overlap labels and add parent
Expand Down Expand Up @@ -301,3 +306,8 @@ def test_can_import_100(self):
@mark_requirement(Requirements.DATUM_GENERAL_REQ)
def test_can_detect_100(self):
self.assertTrue(CifarImporter.detect(DUMMY_100_DATASET_DIR))

@mark_requirement(Requirements.DATUM_GENERAL_REQ)
def test_can_detect_100_subset(self):
self.assertTrue(CifarImporter.detect(
osp.join(DUMMY_100_DATASET_DIR, 'train')))

0 comments on commit 990df27

Please sign in to comment.