-
Notifications
You must be signed in to change notification settings - Fork 238
feat: add compression and protocol in file name #138
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f64edf0
feat: add compression and protocol in file name
davidbp 4e002e1
fix: typo
davidbp b072c6f
fix: typo type hint
davidbp d0cbb82
test: test helper functions
davidbp e6e1b84
refactor: global variables in binary
davidbp ea68c6d
refactor: global variables in helper
davidbp 7ab2bf0
test: fix saving file with protocol and compression
davidbp b599620
test: add protocol and compress
davidbp 5ad298e
refactor: allow keyword and extension loading
davidbp 0c5a03c
test: simplify test with helper func
davidbp 919f534
test: add missing import
davidbp 2eb8133
refactor: remove print
davidbp 03d3daa
docs: add serialization documentation
davidbp 10b22fa
docs: rephrase explanation
davidbp 2352842
docs: add save binary
davidbp 2545ed7
docs: add save binary
davidbp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import pytest | ||
| import pathlib | ||
|
|
||
| from docarray.helper import ( | ||
| protocol_and_compress_from_file_path, | ||
| add_protocol_and_compress_to_file_path, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| 'file_path', ['doc_array', '../docarray', './a_folder/docarray'] | ||
| ) | ||
| @pytest.mark.parametrize( | ||
| 'protocol', ['protobuf', 'protobuf-array', 'pickle', 'pickle-array'] | ||
| ) | ||
| @pytest.mark.parametrize('compress', ['lz4', 'bz2', 'lzma', 'zlib', 'gzip', None]) | ||
| def test_protocol_and_compress_from_file_path(file_path, protocol, compress): | ||
|
|
||
| file_path_extended = file_path | ||
| if protocol: | ||
| file_path_extended += '.' + protocol | ||
| if compress: | ||
| file_path_extended += '.' + compress | ||
|
|
||
| _protocol, _compress = protocol_and_compress_from_file_path(file_path_extended) | ||
|
|
||
| assert _protocol in {'protobuf', 'protobuf-array', 'pickle', 'pickle-array', None} | ||
| assert _compress in {'lz4', 'bz2', 'lzma', 'zlib', 'gzip', None} | ||
|
|
||
| assert protocol == _protocol | ||
| assert compress == _compress | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('file_path', ['doc_array', './some_folder/doc_array']) | ||
| @pytest.mark.parametrize( | ||
| 'protocol', ['protobuf', 'protobuf-array', 'pickle', 'pickle-array'] | ||
| ) | ||
| @pytest.mark.parametrize('compress', ['lz4', 'bz2', 'lzma', 'zlib', 'gzip']) | ||
| def test_add_protocol_and_compress_to_file_path(file_path, compress, protocol): | ||
| file_path_extended = add_protocol_and_compress_to_file_path( | ||
| file_path, compress, protocol | ||
| ) | ||
| file_path_suffixes = [ | ||
| e.replace('.', '') for e in pathlib.Path(file_path_extended).suffixes | ||
| ] | ||
|
|
||
| if compress: | ||
| assert compress in file_path_suffixes | ||
| if protocol: | ||
| assert protocol in file_path_suffixes |
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.
Uh oh!
There was an error while loading. Please reload this page.