From cd39c59781a694f5aecf54f5a12bfeeac710e2d9 Mon Sep 17 00:00:00 2001 From: Kirill Lakhov Date: Tue, 14 May 2024 19:49:52 +0300 Subject: [PATCH 01/10] added wrappers for DatasetNotFound error --- datumaro/components/environment.py | 5 ++++ datumaro/components/errors.py | 4 ++- datumaro/components/extractor.py | 6 ++++- datumaro/components/wrappers.py | 41 ++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 datumaro/components/wrappers.py diff --git a/datumaro/components/environment.py b/datumaro/components/environment.py index 4e2b9e72c3..d1042912a6 100644 --- a/datumaro/components/environment.py +++ b/datumaro/components/environment.py @@ -12,6 +12,7 @@ from datumaro.components.cli_plugin import CliPlugin, plugin_types from datumaro.components.format_detection import RejectionReason, detect_dataset_format +from datumaro.components.wrappers import wrap_importer from datumaro.util.os_util import import_foreign_module, split_path T = TypeVar("T") @@ -226,6 +227,10 @@ def _register_plugins(self, plugins): self.transforms.batch_register(plugins) self.validators.batch_register(plugins) + for key in self.importers: + importer = self.importers.get(key) + wrap_importer(importer) + def make_extractor(self, name, *args, **kwargs): return self.extractors.get(name)(*args, **kwargs) diff --git a/datumaro/components/errors.py b/datumaro/components/errors.py index 45c533efdc..fb924849fc 100644 --- a/datumaro/components/errors.py +++ b/datumaro/components/errors.py @@ -273,9 +273,11 @@ def __str__(self): @define(auto_exc=False) class DatasetNotFoundError(DatasetImportError): path = field() + ext = field(default="") def __str__(self): - return f"Failed to find dataset at '{self.path}'" + file_ext_info = f", file '{self.ext}' was not found" if self.ext else '' + return f"Failed to find dataset at '{self.path}' {file_ext_info}" @define(auto_exc=False) diff --git a/datumaro/components/extractor.py b/datumaro/components/extractor.py index 290798e02f..54a5dbdcfb 100644 --- a/datumaro/components/extractor.py +++ b/datumaro/components/extractor.py @@ -433,13 +433,17 @@ def find_sources(cls, path) -> List[Dict]: def find_sources_with_params(cls, path, **extra_params) -> List[Dict]: return cls.find_sources(path) + @classmethod + def _generate_not_found_error(self, path): + return DatasetNotFoundError(path) + def __call__(self, path, **extra_params): if not path or not osp.exists(path): raise DatasetNotFoundError(path) found_sources = self.find_sources_with_params(osp.normpath(path), **extra_params) if not found_sources: - raise DatasetNotFoundError(path) + raise self._generate_not_found_error(path) sources = [] for desc in found_sources: diff --git a/datumaro/components/wrappers.py b/datumaro/components/wrappers.py new file mode 100644 index 0000000000..ed5aa7c7ad --- /dev/null +++ b/datumaro/components/wrappers.py @@ -0,0 +1,41 @@ +# Copyright (C) 2024 CVAT.ai Corporation +# +# SPDX-License-Identifier: MIT + +from unittest import mock +from typing import Optional, Callable + +from datumaro.components.errors import DatasetNotFoundError + +def wrap_find_sources_recursive(importer): + @classmethod + def updated_find_sources_recursive( + cls, + path: str, + ext: Optional[str], + extractor_name: str, + filename: str = "*", + dirname: str = "", + file_filter: Optional[Callable[[str], bool]] = None, + max_depth: int = 3, + ): + sources = super(importer, cls)._find_sources_recursive( + path, ext, extractor_name, + filename, dirname, file_filter, max_depth + ) + if not sources: + cls._not_found_error_data = {"ext": ext} + + return updated_find_sources_recursive + +def wrap_generate_not_found_error(importer): + @classmethod + def updated_generate_not_found_error(cls, path): + return DatasetNotFoundError(path, cls._not_found_error_data.get("ext")) + + return updated_generate_not_found_error + +def wrap_importer(importer): + mock.patch.object(importer, '_find_sources_recursive', new=wrap_find_sources_recursive(importer)).start() + mock.patch.object(importer, '_generate_not_found_error', new=wrap_generate_not_found_error(importer)).start() + mock.patch.object(importer, '_not_found_error_data', new={"ext": ""}, create=True).start() From 826146f780d245580642c8c9be3f12e1a5fed854 Mon Sep 17 00:00:00 2001 From: Kirill Lakhov Date: Wed, 15 May 2024 10:25:44 +0300 Subject: [PATCH 02/10] fixed return sources --- datumaro/components/wrappers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/datumaro/components/wrappers.py b/datumaro/components/wrappers.py index ed5aa7c7ad..23075843a3 100644 --- a/datumaro/components/wrappers.py +++ b/datumaro/components/wrappers.py @@ -23,12 +23,15 @@ def updated_find_sources_recursive( path, ext, extractor_name, filename, dirname, file_filter, max_depth ) + if not sources: cls._not_found_error_data = {"ext": ext} + return sources + return updated_find_sources_recursive -def wrap_generate_not_found_error(importer): +def wrap_generate_not_found_error(): @classmethod def updated_generate_not_found_error(cls, path): return DatasetNotFoundError(path, cls._not_found_error_data.get("ext")) @@ -37,5 +40,5 @@ def updated_generate_not_found_error(cls, path): def wrap_importer(importer): mock.patch.object(importer, '_find_sources_recursive', new=wrap_find_sources_recursive(importer)).start() - mock.patch.object(importer, '_generate_not_found_error', new=wrap_generate_not_found_error(importer)).start() + mock.patch.object(importer, '_generate_not_found_error', new=wrap_generate_not_found_error()).start() mock.patch.object(importer, '_not_found_error_data', new={"ext": ""}, create=True).start() From 740e77a1703ce5b3f2d8834d02d51865d628f184 Mon Sep 17 00:00:00 2001 From: Kirill Lakhov Date: Wed, 15 May 2024 10:33:34 +0300 Subject: [PATCH 03/10] added filename --- datumaro/components/errors.py | 3 ++- datumaro/components/wrappers.py | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/datumaro/components/errors.py b/datumaro/components/errors.py index fb924849fc..78d87d3ef3 100644 --- a/datumaro/components/errors.py +++ b/datumaro/components/errors.py @@ -274,9 +274,10 @@ def __str__(self): class DatasetNotFoundError(DatasetImportError): path = field() ext = field(default="") + filename = field(default="") def __str__(self): - file_ext_info = f", file '{self.ext}' was not found" if self.ext else '' + file_ext_info = f", file '{self.filename}{self.ext}' was not found" if self.ext or self.filename else '' return f"Failed to find dataset at '{self.path}' {file_ext_info}" diff --git a/datumaro/components/wrappers.py b/datumaro/components/wrappers.py index 23075843a3..3c1891f368 100644 --- a/datumaro/components/wrappers.py +++ b/datumaro/components/wrappers.py @@ -25,7 +25,7 @@ def updated_find_sources_recursive( ) if not sources: - cls._not_found_error_data = {"ext": ext} + cls._not_found_error_data = {"ext": ext, "filename": filename} return sources @@ -34,11 +34,15 @@ def updated_find_sources_recursive( def wrap_generate_not_found_error(): @classmethod def updated_generate_not_found_error(cls, path): - return DatasetNotFoundError(path, cls._not_found_error_data.get("ext")) + return DatasetNotFoundError( + path, + cls._not_found_error_data.get("ext", ""), + cls._not_found_error_data.get("filename", ""), + ) return updated_generate_not_found_error def wrap_importer(importer): mock.patch.object(importer, '_find_sources_recursive', new=wrap_find_sources_recursive(importer)).start() mock.patch.object(importer, '_generate_not_found_error', new=wrap_generate_not_found_error()).start() - mock.patch.object(importer, '_not_found_error_data', new={"ext": ""}, create=True).start() + mock.patch.object(importer, '_not_found_error_data', new={"ext": "", "filename": ""}, create=True).start() From b9bdab0ab4b6e346652b9fa380edbba264e875e0 Mon Sep 17 00:00:00 2001 From: Kirill Lakhov Date: Wed, 15 May 2024 10:42:26 +0300 Subject: [PATCH 04/10] fixed linters --- datumaro/components/errors.py | 2 +- datumaro/components/wrappers.py | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/datumaro/components/errors.py b/datumaro/components/errors.py index 78d87d3ef3..d65b71885b 100644 --- a/datumaro/components/errors.py +++ b/datumaro/components/errors.py @@ -277,7 +277,7 @@ class DatasetNotFoundError(DatasetImportError): filename = field(default="") def __str__(self): - file_ext_info = f", file '{self.filename}{self.ext}' was not found" if self.ext or self.filename else '' + file_ext_info = f", file '{self.filename}{self.ext}' was not found" if self.ext or self.filename else "" return f"Failed to find dataset at '{self.path}' {file_ext_info}" diff --git a/datumaro/components/wrappers.py b/datumaro/components/wrappers.py index 3c1891f368..d1ec21e688 100644 --- a/datumaro/components/wrappers.py +++ b/datumaro/components/wrappers.py @@ -2,8 +2,8 @@ # # SPDX-License-Identifier: MIT -from unittest import mock from typing import Optional, Callable +from unittest import mock from datumaro.components.errors import DatasetNotFoundError @@ -20,8 +20,7 @@ def updated_find_sources_recursive( max_depth: int = 3, ): sources = super(importer, cls)._find_sources_recursive( - path, ext, extractor_name, - filename, dirname, file_filter, max_depth + path, ext, extractor_name, filename, dirname, file_filter, max_depth ) if not sources: @@ -43,6 +42,12 @@ def updated_generate_not_found_error(cls, path): return updated_generate_not_found_error def wrap_importer(importer): - mock.patch.object(importer, '_find_sources_recursive', new=wrap_find_sources_recursive(importer)).start() - mock.patch.object(importer, '_generate_not_found_error', new=wrap_generate_not_found_error()).start() - mock.patch.object(importer, '_not_found_error_data', new={"ext": "", "filename": ""}, create=True).start() + mock.patch.object( + importer, '_find_sources_recursive', new=wrap_find_sources_recursive(importer) + ).start() + mock.patch.object( + importer, '_generate_not_found_error', new=wrap_generate_not_found_error() + ).start() + mock.patch.object( + importer, '_not_found_error_data', new={"ext": "", "filename": ""}, create=True + ).start() From b6ac33891cd94cb5d8e31976465769e9cdfdf26a Mon Sep 17 00:00:00 2001 From: Kirill Lakhov Date: Wed, 15 May 2024 12:34:10 +0300 Subject: [PATCH 05/10] fixed linter --- datumaro/components/errors.py | 4 +++- datumaro/components/wrappers.py | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/datumaro/components/errors.py b/datumaro/components/errors.py index d65b71885b..a53d74dae9 100644 --- a/datumaro/components/errors.py +++ b/datumaro/components/errors.py @@ -277,7 +277,9 @@ class DatasetNotFoundError(DatasetImportError): filename = field(default="") def __str__(self): - file_ext_info = f", file '{self.filename}{self.ext}' was not found" if self.ext or self.filename else "" + file_ext_info = ( + f", file '{self.filename}{self.ext}' was not found" if self.ext or self.filename else "" + ) return f"Failed to find dataset at '{self.path}' {file_ext_info}" diff --git a/datumaro/components/wrappers.py b/datumaro/components/wrappers.py index d1ec21e688..4390f5b67c 100644 --- a/datumaro/components/wrappers.py +++ b/datumaro/components/wrappers.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: MIT -from typing import Optional, Callable +from typing import Callable, Optional from unittest import mock from datumaro.components.errors import DatasetNotFoundError @@ -43,11 +43,11 @@ def updated_generate_not_found_error(cls, path): def wrap_importer(importer): mock.patch.object( - importer, '_find_sources_recursive', new=wrap_find_sources_recursive(importer) + importer, "_find_sources_recursive", new=wrap_find_sources_recursive(importer) ).start() mock.patch.object( - importer, '_generate_not_found_error', new=wrap_generate_not_found_error() + importer, "_generate_not_found_error", new=wrap_generate_not_found_error() ).start() mock.patch.object( - importer, '_not_found_error_data', new={"ext": "", "filename": ""}, create=True + importer, "_not_found_error_data", new={"ext": "", "filename": ""}, create=True ).start() From 484e5a742dc8bb5f0a127f185178c722e11df8f1 Mon Sep 17 00:00:00 2001 From: Kirill Lakhov Date: Wed, 15 May 2024 12:39:50 +0300 Subject: [PATCH 06/10] added newlines --- datumaro/components/wrappers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/datumaro/components/wrappers.py b/datumaro/components/wrappers.py index 4390f5b67c..5397f2f9a1 100644 --- a/datumaro/components/wrappers.py +++ b/datumaro/components/wrappers.py @@ -7,6 +7,7 @@ from datumaro.components.errors import DatasetNotFoundError + def wrap_find_sources_recursive(importer): @classmethod def updated_find_sources_recursive( @@ -30,6 +31,7 @@ def updated_find_sources_recursive( return updated_find_sources_recursive + def wrap_generate_not_found_error(): @classmethod def updated_generate_not_found_error(cls, path): @@ -41,6 +43,7 @@ def updated_generate_not_found_error(cls, path): return updated_generate_not_found_error + def wrap_importer(importer): mock.patch.object( importer, "_find_sources_recursive", new=wrap_find_sources_recursive(importer) From c6596a47a168297a286dfefb4cd0f3e083d05a1d Mon Sep 17 00:00:00 2001 From: Kirill Lakhov Date: Thu, 16 May 2024 13:15:04 +0300 Subject: [PATCH 07/10] fixed classmethod decorator --- datumaro/components/wrappers.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/datumaro/components/wrappers.py b/datumaro/components/wrappers.py index 5397f2f9a1..afbcca4d15 100644 --- a/datumaro/components/wrappers.py +++ b/datumaro/components/wrappers.py @@ -9,7 +9,6 @@ def wrap_find_sources_recursive(importer): - @classmethod def updated_find_sources_recursive( cls, path: str, @@ -29,11 +28,10 @@ def updated_find_sources_recursive( return sources - return updated_find_sources_recursive + return classmethod(updated_find_sources_recursive) def wrap_generate_not_found_error(): - @classmethod def updated_generate_not_found_error(cls, path): return DatasetNotFoundError( path, @@ -41,7 +39,7 @@ def updated_generate_not_found_error(cls, path): cls._not_found_error_data.get("filename", ""), ) - return updated_generate_not_found_error + return classmethod(updated_generate_not_found_error) def wrap_importer(importer): From e460773f58c67ecb26b46e311142452d28a027c9 Mon Sep 17 00:00:00 2001 From: Kirill Lakhov Date: Thu, 16 May 2024 14:32:00 +0300 Subject: [PATCH 08/10] assign empty set to old_ids --- datumaro/components/dataset.py | 1 + 1 file changed, 1 insertion(+) diff --git a/datumaro/components/dataset.py b/datumaro/components/dataset.py index d5309dadf1..bbb2508780 100644 --- a/datumaro/components/dataset.py +++ b/datumaro/components/dataset.py @@ -421,6 +421,7 @@ def _update_status(item_id, new_status: ItemStatus): ) transform = None + old_ids = set() if self._transforms: transform = _StackedTransform(source, self._transforms) if transform.is_local: From 48993d49960086ef8ae00486fd06e1b33a046925 Mon Sep 17 00:00:00 2001 From: Kirill Lakhov Date: Fri, 17 May 2024 11:23:36 +0300 Subject: [PATCH 09/10] removed patching --- datumaro/components/environment.py | 5 --- datumaro/components/extractor.py | 25 +++++++++++--- datumaro/components/wrappers.py | 54 ------------------------------ 3 files changed, 20 insertions(+), 64 deletions(-) delete mode 100644 datumaro/components/wrappers.py diff --git a/datumaro/components/environment.py b/datumaro/components/environment.py index d1042912a6..4e2b9e72c3 100644 --- a/datumaro/components/environment.py +++ b/datumaro/components/environment.py @@ -12,7 +12,6 @@ from datumaro.components.cli_plugin import CliPlugin, plugin_types from datumaro.components.format_detection import RejectionReason, detect_dataset_format -from datumaro.components.wrappers import wrap_importer from datumaro.util.os_util import import_foreign_module, split_path T = TypeVar("T") @@ -227,10 +226,6 @@ def _register_plugins(self, plugins): self.transforms.batch_register(plugins) self.validators.batch_register(plugins) - for key in self.importers: - importer = self.importers.get(key) - wrap_importer(importer) - def make_extractor(self, name, *args, **kwargs): return self.extractors.get(name)(*args, **kwargs) diff --git a/datumaro/components/extractor.py b/datumaro/components/extractor.py index 54a5dbdcfb..71d85987ad 100644 --- a/datumaro/components/extractor.py +++ b/datumaro/components/extractor.py @@ -415,6 +415,17 @@ def get(self, id, subset=None): class Importer(CliPlugin): + def __init__(self): + self.__not_found_error_data = {"ext": "", "filename": ""} + + @property + def _not_found_error_data(self): + return self.__not_found_error_data + + @_not_found_error_data.setter + def _not_found_error_data_setter(self, val): + self.__not_found_error_data = val + @classmethod def detect( cls, @@ -433,17 +444,17 @@ def find_sources(cls, path) -> List[Dict]: def find_sources_with_params(cls, path, **extra_params) -> List[Dict]: return cls.find_sources(path) - @classmethod - def _generate_not_found_error(self, path): - return DatasetNotFoundError(path) - def __call__(self, path, **extra_params): if not path or not osp.exists(path): raise DatasetNotFoundError(path) found_sources = self.find_sources_with_params(osp.normpath(path), **extra_params) if not found_sources: - raise self._generate_not_found_error(path) + raise DatasetNotFoundError( + path, + self._not_found_error_data.get("ext", ""), + self._not_found_error_data.get("filename", ""), + ) sources = [] for desc in found_sources: @@ -508,6 +519,10 @@ def _find_sources_recursive( ) if sources: break + + if not sources: + cls._not_found_error_data = {"ext": ext, "filename": filename} + return sources diff --git a/datumaro/components/wrappers.py b/datumaro/components/wrappers.py deleted file mode 100644 index afbcca4d15..0000000000 --- a/datumaro/components/wrappers.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (C) 2024 CVAT.ai Corporation -# -# SPDX-License-Identifier: MIT - -from typing import Callable, Optional -from unittest import mock - -from datumaro.components.errors import DatasetNotFoundError - - -def wrap_find_sources_recursive(importer): - def updated_find_sources_recursive( - cls, - path: str, - ext: Optional[str], - extractor_name: str, - filename: str = "*", - dirname: str = "", - file_filter: Optional[Callable[[str], bool]] = None, - max_depth: int = 3, - ): - sources = super(importer, cls)._find_sources_recursive( - path, ext, extractor_name, filename, dirname, file_filter, max_depth - ) - - if not sources: - cls._not_found_error_data = {"ext": ext, "filename": filename} - - return sources - - return classmethod(updated_find_sources_recursive) - - -def wrap_generate_not_found_error(): - def updated_generate_not_found_error(cls, path): - return DatasetNotFoundError( - path, - cls._not_found_error_data.get("ext", ""), - cls._not_found_error_data.get("filename", ""), - ) - - return classmethod(updated_generate_not_found_error) - - -def wrap_importer(importer): - mock.patch.object( - importer, "_find_sources_recursive", new=wrap_find_sources_recursive(importer) - ).start() - mock.patch.object( - importer, "_generate_not_found_error", new=wrap_generate_not_found_error() - ).start() - mock.patch.object( - importer, "_not_found_error_data", new={"ext": "", "filename": ""}, create=True - ).start() From aae4bb81c38440cb68432c577f78ed068b35679a Mon Sep 17 00:00:00 2001 From: Kirill Lakhov Date: Fri, 17 May 2024 17:16:52 +0300 Subject: [PATCH 10/10] updated solution to use detect_dataset --- datumaro/components/dataset.py | 21 +++++++++++++++++++-- datumaro/components/environment.py | 15 +++++++++++---- datumaro/components/errors.py | 8 ++------ datumaro/components/extractor.py | 20 +------------------- 4 files changed, 33 insertions(+), 31 deletions(-) diff --git a/datumaro/components/dataset.py b/datumaro/components/dataset.py index bbb2508780..b9752092c1 100644 --- a/datumaro/components/dataset.py +++ b/datumaro/components/dataset.py @@ -22,6 +22,7 @@ from datumaro.components.errors import ( CategoriesRedefinedError, ConflictingCategoriesError, + DatasetNotFoundError, MediaTypeError, MultipleFormatsMatchError, NoMatchingFormatsError, @@ -1158,6 +1159,15 @@ def import_from( if not format: format = cls.detect(path, env=env) + else: + not_found_error_instance = DatasetNotFoundError(path) + + def not_found_error(format_name, reason, human_message): + not_found_error_instance.reason = human_message + + detected = env.detect_dataset(path, rejection_callback=not_found_error, depth=3, format=format) + if not detected: + raise not_found_error_instance # TODO: remove importers, put this logic into extractors if format in env.importers: @@ -1227,7 +1237,14 @@ def import_from( return dataset @staticmethod - def detect(path: str, *, env: Optional[Environment] = None, depth: int = 2) -> str: + def detect( + path: str, + *, + env: Optional[Environment] = None, + depth: int = 2, + rejection_callback:Optional[Callable] = None, + format: Optional[str] = None, + ) -> str: """ Attempts to detect dataset format of a given directory. @@ -1247,7 +1264,7 @@ def detect(path: str, *, env: Optional[Environment] = None, depth: int = 2) -> s if depth < 0: raise ValueError("Depth cannot be less than zero") - matches = env.detect_dataset(path, depth=depth) + matches = env.detect_dataset(path, depth=depth, rejection_callback=rejection_callback, format=format) if not matches: raise NoMatchingFormatsError() elif 1 < len(matches): diff --git a/datumaro/components/environment.py b/datumaro/components/environment.py index 4e2b9e72c3..4a1848da1b 100644 --- a/datumaro/components/environment.py +++ b/datumaro/components/environment.py @@ -252,15 +252,22 @@ def detect_dataset( path: str, depth: int = 1, rejection_callback: Optional[Callable[[str, RejectionReason, str], None]] = None, + format: Optional[str] = None ) -> List[str]: ignore_dirs = {"__MSOSX", "__MACOSX"} matched_formats = set() + detectors = [] + if not format: + detectors = ( + (format_name, importer.detect) + for format_name, importer in self.importers.items.items() + ) + elif self.is_format_known(format): + detectors = [(format, self.importers.get(format).detect)] + for _ in range(depth + 1): detected_formats = detect_dataset_format( - ( - (format_name, importer.detect) - for format_name, importer in self.importers.items.items() - ), + detectors, path, rejection_callback=rejection_callback, ) diff --git a/datumaro/components/errors.py b/datumaro/components/errors.py index a53d74dae9..b6387fe38b 100644 --- a/datumaro/components/errors.py +++ b/datumaro/components/errors.py @@ -273,14 +273,10 @@ def __str__(self): @define(auto_exc=False) class DatasetNotFoundError(DatasetImportError): path = field() - ext = field(default="") - filename = field(default="") + reason = field(default='') def __str__(self): - file_ext_info = ( - f", file '{self.filename}{self.ext}' was not found" if self.ext or self.filename else "" - ) - return f"Failed to find dataset at '{self.path}' {file_ext_info}" + return f"Failed to find dataset at '{self.path}' {self.reason}" @define(auto_exc=False) diff --git a/datumaro/components/extractor.py b/datumaro/components/extractor.py index 71d85987ad..6b1867394f 100644 --- a/datumaro/components/extractor.py +++ b/datumaro/components/extractor.py @@ -415,17 +415,6 @@ def get(self, id, subset=None): class Importer(CliPlugin): - def __init__(self): - self.__not_found_error_data = {"ext": "", "filename": ""} - - @property - def _not_found_error_data(self): - return self.__not_found_error_data - - @_not_found_error_data.setter - def _not_found_error_data_setter(self, val): - self.__not_found_error_data = val - @classmethod def detect( cls, @@ -450,11 +439,7 @@ def __call__(self, path, **extra_params): found_sources = self.find_sources_with_params(osp.normpath(path), **extra_params) if not found_sources: - raise DatasetNotFoundError( - path, - self._not_found_error_data.get("ext", ""), - self._not_found_error_data.get("filename", ""), - ) + raise DatasetNotFoundError(path) sources = [] for desc in found_sources: @@ -520,9 +505,6 @@ def _find_sources_recursive( if sources: break - if not sources: - cls._not_found_error_data = {"ext": ext, "filename": filename} - return sources