Skip to content

Commit 740e77a

Browse files
committed
added filename
1 parent 826146f commit 740e77a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

datumaro/components/errors.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,10 @@ def __str__(self):
274274
class DatasetNotFoundError(DatasetImportError):
275275
path = field()
276276
ext = field(default="")
277+
filename = field(default="")
277278

278279
def __str__(self):
279-
file_ext_info = f", file '{self.ext}' was not found" if self.ext else ''
280+
file_ext_info = f", file '{self.filename}{self.ext}' was not found" if self.ext or self.filename else ''
280281
return f"Failed to find dataset at '{self.path}' {file_ext_info}"
281282

282283

datumaro/components/wrappers.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def updated_find_sources_recursive(
2525
)
2626

2727
if not sources:
28-
cls._not_found_error_data = {"ext": ext}
28+
cls._not_found_error_data = {"ext": ext, "filename": filename}
2929

3030
return sources
3131

@@ -34,11 +34,15 @@ def updated_find_sources_recursive(
3434
def wrap_generate_not_found_error():
3535
@classmethod
3636
def updated_generate_not_found_error(cls, path):
37-
return DatasetNotFoundError(path, cls._not_found_error_data.get("ext"))
37+
return DatasetNotFoundError(
38+
path,
39+
cls._not_found_error_data.get("ext", ""),
40+
cls._not_found_error_data.get("filename", ""),
41+
)
3842

3943
return updated_generate_not_found_error
4044

4145
def wrap_importer(importer):
4246
mock.patch.object(importer, '_find_sources_recursive', new=wrap_find_sources_recursive(importer)).start()
4347
mock.patch.object(importer, '_generate_not_found_error', new=wrap_generate_not_found_error()).start()
44-
mock.patch.object(importer, '_not_found_error_data', new={"ext": ""}, create=True).start()
48+
mock.patch.object(importer, '_not_found_error_data', new={"ext": "", "filename": ""}, create=True).start()

0 commit comments

Comments
 (0)