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

[Datasets] Handle any error code when encountering AWS S3 credential error #26669

Merged
merged 3 commits into from
Jul 19, 2022

Conversation

c21
Copy link
Contributor

@c21 c21 commented Jul 18, 2022

Why are these changes needed?

As a followup of #26619 (comment) and #26619 (comment), here we change from PermissionError to OSError, to be consistent as original error, and also change function name from _handle_read_s3_files_error to _handle_read_os_error, which is more general that we can handle other file systems such as GCS in the future.

Also change to hanlde any error message with pattern AWS Error [code xxx]: No response body as new issue with error code 100 is raised in #26672 .

Tested the example in #26672 and verified it shows new error message now:

>>> import ray
>>> ds = ray.data.read_parquet([
...     "s3://anonymous@ursa-labs-taxi-data/2009/01/data.parquet",
...     "s3://anonymous@ursa-labs-taxi-data/2009/02/data.parquet",
... ])

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/chengsu/ray/python/ray/data/read_api.py", line 365, in read_parquet
    return read_datasource(
  File "/Users/chengsu/ray/python/ray/data/read_api.py", line 267, in read_datasource
    requested_parallelism, min_safe_parallelism, read_tasks = ray.get(
  File "/Users/chengsu/ray/python/ray/_private/client_mode_hook.py", line 105, in wrapper
    return func(*args, **kwargs)
  File "/Users/chengsu/ray/python/ray/_private/worker.py", line 2196, in get
    raise value.as_instanceof_cause()
ray.exceptions.RayTaskError(OSError): ray::_get_read_tasks() (pid=37757, ip=127.0.0.1)
  File "/Users/chengsu/ray/python/ray/data/datasource/file_meta_provider.py", line 330, in prefetch_file_metadata
    return _fetch_metadata(pieces)
  File "/Users/chengsu/ray/python/ray/data/datasource/parquet_datasource.py", line 341, in _fetch_metadata
    piece_metadata.append(p.metadata)
  File "pyarrow/_dataset.pyx", line 1315, in pyarrow._dataset.ParquetFileFragment.metadata.__get__
  File "pyarrow/_dataset.pyx", line 1304, in pyarrow._dataset.ParquetFileFragment.ensure_complete_metadata
  File "pyarrow/error.pxi", line 114, in pyarrow.lib.check_status
OSError: When reading information for key '2009/02/data.parquet' in bucket 'anonymous@ursa-labs-taxi-data': AWS Error [code 100]: No response body.

During handling of the above exception, another exception occurred:

ray::_get_read_tasks() (pid=37757, ip=127.0.0.1)
  File "/Users/chengsu/ray/python/ray/data/read_api.py", line 1129, in _get_read_tasks
    reader = ds.create_reader(**kwargs)
  File "/Users/chengsu/ray/python/ray/data/datasource/parquet_datasource.py", line 142, in create_reader
    return _ParquetDatasourceReader(**kwargs)
  File "/Users/chengsu/ray/python/ray/data/datasource/parquet_datasource.py", line 197, in __init__
    _handle_read_os_error(e, paths)
  File "/Users/chengsu/ray/python/ray/data/datasource/file_meta_provider.py", line 345, in _handle_read_os_error
    raise OSError(
OSError: Failing to read AWS S3 file(s): ['ursa-labs-taxi-data/2009/01/data.parquet', 'anonymous@ursa-labs-taxi-data/2009/02/data.parquet']. Please check that file exists and has properly configured access. See https://docs.ray.io/en/latest/data/creating-datasets.html#reading-from-remote-storage for more information.

Related issue number

Closes #26672 .

Checks

  • 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 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 :(

@c21
Copy link
Contributor Author

c21 commented Jul 18, 2022

@matthewdeng - could you help take a look when you have time? Thanks.

Comment on lines +334 to +336
# Specially handle AWS error when reading files, to give a clearer error
# message to avoid confusing users. The real issue is most likely that the AWS
# S3 file credentials have not been properly configured yet.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just move the original comment literally without any change. Feel make more sense to comment inside the if branch, as we plan to extend the function to apply to other file system such as GCS in the future.

# Specially handle AWS error when reading files, to give a clearer error message
# to avoid confusing users. The real issue is most likely that the AWS S3 file
# credentials have not been properly configured yet.
def _handle_read_os_error(error: OSError, paths: Union[str, List[str]]) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a quick note to make it explicit that this is not comprehensive yet, and should be extended as more errors arise?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@matthewdeng - sure, added.

@c21
Copy link
Contributor Author

c21 commented Jul 18, 2022

@pcmoritz, @dmatrix - this should fix #26672, please let me know if the error message below is intuitive enough, thanks.

OSError: Failing to read AWS S3 file(s): ['ursa-labs-taxi-data/2009/01/data.parquet', 'anonymous@ursa-labs-taxi-data/2009/02/data.parquet']. 
Please check that file exists and has properly configured access.
See https://docs.ray.io/en/latest/data/creating-datasets.html#reading-from-remote-storage for more information.

@c21 c21 changed the title [Datasets] Refine error type and function name for handling S3 credential error [Datasets] Handle any error code when encountering AWS S3 credential error Jul 18, 2022
@c21 c21 added the tests-ok The tagger certifies test failures are unrelated and assumes personal liability. label Jul 19, 2022
@scv119 scv119 merged commit daa3464 into ray-project:master Jul 19, 2022
@c21
Copy link
Contributor Author

c21 commented Jul 19, 2022

Thanks @scv119 and @matthewdeng for review!

@c21 c21 deleted the s3-followup branch July 19, 2022 00:59
@matthewdeng
Copy link
Contributor

@pcmoritz, @dmatrix - this should fix #26672, please let me know if the error message below is intuitive enough, thanks.

OSError: Failing to read AWS S3 file(s): ['ursa-labs-taxi-data/2009/01/data.parquet', 'anonymous@ursa-labs-taxi-data/2009/02/data.parquet']. 
Please check that file exists and has properly configured access.
See https://docs.ray.io/en/latest/data/creating-datasets.html#reading-from-remote-storage for more information.

Do you know if there are any resources describing what these error codes (e.g. 15, 100) mean? I feel like it's still not clear which issue is occurring.

@pcmoritz
Copy link
Contributor

@c21
Copy link
Contributor Author

c21 commented Jul 19, 2022

@matthewdeng - my guess when user encounters the issue, is they will (1). first check the file exists (Please check that file exists) then (2). check access / credential configured properly (has properly configured access).

From @pcmoritz 's link, it looks like error code 15 is ACCESS_DENIED, and 100 isUNKNOWN, not giving out too much information. btw I also tried locally for reading a non-existent file, error code is also 15.

@matthewdeng
Copy link
Contributor

@pcmoritz and I briefly chatted about how we could improve the UX so it is easier for the user to check if the file exists and their credentials.

One idea that comes from Philipp's manual debugging is to show them the s3 CLI/SDK command they can run to get a more verbose error message (e.g. #19799 (comment) or #19799 (comment)).

xwjiang2010 pushed a commit to xwjiang2010/ray that referenced this pull request Jul 19, 2022
…error (ray-project#26669)

As a followup of ray-project#26619 (comment) and ray-project#26619 (comment), here we change from PermissionError to OSError, to be consistent as original error, and also change function name from _handle_read_s3_files_error to _handle_read_os_error, which is more general that we can handle other file systems such as GCS in the future.

Also change to hanlde any error message with pattern AWS Error [code xxx]: No response body as new issue with error code 100 is raised in ray-project#26672 .

Signed-off-by: Xiaowei Jiang <[email protected]>
clarkzinzow pushed a commit that referenced this pull request Jul 21, 2022
As followup of #26669 (comment), we want to add AWS CLI command information into S# credential error message, so users have a better idea to further debug the read issue.
Rohan138 pushed a commit to Rohan138/ray that referenced this pull request Jul 28, 2022
…oject#26789)

As followup of ray-project#26669 (comment), we want to add AWS CLI command information into S# credential error message, so users have a better idea to further debug the read issue.

Signed-off-by: Rohan138 <[email protected]>
Stefan-1313 pushed a commit to Stefan-1313/ray_mod that referenced this pull request Aug 18, 2022
…error (ray-project#26669)

As a followup of ray-project#26619 (comment) and ray-project#26619 (comment), here we change from PermissionError to OSError, to be consistent as original error, and also change function name from _handle_read_s3_files_error to _handle_read_os_error, which is more general that we can handle other file systems such as GCS in the future.

Also change to hanlde any error message with pattern AWS Error [code xxx]: No response body as new issue with error code 100 is raised in ray-project#26672 .

Signed-off-by: Stefan van der Kleij <[email protected]>
Stefan-1313 pushed a commit to Stefan-1313/ray_mod that referenced this pull request Aug 18, 2022
…oject#26789)

As followup of ray-project#26669 (comment), we want to add AWS CLI command information into S# credential error message, so users have a better idea to further debug the read issue.

Signed-off-by: Stefan van der Kleij <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests-ok The tagger certifies test failures are unrelated and assumes personal liability.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Datasets] Raise descriptive error when expired AWS credentials are used
4 participants