Attention
June 2024 Status Update: Removing DataPipes and DataLoader V2
We are re-focusing the torchdata repo to be an iterative enhancement of torch.utils.data.DataLoader. We do not plan on continuing development or maintaining the [DataPipes] and [DataLoaderV2] solutions, and they will be removed from the torchdata repo. We’ll also be revisiting the DataPipes references in pytorch/pytorch. In release torchdata==0.8.0 (July 2024) they will be marked as deprecated, and in 0.9.0 (Oct 2024) they will be deleted. Existing users are advised to pin to torchdata==0.8.0 or an older version until they are able to migrate away. Subsequent releases will not include DataPipes or DataLoaderV2. Please reach out if you suggestions or comments (please use this issue for feedback)
Decompressor¶
- class torchdata.datapipes.iter.Decompressor(source_datapipe: IterDataPipe[Tuple[str, IOBase]], file_type: Optional[Union[str, CompressionType]] = None)¶
Takes tuples of path and compressed stream of data, and returns tuples of path and decompressed stream of data (functional name:
decompress
). The input compression format can be specified or automatically detected based on the files’ file extensions.- Parameters:
source_datapipe – IterDataPipe containing tuples of path and compressed stream of data
file_type – Optional string or
CompressionType
that represents what compression format of the inputs
Example
>>> from torchdata.datapipes.iter import FileLister, FileOpener >>> tar_file_dp = FileLister(self.temp_dir.name, "*.tar") >>> tar_load_dp = FileOpener(tar_file_dp, mode="b") >>> tar_decompress_dp = Decompressor(tar_load_dp, file_type="tar") >>> for _, stream in tar_decompress_dp: >>> print(stream.read()) b'0123456789abcdef'