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

Fix cache path to snakecase for CachedDatasetModuleFactory and Cache #6754

Merged
merged 8 commits into from
Apr 15, 2024

Conversation

izhx
Copy link
Contributor

@izhx izhx commented Mar 24, 2024

Fix #6750 (comment)

I didn't find a guideline on how to run the tests, so i just run the following steps to make sure that this bug is fixed.

  1. python test.py,
  2. then HF_DATASETS_OFFLINE=1 python test.py

The test.py is

  import datasets

  datasets.utils.logging.set_verbosity_info()

  ds = datasets.load_dataset('izhx/STS17-debug')
  print(ds)

  ds = datasets.load_dataset('C-MTEB/AFQMC', revision='b44c3b011063adb25877c13823db83bb193913c4')
  print(ds)

@izhx
Copy link
Contributor Author

izhx commented Mar 28, 2024

@lhoestq hi 😃, is there something else I need to do to check this change?

Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

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

Hi ! Thanks for the fix :) I added a comment

I also created https://huggingface.co/datasets/hf-internal-testing/DatasetWithCapitalLetters if you want to use it to add a test in test_cache.py (similar to test_cache_single_config for example)

src/datasets/load.py Outdated Show resolved Hide resolved
src/datasets/packaged_modules/cache/cache.py Outdated Show resolved Hide resolved
@izhx
Copy link
Contributor Author

izhx commented Mar 29, 2024

I added two tests and passed them on my server.

pytest tests/packaged_modules/test_cache.py 
========================================================================== test session starts ==========================================================================
platform linux -- Python 3.11.5, pytest-8.1.1, pluggy-1.4.0
rootdir: /mnt/nas/datasets
configfile: pyproject.toml
plugins: xdist-3.5.0, datadir-1.5.0
collected 8 items                                                                                                                                                       

tests/packaged_modules/test_cache.py ........                                                                                                                     [100%]

========================================================================== 8 passed in 50.71s ===========================================================================

pytest tests/test_load.py
========================================================================== test session starts ==========================================================================
platform linux -- Python 3.11.5, pytest-8.1.1, pluggy-1.4.0
rootdir: /mnt/nas/datasets
configfile: pyproject.toml
plugins: xdist-3.5.0, datadir-1.5.0
collected 151 items                                                                                                                                                     

tests/test_load.py .............................................................................................................................................. [ 94%]
.........                                                                                                                                                         [100%]

...

============================================================= 151 passed, 29 warnings in 578.36s (0:09:38) ==============================================================

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@minotru
Copy link

minotru commented Apr 2, 2024

Hi @izhx! I have also faced this issue, happy to see it already addressed, looking forward for PR merge :)

@izhx
Copy link
Contributor Author

izhx commented Apr 11, 2024

@lhoestq What do you think of these tests? 😀

Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

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

LGTM ! thanks :)

@lhoestq lhoestq merged commit 91b07b9 into huggingface:main Apr 15, 2024
12 checks passed
Copy link

Show benchmarks

PyArrow==8.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.005060 / 0.011353 (-0.006293) 0.003251 / 0.011008 (-0.007757) 0.063538 / 0.038508 (0.025030) 0.031178 / 0.023109 (0.008069) 0.249971 / 0.275898 (-0.025927) 0.284828 / 0.323480 (-0.038652) 0.004183 / 0.007986 (-0.003802) 0.002656 / 0.004328 (-0.001673) 0.049585 / 0.004250 (0.045335) 0.042656 / 0.037052 (0.005604) 0.270962 / 0.258489 (0.012473) 0.296091 / 0.293841 (0.002250) 0.028065 / 0.128546 (-0.100482) 0.010545 / 0.075646 (-0.065102) 0.207323 / 0.419271 (-0.211948) 0.035977 / 0.043533 (-0.007556) 0.257315 / 0.255139 (0.002176) 0.272238 / 0.283200 (-0.010962) 0.017984 / 0.141683 (-0.123699) 1.131314 / 1.452155 (-0.320840) 1.180259 / 1.492716 (-0.312457)

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.090977 / 0.018006 (0.072971) 0.284021 / 0.000490 (0.283531) 0.000264 / 0.000200 (0.000065) 0.000044 / 0.000054 (-0.000011)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.017852 / 0.037411 (-0.019559) 0.061288 / 0.014526 (0.046762) 0.073844 / 0.176557 (-0.102713) 0.121371 / 0.737135 (-0.615764) 0.075036 / 0.296338 (-0.221303)

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.287599 / 0.215209 (0.072390) 2.821172 / 2.077655 (0.743517) 1.459904 / 1.504120 (-0.044216) 1.340224 / 1.541195 (-0.200970) 1.357350 / 1.468490 (-0.111140) 0.557344 / 4.584777 (-4.027433) 2.412177 / 3.745712 (-1.333535) 2.745126 / 5.269862 (-2.524735) 1.754600 / 4.565676 (-2.811077) 0.062487 / 0.424275 (-0.361788) 0.005306 / 0.007607 (-0.002301) 0.338856 / 0.226044 (0.112811) 3.354953 / 2.268929 (1.086024) 1.803208 / 55.444624 (-53.641417) 1.553051 / 6.876477 (-5.323426) 1.554790 / 2.142072 (-0.587282) 0.651380 / 4.805227 (-4.153847) 0.117777 / 6.500664 (-6.382887) 0.041992 / 0.075469 (-0.033477)

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) 0.977588 / 1.841788 (-0.864200) 11.363058 / 8.074308 (3.288750) 9.791770 / 10.191392 (-0.399622) 0.130708 / 0.680424 (-0.549716) 0.013798 / 0.534201 (-0.520403) 0.288313 / 0.579283 (-0.290970) 0.268170 / 0.434364 (-0.166194) 0.324815 / 0.540337 (-0.215522) 0.419260 / 1.386936 (-0.967676)
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.005187 / 0.011353 (-0.006166) 0.003348 / 0.011008 (-0.007660) 0.050309 / 0.038508 (0.011801) 0.031334 / 0.023109 (0.008225) 0.279542 / 0.275898 (0.003644) 0.299608 / 0.323480 (-0.023872) 0.004202 / 0.007986 (-0.003784) 0.002735 / 0.004328 (-0.001593) 0.050321 / 0.004250 (0.046070) 0.039793 / 0.037052 (0.002740) 0.289972 / 0.258489 (0.031483) 0.313887 / 0.293841 (0.020046) 0.028797 / 0.128546 (-0.099750) 0.010166 / 0.075646 (-0.065480) 0.059228 / 0.419271 (-0.360044) 0.032667 / 0.043533 (-0.010866) 0.278409 / 0.255139 (0.023270) 0.292208 / 0.283200 (0.009008) 0.017577 / 0.141683 (-0.124106) 1.175046 / 1.452155 (-0.277109) 1.200766 / 1.492716 (-0.291950)

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.092236 / 0.018006 (0.074230) 0.298860 / 0.000490 (0.298370) 0.000211 / 0.000200 (0.000011) 0.000043 / 0.000054 (-0.000011)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.021475 / 0.037411 (-0.015936) 0.074414 / 0.014526 (0.059888) 0.087746 / 0.176557 (-0.088811) 0.124757 / 0.737135 (-0.612378) 0.088513 / 0.296338 (-0.207826)

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.296583 / 0.215209 (0.081374) 2.894978 / 2.077655 (0.817323) 1.590806 / 1.504120 (0.086686) 1.463251 / 1.541195 (-0.077944) 1.478751 / 1.468490 (0.010261) 0.571724 / 4.584777 (-4.013053) 2.454356 / 3.745712 (-1.291356) 2.789275 / 5.269862 (-2.480586) 1.753866 / 4.565676 (-2.811811) 0.064787 / 0.424275 (-0.359488) 0.005321 / 0.007607 (-0.002287) 0.348454 / 0.226044 (0.122410) 3.453052 / 2.268929 (1.184124) 1.972237 / 55.444624 (-53.472388) 1.677822 / 6.876477 (-5.198655) 1.674750 / 2.142072 (-0.467322) 0.649353 / 4.805227 (-4.155874) 0.117135 / 6.500664 (-6.383529) 0.040018 / 0.075469 (-0.035451)

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.029812 / 1.841788 (-0.811976) 11.945063 / 8.074308 (3.870755) 10.238380 / 10.191392 (0.046988) 0.146225 / 0.680424 (-0.534199) 0.015262 / 0.534201 (-0.518939) 0.286632 / 0.579283 (-0.292651) 0.272952 / 0.434364 (-0.161412) 0.323098 / 0.540337 (-0.217239) 0.423549 / 1.386936 (-0.963387)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

load_dataset requires a network connection for local download?
4 participants