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

Allow deleting a subset/config from a no-script dataset #6820

Merged
merged 15 commits into from
Apr 30, 2024
Merged

Conversation

albertvillanova
Copy link
Member

@albertvillanova albertvillanova commented Apr 17, 2024

TODO:

Close #6810.

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

@albertvillanova albertvillanova marked this pull request as ready for review April 19, 2024 11:01
@albertvillanova
Copy link
Member Author

This is ready for review, @huggingface/datasets.

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.

Nice ! Maybe add a simple test ?

operations = []
# data_files
fs = HfFileSystem(endpoint=config.HF_ENDPOINT, token=token)
builder = load_dataset_builder(repo_id, config_name, revision=revision, token=token)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe disallow builders from a script ? you can check if the builder module starts with "datasets." for example

Copy link
Member Author

Choose a reason for hiding this comment

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

I have just passed trust_remote_code=False. Does it seems OK to you?

fs = HfFileSystem(endpoint=config.HF_ENDPOINT, token=token)
builder = load_dataset_builder(repo_id, config_name, revision=revision, token=token)
for data_file in chain(*builder.config.data_files.values()):
operations.append(CommitOperationDelete(path_in_repo=fs.resolve_path(data_file).path_in_repo))
Copy link
Member

Choose a reason for hiding this comment

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

(nit) maybe add a sanity check to make sure it's a file in the same repo (in case someone defines a dataset with data_files urls from another repo)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@albertvillanova
Copy link
Member Author

I am adding a test...

@albertvillanova
Copy link
Member Author

@lhoestq I am getting an error in the test and I think it happens because the CI endpoint does not have the /preupload functionality:

huggingface_hub.utils._errors.RepositoryNotFoundError: 401 Client Error. (Request ID: Root=1-662a4de9-7134df595e29e4c073ac1298;332ff6e3-597a-4dfc-89df-4e9ac64215ad)

Repository Not Found for url: https://hub-ci.huggingface.co/api/datasets/__DUMMY_TRANSFORMERS_USER__/test-dataset-6c54e2-17140484441915/preupload/main?create_pr=1.
Please make sure you specified the correct `repo_id` and `repo_type`.
If you are trying to access a private or gated repo, make sure you are authenticated.
Invalid username or password.
Note: Creating a commit assumes that the repo already exists on the Huggingface Hub. Please use `create_repo` if it's not the case.

@albertvillanova
Copy link
Member Author

@lhoestq, finally, I implemented the test with a mock of the call to HfApi.create_commit.

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 !

@albertvillanova albertvillanova merged commit ceb25e1 into main Apr 30, 2024
12 checks passed
@albertvillanova albertvillanova deleted the fix-6810 branch April 30, 2024 09:44
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.004958 / 0.011353 (-0.006395) 0.004065 / 0.011008 (-0.006943) 0.063499 / 0.038508 (0.024991) 0.030260 / 0.023109 (0.007151) 0.250910 / 0.275898 (-0.024988) 0.276632 / 0.323480 (-0.046848) 0.004038 / 0.007986 (-0.003948) 0.002721 / 0.004328 (-0.001608) 0.049098 / 0.004250 (0.044848) 0.044418 / 0.037052 (0.007366) 0.262189 / 0.258489 (0.003700) 0.292426 / 0.293841 (-0.001415) 0.027268 / 0.128546 (-0.101279) 0.010601 / 0.075646 (-0.065045) 0.207332 / 0.419271 (-0.211940) 0.036102 / 0.043533 (-0.007430) 0.252425 / 0.255139 (-0.002714) 0.269421 / 0.283200 (-0.013779) 0.018534 / 0.141683 (-0.123149) 1.127869 / 1.452155 (-0.324286) 1.179660 / 1.492716 (-0.313056)

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.092686 / 0.018006 (0.074680) 0.299492 / 0.000490 (0.299002) 0.000211 / 0.000200 (0.000011) 0.000044 / 0.000054 (-0.000010)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.018385 / 0.037411 (-0.019026) 0.060979 / 0.014526 (0.046453) 0.073351 / 0.176557 (-0.103205) 0.120145 / 0.737135 (-0.616990) 0.073653 / 0.296338 (-0.222686)

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.286175 / 0.215209 (0.070966) 2.792698 / 2.077655 (0.715043) 1.507442 / 1.504120 (0.003322) 1.392531 / 1.541195 (-0.148664) 1.387253 / 1.468490 (-0.081237) 0.568435 / 4.584777 (-4.016342) 2.387392 / 3.745712 (-1.358321) 2.813695 / 5.269862 (-2.456167) 1.747392 / 4.565676 (-2.818284) 0.062948 / 0.424275 (-0.361328) 0.005596 / 0.007607 (-0.002011) 0.334357 / 0.226044 (0.108313) 3.263289 / 2.268929 (0.994360) 1.829553 / 55.444624 (-53.615071) 1.552510 / 6.876477 (-5.323967) 1.579975 / 2.142072 (-0.562098) 0.633982 / 4.805227 (-4.171246) 0.118752 / 6.500664 (-6.381912) 0.042445 / 0.075469 (-0.033024)

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.988062 / 1.841788 (-0.853725) 11.615693 / 8.074308 (3.541385) 9.728103 / 10.191392 (-0.463289) 0.131561 / 0.680424 (-0.548862) 0.015330 / 0.534201 (-0.518871) 0.289617 / 0.579283 (-0.289666) 0.265717 / 0.434364 (-0.168646) 0.323974 / 0.540337 (-0.216363) 0.419523 / 1.386936 (-0.967413)
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.005385 / 0.011353 (-0.005968) 0.003753 / 0.011008 (-0.007255) 0.049821 / 0.038508 (0.011313) 0.030490 / 0.023109 (0.007381) 0.260550 / 0.275898 (-0.015348) 0.284598 / 0.323480 (-0.038881) 0.004165 / 0.007986 (-0.003821) 0.002741 / 0.004328 (-0.001588) 0.048567 / 0.004250 (0.044317) 0.045185 / 0.037052 (0.008133) 0.273164 / 0.258489 (0.014674) 0.301995 / 0.293841 (0.008155) 0.028802 / 0.128546 (-0.099744) 0.010539 / 0.075646 (-0.065108) 0.057967 / 0.419271 (-0.361305) 0.032826 / 0.043533 (-0.010706) 0.260425 / 0.255139 (0.005286) 0.280175 / 0.283200 (-0.003024) 0.017202 / 0.141683 (-0.124481) 1.129588 / 1.452155 (-0.322567) 1.199565 / 1.492716 (-0.293152)

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.091234 / 0.018006 (0.073228) 0.299313 / 0.000490 (0.298824) 0.000203 / 0.000200 (0.000003) 0.000044 / 0.000054 (-0.000010)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.022519 / 0.037411 (-0.014892) 0.075915 / 0.014526 (0.061389) 0.088636 / 0.176557 (-0.087920) 0.128234 / 0.737135 (-0.608902) 0.089782 / 0.296338 (-0.206556)

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.291936 / 0.215209 (0.076727) 2.864589 / 2.077655 (0.786935) 1.575649 / 1.504120 (0.071529) 1.452797 / 1.541195 (-0.088398) 1.476245 / 1.468490 (0.007754) 0.593972 / 4.584777 (-3.990804) 0.962315 / 3.745712 (-2.783397) 2.836496 / 5.269862 (-2.433366) 1.758639 / 4.565676 (-2.807038) 0.064842 / 0.424275 (-0.359433) 0.005076 / 0.007607 (-0.002531) 0.342568 / 0.226044 (0.116524) 3.392753 / 2.268929 (1.123825) 1.908305 / 55.444624 (-53.536319) 1.632140 / 6.876477 (-5.244337) 1.653048 / 2.142072 (-0.489024) 0.662068 / 4.805227 (-4.143159) 0.118326 / 6.500664 (-6.382338) 0.041222 / 0.075469 (-0.034247)

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.005119 / 1.841788 (-0.836669) 12.250922 / 8.074308 (4.176614) 9.775600 / 10.191392 (-0.415792) 0.146230 / 0.680424 (-0.534194) 0.015883 / 0.534201 (-0.518318) 0.290807 / 0.579283 (-0.288476) 0.126002 / 0.434364 (-0.308362) 0.392332 / 0.540337 (-0.148005) 0.435513 / 1.386936 (-0.951423)

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.

Allow deleting a subset/config from a no-script dataset
3 participants