From 9b29b5a37287be40909be4f7e65a7ba7e9fb0bcb Mon Sep 17 00:00:00 2001 From: PGijsbers Date: Mon, 1 Nov 2021 15:51:30 +0100 Subject: [PATCH 1/3] Add AttributeError as suspect for dependency issue Happens for example when loading a 1.3 dataframe with a 1.0 pandas. --- openml/datasets/dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openml/datasets/dataset.py b/openml/datasets/dataset.py index 122e2e697..466cb0122 100644 --- a/openml/datasets/dataset.py +++ b/openml/datasets/dataset.py @@ -544,13 +544,13 @@ def _load_data(self): data, categorical, attribute_names = pickle.load(fh) except FileNotFoundError: raise ValueError(f"Cannot find file for dataset {self.name} at location '{fpath}'.") - except (EOFError, ModuleNotFoundError, ValueError) as e: + except (EOFError, ModuleNotFoundError, ValueError, AttributeError) as e: error_message = e.message if hasattr(e, "message") else e.args[0] hint = "" if isinstance(e, EOFError): readable_error = "Detected a corrupt cache file" - elif isinstance(e, ModuleNotFoundError): + elif isinstance(e, (ModuleNotFoundError, AttributeError)): readable_error = "Detected likely dependency issues" hint = "This is most likely due to https://github.com/openml/openml-python/issues/918. " # noqa: 501 elif isinstance(e, ValueError) and "unsupported pickle protocol" in e.args[0]: From b6bbede2295c100ce2c257d21a570467d28f8928 Mon Sep 17 00:00:00 2001 From: PGijsbers Date: Wed, 3 Nov 2021 14:23:33 +0100 Subject: [PATCH 2/3] Refer to PR for more info on AttributeError Additionally explained the reason of the error better in the original message. --- openml/datasets/dataset.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openml/datasets/dataset.py b/openml/datasets/dataset.py index 466cb0122..7039fcb9b 100644 --- a/openml/datasets/dataset.py +++ b/openml/datasets/dataset.py @@ -552,7 +552,15 @@ def _load_data(self): readable_error = "Detected a corrupt cache file" elif isinstance(e, (ModuleNotFoundError, AttributeError)): readable_error = "Detected likely dependency issues" - hint = "This is most likely due to https://github.com/openml/openml-python/issues/918. " # noqa: 501 + hint = ( + "This can happen if the cache was constructed with a different pandas version " + "than the one that is used to load the data. See also " + ) + if isinstance(e, ModuleNotFoundError): + hint += "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/openml/openml-python/issues/918. " + elif isinstance(e, AttributeError): + hint = "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/openml/openml-python/pull/1121. " + elif isinstance(e, ValueError) and "unsupported pickle protocol" in e.args[0]: readable_error = "Encountered unsupported pickle protocol" else: From 53af8e949979e8423a7a82e48d77f0f44d7a0afc Mon Sep 17 00:00:00 2001 From: PGijsbers Date: Wed, 3 Nov 2021 14:25:17 +0100 Subject: [PATCH 3/3] Add missing + for string concatenation --- openml/datasets/dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openml/datasets/dataset.py b/openml/datasets/dataset.py index 7039fcb9b..8f1ce612b 100644 --- a/openml/datasets/dataset.py +++ b/openml/datasets/dataset.py @@ -559,7 +559,7 @@ def _load_data(self): if isinstance(e, ModuleNotFoundError): hint += "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/openml/openml-python/issues/918. " elif isinstance(e, AttributeError): - hint = "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/openml/openml-python/pull/1121. " + hint += "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/openml/openml-python/pull/1121. " elif isinstance(e, ValueError) and "unsupported pickle protocol" in e.args[0]: readable_error = "Encountered unsupported pickle protocol"