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

Better error handling in dataset_module_factory #6959

Merged
merged 3 commits into from
Jun 10, 2024

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Jun 7, 2024

cc @cakiki who reported it on slack (private link)

This PR updates how errors are handled in dataset_module_factory when the dataset_info cannot be accessed:

  1. Use multiple except ... as e instead of using isinstance(e, ...)
  2. Always raise DatasetNotFoundError with from e so that the initial error is explicitly logged in the stacktrace.
  3. Differentiate RepoNotFoundError / GatedRepoError / RevisionNotFoundError cases

@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.

Copy link
Member

@albertvillanova albertvillanova left a comment

Choose a reason for hiding this comment

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

Thanks. Much clearer now.

Copy link
Member

@albertvillanova albertvillanova left a comment

Choose a reason for hiding this comment

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

Just a test needs being fixed because of the change in the error messages:

FAILED tests/test_load.py::LoadTest::test_load_dataset_from_hub - AssertionError: "at revision '0.0.0'" not found in "Dataset '_dummy' doesn't exist on the Hub or cannot be accessed."

@Wauplin
Copy link
Contributor Author

Wauplin commented Jun 7, 2024

Test should be fixed by ef8f7ce (tested locally). Let's see what CI says 🤞

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.

thanks !

raise ConnectionError(f"Couldn't reach '{path}' on the Hub ({e.__class__.__name__})") from e
except GatedRepoError as e:
raise DatasetNotFoundError(
f"Dataset '{path}' is a gated dataset on the Hub. Visit the dataset page at https://huggingface.co/datasets/{path} to ask for access."
Copy link
Member

Choose a reason for hiding this comment

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

maybe mention that the user may have to login ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in 62350f5

Copy link
Member

Choose a reason for hiding this comment

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

Thanks.

@Wauplin Wauplin merged commit 9510252 into main Jun 10, 2024
12 checks passed
@Wauplin Wauplin deleted the better-error-handling-in-dataset-module-factory branch June 10, 2024 07:27
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.005678 / 0.011353 (-0.005675) 0.004119 / 0.011008 (-0.006889) 0.063901 / 0.038508 (0.025393) 0.032071 / 0.023109 (0.008961) 0.243182 / 0.275898 (-0.032716) 0.280709 / 0.323480 (-0.042770) 0.004195 / 0.007986 (-0.003791) 0.002810 / 0.004328 (-0.001518) 0.048722 / 0.004250 (0.044472) 0.049381 / 0.037052 (0.012328) 0.257816 / 0.258489 (-0.000673) 0.288460 / 0.293841 (-0.005381) 0.028518 / 0.128546 (-0.100029) 0.010775 / 0.075646 (-0.064871) 0.203149 / 0.419271 (-0.216122) 0.038792 / 0.043533 (-0.004741) 0.248502 / 0.255139 (-0.006637) 0.268251 / 0.283200 (-0.014949) 0.019536 / 0.141683 (-0.122147) 1.133935 / 1.452155 (-0.318220) 1.182855 / 1.492716 (-0.309862)

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.097531 / 0.018006 (0.079525) 0.303612 / 0.000490 (0.303122) 0.000222 / 0.000200 (0.000022) 0.000044 / 0.000054 (-0.000011)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.019670 / 0.037411 (-0.017741) 0.063439 / 0.014526 (0.048913) 0.075119 / 0.176557 (-0.101438) 0.122419 / 0.737135 (-0.614717) 0.076965 / 0.296338 (-0.219374)

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.286780 / 0.215209 (0.071571) 2.811860 / 2.077655 (0.734206) 1.485165 / 1.504120 (-0.018954) 1.373296 / 1.541195 (-0.167898) 1.412700 / 1.468490 (-0.055790) 0.566442 / 4.584777 (-4.018335) 2.382616 / 3.745712 (-1.363096) 2.677214 / 5.269862 (-2.592647) 1.760073 / 4.565676 (-2.805603) 0.062673 / 0.424275 (-0.361602) 0.005050 / 0.007607 (-0.002557) 0.341701 / 0.226044 (0.115657) 3.321182 / 2.268929 (1.052253) 1.811715 / 55.444624 (-53.632909) 1.554986 / 6.876477 (-5.321491) 1.727448 / 2.142072 (-0.414624) 0.642193 / 4.805227 (-4.163034) 0.117878 / 6.500664 (-6.382786) 0.042814 / 0.075469 (-0.032655)

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.985894 / 1.841788 (-0.855894) 12.195975 / 8.074308 (4.121667) 9.890180 / 10.191392 (-0.301212) 0.142638 / 0.680424 (-0.537786) 0.015207 / 0.534201 (-0.518994) 0.283140 / 0.579283 (-0.296143) 0.266016 / 0.434364 (-0.168348) 0.325518 / 0.540337 (-0.214820) 0.418994 / 1.386936 (-0.967942)
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.005978 / 0.011353 (-0.005374) 0.003915 / 0.011008 (-0.007093) 0.051592 / 0.038508 (0.013084) 0.033338 / 0.023109 (0.010229) 0.267925 / 0.275898 (-0.007973) 0.296011 / 0.323480 (-0.027469) 0.004503 / 0.007986 (-0.003483) 0.002854 / 0.004328 (-0.001475) 0.049958 / 0.004250 (0.045707) 0.041708 / 0.037052 (0.004656) 0.287185 / 0.258489 (0.028696) 0.322715 / 0.293841 (0.028874) 0.030088 / 0.128546 (-0.098458) 0.010709 / 0.075646 (-0.064938) 0.059736 / 0.419271 (-0.359536) 0.034294 / 0.043533 (-0.009239) 0.264316 / 0.255139 (0.009177) 0.285471 / 0.283200 (0.002272) 0.019197 / 0.141683 (-0.122486) 1.135571 / 1.452155 (-0.316583) 1.190019 / 1.492716 (-0.302698)

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.099251 / 0.018006 (0.081245) 0.305357 / 0.000490 (0.304867) 0.000215 / 0.000200 (0.000015) 0.000045 / 0.000054 (-0.000010)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.023206 / 0.037411 (-0.014205) 0.077835 / 0.014526 (0.063310) 0.090242 / 0.176557 (-0.086315) 0.131208 / 0.737135 (-0.605928) 0.091726 / 0.296338 (-0.204612)

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.292487 / 0.215209 (0.077278) 2.837044 / 2.077655 (0.759389) 1.553155 / 1.504120 (0.049035) 1.433645 / 1.541195 (-0.107550) 1.476702 / 1.468490 (0.008212) 0.561926 / 4.584777 (-4.022851) 0.954630 / 3.745712 (-2.791082) 2.752286 / 5.269862 (-2.517575) 1.782746 / 4.565676 (-2.782931) 0.062984 / 0.424275 (-0.361291) 0.005056 / 0.007607 (-0.002551) 0.341700 / 0.226044 (0.115656) 3.343726 / 2.268929 (1.074798) 1.953390 / 55.444624 (-53.491234) 1.616989 / 6.876477 (-5.259488) 1.785104 / 2.142072 (-0.356969) 0.643465 / 4.805227 (-4.161763) 0.115905 / 6.500664 (-6.384759) 0.041678 / 0.075469 (-0.033791)

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.000237 / 1.841788 (-0.841550) 12.633517 / 8.074308 (4.559208) 10.553485 / 10.191392 (0.362092) 0.143188 / 0.680424 (-0.537236) 0.016020 / 0.534201 (-0.518181) 0.286739 / 0.579283 (-0.292544) 0.128488 / 0.434364 (-0.305876) 0.321932 / 0.540337 (-0.218405) 0.418635 / 1.386936 (-0.968301)

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.

4 participants