ray.data.read_binary_files(paths: Union[str, List[str]], *, include_paths: bool = False, filesystem: Optional[pyarrow.fs.FileSystem] = None, parallelism: int = -1, ray_remote_args: Dict[str, Any] = None, arrow_open_stream_args: Optional[Dict[str, Any]] = None, meta_provider: ray.data.datasource.file_meta_provider.BaseFileMetadataProvider = <ray.data.datasource.file_meta_provider.DefaultFileMetadataProvider object>, partition_filter: Optional[ray.data.datasource.partitioning.PathPartitionFilter] = None, partitioning: ray.data.datasource.partitioning.Partitioning = None, ignore_missing_paths: bool = False, output_arrow_format: bool = False) ray.data.dataset.Dataset[source]#

Create a dataset from binary files of arbitrary contents.


>>> import ray
>>> # Read a directory of files in remote storage.
>>> ray.data.read_binary_files("s3://bucket/path") 
>>> # Read multiple local files.
>>> ray.data.read_binary_files( 
...     ["/path/to/file1", "/path/to/file2"])
  • paths – A single file path or a list of file paths (or directories).

  • include_paths – Whether to include the full path of the file in the dataset records. When specified, the stream records will be a tuple of the file path and the file contents.

  • filesystem – The filesystem implementation to read from.

  • ray_remote_args – kwargs passed to ray.remote in the read tasks.

  • parallelism – The requested parallelism of the read. Parallelism may be limited by the number of files of the stream.

  • arrow_open_stream_args – kwargs passed to pyarrow.fs.FileSystem.open_input_stream

  • meta_provider – File metadata provider. Custom metadata providers may be able to resolve file metadata more quickly and/or accurately.

  • partition_filter – Path-based partition filter, if any. Can be used with a custom callback to read only selected partitions of a dataset. By default, this does not filter out any files.

  • partitioning – A Partitioning object that describes how paths are organized. Defaults to None.

  • ignore_missing_paths – If True, ignores any file paths in paths that are not found. Defaults to False.

  • output_arrow_format – If True, returns data in Arrow format, instead of Python list format. Defaults to False.


Dataset producing records read from the specified paths.

PublicAPI: This API is stable across Ray releases.