Skip to content

Commit 2a79e23

Browse files
committed
better error handling
1 parent f8448a7 commit 2a79e23

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/datasets/arrow_dataset.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
)
7171
from huggingface_hub.hf_api import HfHubHTTPError, RepoFile, RepositoryNotFoundError
7272
from multiprocess import Pool
73+
from requests import HTTPError
7374
from tqdm.contrib.concurrent import thread_map
7475

7576
from . import config
@@ -6005,9 +6006,17 @@ def get_new_dataset_card_data() -> tuple[str, str, Optional[str]]:
60056006
parent_commit=parent_commit,
60066007
)
60076008
except HfHubHTTPError as err:
6008-
if "Precondition Failed" in str(err):
6009+
if (
6010+
err.__context__
6011+
and isinstance(err.__context__, HTTPError)
6012+
and err.__context__.response.status_code in (412, 409)
6013+
):
6014+
# 412 is Precondition failed (parent_commit isn't satisfied)
6015+
# 409 is Conflict (another commit is in progress)
60096016
time.sleep(sleep_time)
6010-
logger.warning(f"Retry #{retry} for {repo_id}, {config_name}")
6017+
logger.info(
6018+
f"Retrying commit for {repo_id}, {config_name} ({retry}/n with status_code {err.__context__.response.status_code})"
6019+
)
60116020
continue
60126021
else:
60136022
raise

0 commit comments

Comments
 (0)