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

[data] add validation for shuffle arg #47055

Merged
merged 4 commits into from
Aug 13, 2024

Conversation

matthewdeng
Copy link
Contributor

@matthewdeng matthewdeng commented Aug 10, 2024

Why are these changes needed?

Add validation for shuffle argument. Previously, specifying an incorrect argument would lead to the default behavior of None, which does is no shuffling.

Before:

>>> ray.data.read_parquet("/tmp/files", shuffle=True)
Dataset(num_rows=?, schema={})

After:

>>> ray.data.read_parquet("/tmp/files", shuffle=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/matt/workspace/ray/python/ray/data/read_api.py", line 768, in read_parquet
    datasource = ParquetDatasource(
                 ^^^^^^^^^^^^^^^^^^
  File "/Users/matt/workspace/ray/python/ray/data/_internal/datasource/parquet_datasource.py", line 284, in __init__
    _validate_shuffle_arg(shuffle)
  File "/Users/matt/workspace/ray/python/ray/data/datasource/file_based_datasource.py", line 527, in _validate_shuffle_arg
    raise ValueError(
ValueError: Invalid value for 'shuffle': True. Valid values are None, 'files'.

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

self._include_paths = include_paths

_validate_shuffle_arg(shuffle)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure what the best way to organize this was, I expected ParquetDatasource to extend FileBasedDatasource.

Copy link
Member

Choose a reason for hiding this comment

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

They have different code paths because ParquetDatasource leverages PyArrow's ParquetDataset

python/ray/data/_internal/datasource/parquet_datasource.py Outdated Show resolved Hide resolved
self._include_paths = include_paths

_validate_shuffle_arg(shuffle)
Copy link
Member

Choose a reason for hiding this comment

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

They have different code paths because ParquetDatasource leverages PyArrow's ParquetDataset

python/ray/data/tests/test_file_based_datasource.py Outdated Show resolved Hide resolved
python/ray/data/tests/test_file_based_datasource.py Outdated Show resolved Hide resolved
Signed-off-by: Matthew Deng <[email protected]>
Signed-off-by: Matthew Deng <[email protected]>
Signed-off-by: Matthew Deng <[email protected]>
@matthewdeng matthewdeng enabled auto-merge (squash) August 13, 2024 00:19
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Aug 13, 2024
@matthewdeng matthewdeng merged commit e2e4076 into ray-project:master Aug 13, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants