-
Notifications
You must be signed in to change notification settings - Fork 238
fix(annlite): bump annlite to v0.4.0 #622
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
Closed
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
b949459
fix: fix annlite unit test
jemmyshin 0e4b335
fix: fix annlite unit test
jemmyshin 1e0e3cb
fix: fix annlite unit test
jemmyshin 9616ce7
fix: resolve file lock in rocksdb
jemmyshin 370df2d
fix: close da in plot test
jemmyshin 468888c
fix: close da in plot test
jemmyshin 71fdcdc
fix: remove close in backend
jemmyshin 7a02127
feat: add annlite ctx mngr
jemmyshin 8ca4027
feat: add annlite ctx mngr
jemmyshin ab3846f
fix: fix plot test
jemmyshin 8026e87
fix: fix plot test
jemmyshin ad5c2f1
fix: fix annlite based unit test
jemmyshin 1abdaa2
fix: ensure ci use main branch of annlite
jemmyshin 7c7c648
fix: ensure ci use main branch of annlite
jemmyshin b99d438
fix: ensure ci use main branch of annlite
jemmyshin 0665f4b
fix: remove annlite cntx mngr
jemmyshin 21e6d1d
fix: recover annlite ci
jemmyshin d8bc517
fix: revert changes in tests
jemmyshin 99cfb70
fix: revert changes in tests
jemmyshin 669aea0
Merge branch 'main' into fix-annlite
jemmyshin cde4a16
fix: close annlite after iteration
jemmyshin e1274aa
fix: close annlite after iteration
jemmyshin 089e316
fix: remove redundant cntx mngr
jemmyshin 95d054b
fix: fix and enable the annlite test
jemmyshin d622fdb
ci: remove pip install --pre annlite
jemmyshin 8176720
Merge branch 'main' into fix-annlite
jemmyshin d15dce0
Merge branch 'main' into fix-annlite
jemmyshin 49c7ea6
Merge branch 'main' into fix-annlite
jemmyshin 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,20 +43,31 @@ def test_document_save_load( | |
| ): | ||
| tmp_file = os.path.join(tmp_path, 'test') | ||
| da = da_cls(docs, config=config()) | ||
|
|
||
| da.insert(2, Document(id='new')) | ||
| da.save(tmp_file, file_format=method, encoding=encoding) | ||
|
|
||
| da_info = { | ||
| 'id': [d.id for d in da], | ||
| 'embedding': [d.embedding for d in da], | ||
| 'content': [d.content for d in da], | ||
| } | ||
|
|
||
| if da_cls == DocumentArrayAnnlite: | ||
| da._annlite.close() | ||
|
|
||
| da_r = type(da).load( | ||
| tmp_file, file_format=method, encoding=encoding, config=config() | ||
| ) | ||
|
|
||
| assert type(da) is type(da_r) | ||
| assert len(da) == len(da_r) | ||
| assert len(da) == len(da_info['id']) | ||
| assert da_r[2].id == 'new' | ||
| for d, d_r in zip(da, da_r): | ||
| assert d.id == d_r.id | ||
| np.testing.assert_equal(d.embedding, d_r.embedding) | ||
| assert d.content == d_r.content | ||
|
|
||
| for idx, d_r in enumerate(da_r): | ||
| assert da_info['id'][idx] == d_r.id | ||
| np.testing.assert_equal(da_info['embedding'][idx], d_r.embedding) | ||
| assert da_info['content'][idx] == d_r.content | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('flatten_tags', [True, False]) | ||
|
|
@@ -200,13 +211,24 @@ def test_from_to_pd_dataframe(da_cls, config, start_storage): | |
| ) | ||
| def test_from_to_bytes(da_cls, config, start_storage): | ||
| # simple | ||
| assert len(da_cls.load_binary(bytes(da_cls.empty(2, config=config)))) == 2 | ||
| if da_cls == DocumentArrayAnnlite: | ||
| da = da_cls.empty(2, config=config) | ||
| da_bytes = da.to_bytes() | ||
| da._annlite.close() | ||
|
|
||
| db = da_cls.from_bytes(da_bytes, config=config) | ||
| assert len(db) == 2 | ||
| db._annlite.close() | ||
| else: | ||
| assert len(da_cls.load_binary(bytes(da_cls.empty(2, config=config)))) == 2 | ||
|
|
||
| da = da_cls.empty(2, config=config) | ||
|
|
||
| da[:, 'embedding'] = [[1, 2, 3], [4, 5, 6]] | ||
| da[:, 'tensor'] = [[1, 2], [2, 1]] | ||
| da[0, 'tags'] = {'hello': 'world'} | ||
| if da_cls == DocumentArrayAnnlite: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this |
||
| da._annlite.close() | ||
| da2 = da_cls.load_binary(bytes(da)) | ||
jemmyshin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert da2.tensors == [[1, 2], [2, 1]] | ||
| import numpy as np | ||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for example here, DA will create an annlite instance with temp file name. I don't think anything would access the same temp file concurrently, why do we need to release the lock ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because we need to test with different parameters, it's like a for loop, need to close it before another iteration.