Skip to content

Commit 0565509

Browse files
authored
remove ignore_url_params (#624)
* remove ignore_url_params * style
1 parent db16a6e commit 0565509

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/evaluate/utils/file_utils.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from hashlib import sha256
2121
from pathlib import Path
2222
from typing import List, Optional, Type, TypeVar, Union
23-
from urllib.parse import urljoin, urlparse
23+
from urllib.parse import urlparse
2424

2525
import requests
2626
from datasets import DownloadConfig
@@ -183,7 +183,6 @@ def cached_path(
183183
use_etag=download_config.use_etag,
184184
max_retries=download_config.max_retries,
185185
token=download_config.token,
186-
ignore_url_params=download_config.ignore_url_params,
187186
download_desc=download_config.download_desc,
188187
)
189188
elif os.path.exists(url_or_filename):
@@ -409,7 +408,6 @@ def get_from_cache(
409408
use_etag=True,
410409
max_retries=0,
411410
token=None,
412-
ignore_url_params=False,
413411
download_desc=None,
414412
) -> str:
415413
"""
@@ -432,12 +430,6 @@ def get_from_cache(
432430

433431
os.makedirs(cache_dir, exist_ok=True)
434432

435-
if ignore_url_params:
436-
# strip all query parameters and #fragments from the URL
437-
cached_url = urljoin(url, urlparse(url).path)
438-
else:
439-
cached_url = url # additional parameters may be added to the given URL
440-
441433
connected = False
442434
response = None
443435
cookies = None
@@ -446,7 +438,7 @@ def get_from_cache(
446438

447439
# Try a first time to file the file on the local file system without eTag (None)
448440
# if we don't ask for 'force_download' then we spare a request
449-
filename = hash_url_to_filename(cached_url, etag=None)
441+
filename = hash_url_to_filename(url, etag=None)
450442
cache_path = os.path.join(cache_dir, filename)
451443

452444
if os.path.exists(cache_path) and not force_download and not use_etag:
@@ -526,7 +518,7 @@ def get_from_cache(
526518
raise ConnectionError(f"Couldn't reach {url}")
527519

528520
# Try a second time
529-
filename = hash_url_to_filename(cached_url, etag)
521+
filename = hash_url_to_filename(url, etag)
530522
cache_path = os.path.join(cache_dir, filename)
531523

532524
if os.path.exists(cache_path) and not force_download:

0 commit comments

Comments
 (0)