Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove ignore_url_params #624

Merged
merged 2 commits into from
Sep 11, 2024
Merged
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
14 changes: 3 additions & 11 deletions src/evaluate/utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from hashlib import sha256
from pathlib import Path
from typing import List, Optional, Type, TypeVar, Union
from urllib.parse import urljoin, urlparse
from urllib.parse import urlparse

import requests
from datasets import DownloadConfig
Expand Down Expand Up @@ -183,7 +183,6 @@ def cached_path(
use_etag=download_config.use_etag,
max_retries=download_config.max_retries,
token=download_config.token,
ignore_url_params=download_config.ignore_url_params,
download_desc=download_config.download_desc,
)
elif os.path.exists(url_or_filename):
Expand Down Expand Up @@ -409,7 +408,6 @@ def get_from_cache(
use_etag=True,
max_retries=0,
token=None,
ignore_url_params=False,
download_desc=None,
) -> str:
"""
Expand All @@ -432,12 +430,6 @@ def get_from_cache(

os.makedirs(cache_dir, exist_ok=True)

if ignore_url_params:
# strip all query parameters and #fragments from the URL
cached_url = urljoin(url, urlparse(url).path)
else:
cached_url = url # additional parameters may be added to the given URL

connected = False
response = None
cookies = None
Expand All @@ -446,7 +438,7 @@ def get_from_cache(

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

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

# Try a second time
filename = hash_url_to_filename(cached_url, etag)
filename = hash_url_to_filename(url, etag)
cache_path = os.path.join(cache_dir, filename)

if os.path.exists(cache_path) and not force_download:
Expand Down
Loading