Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/datasets/features/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def encode_np_array(array: np.ndarray) -> dict:


def objects_to_list_of_image_dicts(
objs: Union[List[str], List[dict], List[np.ndarray], List["PIL.Image.Image"]]
objs: Union[List[str], List[dict], List[np.ndarray], List["PIL.Image.Image"]],
) -> List[dict]:
"""Encode a list of objects into a format suitable for creating an extension array of type `ImageExtensionType`."""
if config.PIL_AVAILABLE:
Expand Down
14 changes: 8 additions & 6 deletions src/datasets/utils/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from huggingface_hub import HfApi, hf_hub_url
from packaging import version
from requests import HTTPError
from requests import ConnectionError, HTTPError

from .. import config
from . import logging
Expand All @@ -18,15 +18,17 @@ def preupload_lfs_files(hf_api: HfApi, **kwargs):
max_retries = 5
base_wait_time = 1
max_wait_time = 8
status_codes = [500, 503]
retry = 0
while True:
try:
hf_api.preupload_lfs_files(**kwargs)
except (RuntimeError, HTTPError) as err:
if isinstance(err, RuntimeError) and isinstance(err.__cause__, HTTPError):
err = err.__cause__
if retry >= max_retries or err.response.status_code not in status_codes:
except (RuntimeError, HTTPError, ConnectionError) as err:
if isinstance(err, RuntimeError):
if isinstance(err.__cause__, (HTTPError, ConnectionError)):
err = err.__cause__
else:
raise err
if retry >= max_retries or err.response and err.response.status_code not in [500, 503]:
raise err
else:
sleep_time = min(max_wait_time, base_wait_time * 2**retry) # Exponential backoff
Expand Down