Skip to content

Commit

Permalink
Encode path only for old versions of hfh (huggingface#5237)
Browse files Browse the repository at this point in the history
encode path only for old versions of hfh
  • Loading branch information
lhoestq committed Nov 14, 2022
1 parent 9506301 commit 9e987a4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/datasets/utils/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
from urllib.parse import quote

import huggingface_hub as hfh
from packaging import version


def hf_hub_url(repo_id: str, path: str, revision: Optional[str] = None) -> str:
return hfh.hf_hub_url(repo_id, quote(path), repo_type="dataset", revision=revision)
if version.parse(hfh.__version__) < version.parse("0.11.0"):
# old versions of hfh don't url-encode the file path
path = quote(path)
return hfh.hf_hub_url(repo_id, path, repo_type="dataset", revision=revision)

0 comments on commit 9e987a4

Please sign in to comment.