Skip to content

Commit a6461e9

Browse files
akxlhoestq
andauthored
Remove aiohttp from direct dependencies (#7294)
* Remove `aiohttp` from direct dependencies It is only used for catching an exception from other code. * Update setup.py --------- Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>
1 parent 22f62f6 commit a6461e9

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

.github/conda/meta.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ requirements:
2626
- fsspec
2727
- huggingface_hub >=0.24.0,<1.0.0
2828
- packaging
29-
- aiohttp
3029
run:
3130
- python
3231
- pip
@@ -42,7 +41,6 @@ requirements:
4241
- fsspec
4342
- huggingface_hub >=0.24.0,<1.0.0
4443
- packaging
45-
- aiohttp
4644

4745
test:
4846
imports:

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@
128128
# to save datasets locally or on any filesystem
129129
# minimum 2023.1.0 to support protocol=kwargs in fsspec's `open`, `get_fs_token_paths`, etc.: see https://github.com/fsspec/filesystem_spec/pull/1143
130130
"fsspec[http]>=2023.1.0,<=2025.3.0",
131-
# for data streaming via http
132-
"aiohttp",
133131
# To get datasets from the Datasets Hub on huggingface.co
134132
"huggingface-hub>=0.24.0",
135133
# Utilities from PyPA to e.g., compare versions
@@ -164,6 +162,7 @@
164162
"pytest-datadir",
165163
"pytest-xdist",
166164
# optional dependencies
165+
"aiohttp",
167166
"elasticsearch>=7.17.12,<8.0.0", # 8.0 asks users to provide hosts or cloud_id when instantiating ElasticSearch(); 7.9.1 has legacy numpy.float_ which was fixed in https://github.com/elastic/elasticsearch-py/pull/2551.
168167
"faiss-cpu>=1.8.0.post1", # Pins numpy < 2
169168
"jax>=0.3.14; sys_platform != 'win32'",

src/datasets/utils/file_utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from urllib.parse import urlparse
2828
from xml.etree import ElementTree as ET
2929

30-
import aiohttp.client_exceptions
3130
import fsspec
3231
import huggingface_hub
3332
import huggingface_hub.errors
@@ -45,6 +44,15 @@
4544
from .extract import ExtractManager
4645
from .track import TrackedIterableFromGenerator
4746

47+
try:
48+
from aiohttp.client_exceptions import ClientError as _AiohttpClientError
49+
except ImportError:
50+
# aiohttp is not available; synthesize an exception type
51+
# that will never be raised by any actual code for use in the `except`
52+
# clause only.
53+
class _AiohttpClientError(Exception):
54+
pass
55+
4856

4957
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
5058

@@ -818,7 +826,7 @@ def read_with_retries(*args, **kwargs):
818826
out = read(*args, **kwargs)
819827
break
820828
except (
821-
aiohttp.client_exceptions.ClientError,
829+
_AiohttpClientError,
822830
asyncio.TimeoutError,
823831
requests.exceptions.ConnectionError,
824832
requests.exceptions.Timeout,

0 commit comments

Comments
 (0)