Skip to content

Commit

Permalink
encode path only for old versions of hfh
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoestq committed Nov 14, 2022
1 parent 1b81805 commit 67a6122
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)

1 comment on commit 67a6122

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show benchmarks

PyArrow==6.0.0

Show updated benchmarks!

Benchmark: benchmark_array_xd.json

metric read_batch_formatted_as_numpy after write_array2d read_batch_formatted_as_numpy after write_flattened_sequence read_batch_formatted_as_numpy after write_nested_sequence read_batch_unformated after write_array2d read_batch_unformated after write_flattened_sequence read_batch_unformated after write_nested_sequence read_col_formatted_as_numpy after write_array2d read_col_formatted_as_numpy after write_flattened_sequence read_col_formatted_as_numpy after write_nested_sequence read_col_unformated after write_array2d read_col_unformated after write_flattened_sequence read_col_unformated after write_nested_sequence read_formatted_as_numpy after write_array2d read_formatted_as_numpy after write_flattened_sequence read_formatted_as_numpy after write_nested_sequence read_unformated after write_array2d read_unformated after write_flattened_sequence read_unformated after write_nested_sequence write_array2d write_flattened_sequence write_nested_sequence
new / old (diff) 0.008374 / 0.011353 (-0.002979) 0.004546 / 0.011008 (-0.006462) 0.097679 / 0.038508 (0.059171) 0.029663 / 0.023109 (0.006554) 0.297935 / 0.275898 (0.022037) 0.353497 / 0.323480 (0.030017) 0.006675 / 0.007986 (-0.001310) 0.003295 / 0.004328 (-0.001034) 0.075300 / 0.004250 (0.071050) 0.036546 / 0.037052 (-0.000506) 0.313969 / 0.258489 (0.055480) 0.341430 / 0.293841 (0.047589) 0.036654 / 0.128546 (-0.091892) 0.014394 / 0.075646 (-0.061253) 0.325820 / 0.419271 (-0.093452) 0.043363 / 0.043533 (-0.000170) 0.306629 / 0.255139 (0.051490) 0.326906 / 0.283200 (0.043707) 0.086237 / 0.141683 (-0.055446) 1.547905 / 1.452155 (0.095750) 1.546489 / 1.492716 (0.053772)

Benchmark: benchmark_getitem_100B.json

metric get_batch_of_1024_random_rows get_batch_of_1024_rows get_first_row get_last_row
new / old (diff) 0.185583 / 0.018006 (0.167576) 0.407199 / 0.000490 (0.406710) 0.000847 / 0.000200 (0.000647) 0.000075 / 0.000054 (0.000020)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.023185 / 0.037411 (-0.014226) 0.095255 / 0.014526 (0.080729) 0.103936 / 0.176557 (-0.072620) 0.139807 / 0.737135 (-0.597328) 0.108107 / 0.296338 (-0.188231)

Benchmark: benchmark_iterating.json

metric read 5000 read 50000 read_batch 50000 10 read_batch 50000 100 read_batch 50000 1000 read_formatted numpy 5000 read_formatted pandas 5000 read_formatted tensorflow 5000 read_formatted torch 5000 read_formatted_batch numpy 5000 10 read_formatted_batch numpy 5000 1000 shuffled read 5000 shuffled read 50000 shuffled read_batch 50000 10 shuffled read_batch 50000 100 shuffled read_batch 50000 1000 shuffled read_formatted numpy 5000 shuffled read_formatted_batch numpy 5000 10 shuffled read_formatted_batch numpy 5000 1000
new / old (diff) 0.408756 / 0.215209 (0.193547) 4.092558 / 2.077655 (2.014903) 1.826316 / 1.504120 (0.322197) 1.628059 / 1.541195 (0.086864) 1.649430 / 1.468490 (0.180940) 0.689313 / 4.584777 (-3.895464) 3.373653 / 3.745712 (-0.372059) 2.816555 / 5.269862 (-2.453306) 1.530290 / 4.565676 (-3.035386) 0.080850 / 0.424275 (-0.343425) 0.011647 / 0.007607 (0.004040) 0.523804 / 0.226044 (0.297760) 5.245398 / 2.268929 (2.976469) 2.292593 / 55.444624 (-53.152031) 1.947861 / 6.876477 (-4.928616) 1.997843 / 2.142072 (-0.144229) 0.809626 / 4.805227 (-3.995601) 0.147745 / 6.500664 (-6.352920) 0.063471 / 0.075469 (-0.011998)

Benchmark: benchmark_map_filter.json

metric filter map fast-tokenizer batched map identity map identity batched map no-op batched map no-op batched numpy map no-op batched pandas map no-op batched pytorch map no-op batched tensorflow
new / old (diff) 1.592486 / 1.841788 (-0.249302) 12.313165 / 8.074308 (4.238857) 26.256547 / 10.191392 (16.065155) 0.884322 / 0.680424 (0.203898) 0.636316 / 0.534201 (0.102115) 0.390399 / 0.579283 (-0.188884) 0.397235 / 0.434364 (-0.037129) 0.241476 / 0.540337 (-0.298861) 0.237932 / 1.386936 (-1.149004)
PyArrow==latest
Show updated benchmarks!

Benchmark: benchmark_array_xd.json

metric read_batch_formatted_as_numpy after write_array2d read_batch_formatted_as_numpy after write_flattened_sequence read_batch_formatted_as_numpy after write_nested_sequence read_batch_unformated after write_array2d read_batch_unformated after write_flattened_sequence read_batch_unformated after write_nested_sequence read_col_formatted_as_numpy after write_array2d read_col_formatted_as_numpy after write_flattened_sequence read_col_formatted_as_numpy after write_nested_sequence read_col_unformated after write_array2d read_col_unformated after write_flattened_sequence read_col_unformated after write_nested_sequence read_formatted_as_numpy after write_array2d read_formatted_as_numpy after write_flattened_sequence read_formatted_as_numpy after write_nested_sequence read_unformated after write_array2d read_unformated after write_flattened_sequence read_unformated after write_nested_sequence write_array2d write_flattened_sequence write_nested_sequence
new / old (diff) 0.006359 / 0.011353 (-0.004994) 0.004391 / 0.011008 (-0.006618) 0.096565 / 0.038508 (0.058057) 0.027347 / 0.023109 (0.004238) 0.342208 / 0.275898 (0.066310) 0.371862 / 0.323480 (0.048382) 0.004789 / 0.007986 (-0.003196) 0.003288 / 0.004328 (-0.001040) 0.075259 / 0.004250 (0.071008) 0.032632 / 0.037052 (-0.004420) 0.340752 / 0.258489 (0.082263) 0.384999 / 0.293841 (0.091158) 0.031357 / 0.128546 (-0.097189) 0.011676 / 0.075646 (-0.063970) 0.320126 / 0.419271 (-0.099146) 0.041148 / 0.043533 (-0.002385) 0.340047 / 0.255139 (0.084908) 0.369547 / 0.283200 (0.086348) 0.087834 / 0.141683 (-0.053849) 1.491778 / 1.452155 (0.039624) 1.556159 / 1.492716 (0.063442)

Benchmark: benchmark_getitem_100B.json

metric get_batch_of_1024_random_rows get_batch_of_1024_rows get_first_row get_last_row
new / old (diff) 0.235069 / 0.018006 (0.217062) 0.398623 / 0.000490 (0.398133) 0.003322 / 0.000200 (0.003122) 0.000077 / 0.000054 (0.000023)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.024726 / 0.037411 (-0.012686) 0.100074 / 0.014526 (0.085549) 0.106132 / 0.176557 (-0.070425) 0.141374 / 0.737135 (-0.595761) 0.110119 / 0.296338 (-0.186220)

Benchmark: benchmark_iterating.json

metric read 5000 read 50000 read_batch 50000 10 read_batch 50000 100 read_batch 50000 1000 read_formatted numpy 5000 read_formatted pandas 5000 read_formatted tensorflow 5000 read_formatted torch 5000 read_formatted_batch numpy 5000 10 read_formatted_batch numpy 5000 1000 shuffled read 5000 shuffled read 50000 shuffled read_batch 50000 10 shuffled read_batch 50000 100 shuffled read_batch 50000 1000 shuffled read_formatted numpy 5000 shuffled read_formatted_batch numpy 5000 10 shuffled read_formatted_batch numpy 5000 1000
new / old (diff) 0.443906 / 0.215209 (0.228697) 4.412797 / 2.077655 (2.335142) 2.122494 / 1.504120 (0.618374) 1.913379 / 1.541195 (0.372185) 1.948302 / 1.468490 (0.479812) 0.694037 / 4.584777 (-3.890740) 3.444567 / 3.745712 (-0.301145) 1.849532 / 5.269862 (-3.420329) 1.167746 / 4.565676 (-3.397931) 0.080971 / 0.424275 (-0.343304) 0.011843 / 0.007607 (0.004236) 0.548915 / 0.226044 (0.322870) 5.456905 / 2.268929 (3.187976) 2.575938 / 55.444624 (-52.868686) 2.231971 / 6.876477 (-4.644506) 2.216162 / 2.142072 (0.074089) 0.802677 / 4.805227 (-4.002550) 0.149181 / 6.500664 (-6.351483) 0.064341 / 0.075469 (-0.011128)

Benchmark: benchmark_map_filter.json

metric filter map fast-tokenizer batched map identity map identity batched map no-op batched map no-op batched numpy map no-op batched pandas map no-op batched pytorch map no-op batched tensorflow
new / old (diff) 1.581840 / 1.841788 (-0.259948) 12.496663 / 8.074308 (4.422355) 12.183235 / 10.191392 (1.991842) 0.916286 / 0.680424 (0.235862) 0.638011 / 0.534201 (0.103810) 0.370028 / 0.579283 (-0.209255) 0.376184 / 0.434364 (-0.058180) 0.224338 / 0.540337 (-0.316000) 0.231885 / 1.386936 (-1.155051)

Please sign in to comment.