Add zlib support to Decompressor#1189
Open
JohnHBrock wants to merge 1 commit intometa-pytorch:mainfrom
Open
Conversation
JohnHBrock
commented
Jun 18, 2023
|
|
||
| def test_zlibfile_readall(self): | ||
| uncompressed_data_test_cases = [b"", b"some data", 10_000 * b"some data"] | ||
| for uncompressed_data in uncompressed_data_test_cases: |
Author
There was a problem hiding this comment.
I didn't find an obvious way of using pytest parameterized tests that was compatible with expecttest, so I resorted to just manually iterating over a list of inputs.
JohnHBrock
commented
Jun 18, 2023
| # so that the whole input buffer can be decompressed within one | ||
| # .decompress() call. | ||
| data = self.read(sys.maxsize) | ||
| while data: |
Author
There was a problem hiding this comment.
I wasn't sure if python 3.7 support was desired, so I didn't use the walrus operator here.
JohnHBrock
commented
Jun 19, 2023
| return self.types.ZIP | ||
| elif ext == ".bz2": | ||
| return self.types.BZIP2 | ||
| elif ext == ".zlib": |
Author
There was a problem hiding this comment.
There doesn't seem to be a strong standard for what extension zlib files should have. I've also seen .z and .zz.
Author
|
@ejguan This could use a review. |
Contributor
|
Unfortunately, TorchData is paused for development. You might want to just fork it and land it on your own repo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1163.
Changes
Decompressor.Python unfortunately doesn't have a file-like class for zlib, so I created my own called
_ZlibFile.