Skip to content

Commit

Permalink
Remove deprecated HfFolder (#6512)
Browse files Browse the repository at this point in the history
* remove deprecated HfFolder

* use build_hf_headers

* remove HfFolder completely
  • Loading branch information
lhoestq authored Dec 19, 2023
1 parent 3f699ab commit a91582d
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/datasets/utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import requests
from fsspec.core import strip_protocol
from fsspec.utils import can_be_local
from huggingface_hub import HfFolder
from huggingface_hub.utils import insecure_hashlib
from packaging import version

Expand Down Expand Up @@ -253,18 +252,12 @@ def get_authentication_headers_for_url(
FutureWarning,
)
token = use_auth_token
headers = {}
if url.startswith(config.HF_ENDPOINT):
if token is False:
token = None
elif isinstance(token, str):
token = token
else:
token = HfFolder.get_token()

if token:
headers["authorization"] = f"Bearer {token}"
return headers
return huggingface_hub.utils.build_hf_headers(
token=token, library_name="datasets", library_version=__version__
)
else:
return {}


class OfflineModeIsEnabled(ConnectionError):
Expand Down

0 comments on commit a91582d

Please sign in to comment.