Skip to content

Commit 1ba974c

Browse files
authored
Allow read timeout error in preparation tests (#1615)
* Allow read timeout error in preparation tests Signed-off-by: elronbandel <[email protected]> * Handle additional connection errors in preparation tests Signed-off-by: elronbandel <[email protected]> --------- Signed-off-by: elronbandel <[email protected]>
1 parent 334b15a commit 1ba974c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/catalog/test_preparation.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import tracemalloc
55

66
import psutil
7-
from huggingface_hub.utils import GatedRepoError
7+
from huggingface_hub.errors import GatedRepoError, HfHubHTTPError
88
from unitxt.loaders import MissingKaggleCredentialsError
99
from unitxt.logging_utils import get_logger
1010
from unitxt.settings_utils import get_constants, get_settings
@@ -76,7 +76,18 @@ def test_preparations(self):
7676
)
7777
continue
7878
self.assertTrue(False)
79-
raise
79+
raise e
80+
except Exception as e:
81+
current_exception = e
82+
import requests
83+
while current_exception:
84+
if isinstance(current_exception, (requests.exceptions.ReadTimeout, HfHubHTTPError)):
85+
logger.error(f"Connection error occurred in {file}. Error: {e}.")
86+
break
87+
current_exception = current_exception.__cause__ or current_exception.__context__
88+
else:
89+
raise e
90+
8091
logger.info(f"Testing preparation file: {file} passed")
8192
self.assertTrue(True)
8293

0 commit comments

Comments
 (0)