Skip to content

Commit 67a6122

Browse files
committed
encode path only for old versions of hfh
1 parent 1b81805 commit 67a6122

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/datasets/utils/hub.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
from urllib.parse import quote
33

44
import huggingface_hub as hfh
5+
from packaging import version
56

67

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

0 commit comments

Comments
 (0)