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

Finish deprecating the fs argument #5393

Merged
merged 9 commits into from Jan 18, 2023

Conversation

dconathan
Copy link
Contributor

See #5385 for some discussion on this

The fs= arg was depcrecated from Dataset.save_to_disk and Dataset.load_from_disk in 2.8.0 (to be removed in 3.0.0). There are a few other places where the fs= arg was still used (functions/methods in datasets.info and datasets.load). This PR adds a similar behavior, warnings and the storage_options= arg to these functions and methods.

One question: should the "deprecated" / "added" versions be 2.8.1 for the docs/warnings on these? Right now I'm going with "fs was deprecated in 2.8.0" but "storage_options= was added in 2.8.1" where appropriate.

@mariosasko

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Dec 29, 2022

The documentation is not available anymore as the PR was closed or merged.

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 for the deprecation. Some minor suggested fixes below...

Also note that the corresponding tests should be updated as well.

src/datasets/info.py Show resolved Hide resolved
src/datasets/info.py Outdated Show resolved Hide resolved
src/datasets/info.py Outdated Show resolved Hide resolved
src/datasets/info.py Outdated Show resolved Hide resolved
src/datasets/info.py Outdated Show resolved Hide resolved
src/datasets/load.py Outdated Show resolved Hide resolved
src/datasets/load.py Outdated Show resolved Hide resolved
src/datasets/load.py Outdated Show resolved Hide resolved
src/datasets/load.py Outdated Show resolved Hide resolved
src/datasets/load.py Outdated Show resolved Hide resolved
dconathan and others added 2 commits December 29, 2022 08:55
Co-authored-by: Albert Villanova del Moral <8515462+albertvillanova@users.noreply.github.com>
@dconathan
Copy link
Contributor Author

Thanks for the deprecation. Some minor suggested fixes below...

Also note that the corresponding tests should be updated as well.

Thanks for the suggestions/typo fixes. I updated the failing test - passing locally now

@lhoestq
Copy link
Member

lhoestq commented Jan 5, 2023

Nice thanks !

I believe you also need to update _load_info and _save_info in builder.py - they're still passing fs=self._fs instead of storage_options=self._fs.storage_options

This should remove the remaining warnings in the CI such as

tests/test_builder.py::test_builder_with_filesystem_download_and_prepare_reload
tests/test_load.py::test_load_dataset_local[False]
tests/test_load.py::test_load_dataset_local[True]
tests/test_load.py::test_load_dataset_zip_csv[csv_path-False]
tests/test_load.py::test_load_dataset_then_move_then_reload
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/site-packages/datasets/info.py:344: FutureWarning: 'fs' was deprecated in favor of 'storage_options' in version 2.9.0 and will be removed in 3.0.0.
  You can remove this warning by passing 'storage_options=fs.storage_options' instead.

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 again for all the work, @dconathan.

I agree with @lhoestq that we should better address all remaining fs deprecation warnings with this PR.

For example, there are still some deprecation warnings when calling Dataset.load_from_disk with fs. See:

return Dataset.load_from_disk(dataset_path, fs, keep_in_memory=keep_in_memory)

or DatasetDict.load_from_disk with fs. See:

return DatasetDict.load_from_disk(dataset_path, fs, keep_in_memory=keep_in_memory)

These docstrings should also be updated:

>>> dataset = load_from_disk('s3://my-private-datasets/imdb/train', fs=s3) # doctest: +SKIP

>>> dataset.save_to_disk('s3://my-private-datasets/imdb/train', fs=s3) # doctest: +SKIP

@albertvillanova albertvillanova changed the title Finish Deprecating the fs= arg Finish deprecating the fs argument Jan 10, 2023
@dconathan
Copy link
Contributor Author

re: docstring, I assume passing in storage_options=s3.storage_options is correct/necessary to pass the secrets?

@dconathan
Copy link
Contributor Author

dconathan commented Jan 14, 2023

what about

def is_remote_filesystem(fs: fsspec.AbstractFileSystem) -> bool:
"""
Validates if filesystem has remote protocol.
Args:
fs (`fsspec.spec.AbstractFileSystem`):
An abstract super-class for pythonic file-systems, e.g. `fsspec.filesystem(\'file\')` or [`datasets.filesystems.S3FileSystem`].
"""
if fs is not None and fs.protocol != "file":
return True
else:
return False

leave as is? Is this function no longer necessary?

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 again for all your work on this PR, @dconathan.

I think the function is_remote_filesystem should be kept as it is.

We are going to re-run the CI. Once all green, we can merge.

@albertvillanova albertvillanova merged commit 8d20684 into huggingface:main Jan 18, 2023
@github-actions
Copy link

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.008877 / 0.011353 (-0.002475) 0.004725 / 0.011008 (-0.006283) 0.100738 / 0.038508 (0.062230) 0.030251 / 0.023109 (0.007141) 0.301483 / 0.275898 (0.025585) 0.374161 / 0.323480 (0.050681) 0.007225 / 0.007986 (-0.000761) 0.003654 / 0.004328 (-0.000674) 0.078400 / 0.004250 (0.074149) 0.035786 / 0.037052 (-0.001267) 0.309744 / 0.258489 (0.051255) 0.355834 / 0.293841 (0.061994) 0.034344 / 0.128546 (-0.094202) 0.011584 / 0.075646 (-0.064062) 0.321462 / 0.419271 (-0.097810) 0.041201 / 0.043533 (-0.002332) 0.298808 / 0.255139 (0.043669) 0.332626 / 0.283200 (0.049426) 0.089131 / 0.141683 (-0.052552) 1.477888 / 1.452155 (0.025734) 1.530365 / 1.492716 (0.037649)

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.191647 / 0.018006 (0.173640) 0.424339 / 0.000490 (0.423849) 0.002941 / 0.000200 (0.002741) 0.000075 / 0.000054 (0.000020)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.023442 / 0.037411 (-0.013969) 0.097264 / 0.014526 (0.082738) 0.105655 / 0.176557 (-0.070901) 0.145055 / 0.737135 (-0.592081) 0.108750 / 0.296338 (-0.187588)

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.422925 / 0.215209 (0.207716) 4.216022 / 2.077655 (2.138367) 1.876441 / 1.504120 (0.372322) 1.665115 / 1.541195 (0.123920) 1.711105 / 1.468490 (0.242615) 0.701820 / 4.584777 (-3.882957) 3.389319 / 3.745712 (-0.356393) 1.909868 / 5.269862 (-3.359994) 1.270482 / 4.565676 (-3.295195) 0.083680 / 0.424275 (-0.340595) 0.012347 / 0.007607 (0.004740) 0.531076 / 0.226044 (0.305031) 5.344045 / 2.268929 (3.075117) 2.310897 / 55.444624 (-53.133728) 1.971953 / 6.876477 (-4.904524) 2.113748 / 2.142072 (-0.028325) 0.823766 / 4.805227 (-3.981462) 0.150864 / 6.500664 (-6.349800) 0.066263 / 0.075469 (-0.009206)

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.253190 / 1.841788 (-0.588598) 13.757887 / 8.074308 (5.683579) 13.888195 / 10.191392 (3.696803) 0.137285 / 0.680424 (-0.543139) 0.029151 / 0.534201 (-0.505050) 0.387402 / 0.579283 (-0.191881) 0.401673 / 0.434364 (-0.032691) 0.450474 / 0.540337 (-0.089863) 0.533757 / 1.386936 (-0.853179)
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.006919 / 0.011353 (-0.004434) 0.004655 / 0.011008 (-0.006353) 0.096946 / 0.038508 (0.058438) 0.028697 / 0.023109 (0.005588) 0.420020 / 0.275898 (0.144122) 0.460193 / 0.323480 (0.136713) 0.005189 / 0.007986 (-0.002796) 0.003425 / 0.004328 (-0.000904) 0.074900 / 0.004250 (0.070649) 0.041844 / 0.037052 (0.004792) 0.421538 / 0.258489 (0.163049) 0.468497 / 0.293841 (0.174656) 0.032573 / 0.128546 (-0.095973) 0.011731 / 0.075646 (-0.063916) 0.320221 / 0.419271 (-0.099050) 0.042113 / 0.043533 (-0.001420) 0.422757 / 0.255139 (0.167618) 0.445372 / 0.283200 (0.162172) 0.090300 / 0.141683 (-0.051383) 1.458598 / 1.452155 (0.006443) 1.550060 / 1.492716 (0.057344)

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.235489 / 0.018006 (0.217483) 0.418207 / 0.000490 (0.417718) 0.002511 / 0.000200 (0.002311) 0.000080 / 0.000054 (0.000025)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.025603 / 0.037411 (-0.011808) 0.100237 / 0.014526 (0.085711) 0.108617 / 0.176557 (-0.067939) 0.148417 / 0.737135 (-0.588719) 0.110163 / 0.296338 (-0.186176)

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.474804 / 0.215209 (0.259595) 4.745370 / 2.077655 (2.667715) 2.417819 / 1.504120 (0.913699) 2.209892 / 1.541195 (0.668697) 2.263296 / 1.468490 (0.794806) 0.695537 / 4.584777 (-3.889240) 3.381028 / 3.745712 (-0.364684) 2.952271 / 5.269862 (-2.317591) 1.507041 / 4.565676 (-3.058636) 0.083334 / 0.424275 (-0.340941) 0.012554 / 0.007607 (0.004947) 0.578861 / 0.226044 (0.352817) 5.795241 / 2.268929 (3.526313) 2.858544 / 55.444624 (-52.586080) 2.516270 / 6.876477 (-4.360207) 2.557350 / 2.142072 (0.415278) 0.801799 / 4.805227 (-4.003428) 0.151579 / 6.500664 (-6.349085) 0.068765 / 0.075469 (-0.006704)

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.279935 / 1.841788 (-0.561853) 14.049065 / 8.074308 (5.974757) 13.972703 / 10.191392 (3.781311) 0.140551 / 0.680424 (-0.539873) 0.016831 / 0.534201 (-0.517370) 0.383886 / 0.579283 (-0.195397) 0.385661 / 0.434364 (-0.048703) 0.444525 / 0.540337 (-0.095813) 0.532197 / 1.386936 (-0.854739)

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.

None yet

4 participants