From 05647c5d40d83fca3bede8d052b06404aaac5d5e Mon Sep 17 00:00:00 2001 From: elronbandel Date: Tue, 18 Feb 2025 12:08:20 +0200 Subject: [PATCH 1/2] Allow read timeout error in preparation tests Signed-off-by: elronbandel --- tests/catalog/test_preparation.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/catalog/test_preparation.py b/tests/catalog/test_preparation.py index 0289ec1e45..37f79f062b 100644 --- a/tests/catalog/test_preparation.py +++ b/tests/catalog/test_preparation.py @@ -76,7 +76,18 @@ def test_preparations(self): ) continue self.assertTrue(False) - raise + raise e + except Exception as e: + current_exception = e + import requests + while current_exception: + if isinstance(current_exception, requests.exceptions.ReadTimeout): + logger.error(f"ReadTimeout occurred in {file}") + break + current_exception = current_exception.__cause__ or current_exception.__context__ + else: + raise e + logger.info(f"Testing preparation file: {file} passed") self.assertTrue(True) From ab96ee24d6c75362a78df67538f8028b397aff2d Mon Sep 17 00:00:00 2001 From: elronbandel Date: Tue, 18 Feb 2025 12:13:39 +0200 Subject: [PATCH 2/2] Handle additional connection errors in preparation tests Signed-off-by: elronbandel --- tests/catalog/test_preparation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/catalog/test_preparation.py b/tests/catalog/test_preparation.py index 37f79f062b..3867ec76a9 100644 --- a/tests/catalog/test_preparation.py +++ b/tests/catalog/test_preparation.py @@ -4,7 +4,7 @@ import tracemalloc import psutil -from huggingface_hub.utils import GatedRepoError +from huggingface_hub.errors import GatedRepoError, HfHubHTTPError from unitxt.loaders import MissingKaggleCredentialsError from unitxt.logging_utils import get_logger from unitxt.settings_utils import get_constants, get_settings @@ -81,8 +81,8 @@ def test_preparations(self): current_exception = e import requests while current_exception: - if isinstance(current_exception, requests.exceptions.ReadTimeout): - logger.error(f"ReadTimeout occurred in {file}") + if isinstance(current_exception, (requests.exceptions.ReadTimeout, HfHubHTTPError)): + logger.error(f"Connection error occurred in {file}. Error: {e}.") break current_exception = current_exception.__cause__ or current_exception.__context__ else: