Skip to content

Commit

Permalink
[Data] Improve _resolve_paths_and_filesystem error message (ray-pro…
Browse files Browse the repository at this point in the history
…ject#38366)

If you pass an invalid input to _resolve_paths_and_filesystem, you get an error message telling you what types are valid, but it doesn't tell you what you passed it.

> paths must be a path string or a list of path strings.

This PR updates the error message to describe what you passed in:

> 'Expected paths to be a str, pathlib.Path, or list[str], but got None'

Signed-off-by: Balaji Veeramani <[email protected]>
  • Loading branch information
bveeramani committed Aug 14, 2023
1 parent 613b97d commit 77f70e4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python/ray/data/datasource/file_based_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,10 @@ def _resolve_paths_and_filesystem(
if isinstance(paths, pathlib.Path):
paths = [str(paths)]
elif not isinstance(paths, list) or any(not isinstance(p, str) for p in paths):
raise ValueError("paths must be a path string or a list of path strings.")
raise ValueError(
"Expected `paths` to be a `str`, `pathlib.Path`, or `list[str]`, but got "
f"`{paths}`."
)
elif len(paths) == 0:
raise ValueError("Must provide at least one path.")

Expand Down

0 comments on commit 77f70e4

Please sign in to comment.