-
Notifications
You must be signed in to change notification settings - Fork 61
Increase redisvl test coverage #109
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
13 commits
Select commit
Hold shift + click to select a range
ea4729d
Remove custom event_loop fixture to resolve pytest-asyncio deprecatio…
bsbodden b7b8394
Test non integer value passed to BaseLLMCache#set_ttl
bsbodden d83a875
Test SemanticCache with user-provided Redis client
bsbodden 7c08b0e
Test retrieving underlying SearchIndex for the cache
bsbodden 4c398fb
Test out of range distance threshold
bsbodden ec0c906
Test SemanticCache storing with invalid metadata
bsbodden e168f1c
Test deleting the SemanticCache
bsbodden 03dec1d
Test checks for index existence before use
bsbodden 032eab9
Test invalid schema provided to SearchIndex
bsbodden e529e01
Test SearchIndex#from_yaml
bsbodden 4377b09
Test query results unpacks JSON properly
bsbodden 33f5b19
Tests utils functions
bsbodden dfad9d3
Fix handling of tuples in utils#convert_bytes
bsbodden 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import pytest | ||
|
|
||
| from redisvl.index import SearchIndex | ||
| from redisvl.query import FilterQuery | ||
| from redisvl.query.filter import Tag | ||
|
|
||
| @pytest.fixture | ||
| def filter_query(): | ||
| return FilterQuery( | ||
| return_fields=None, | ||
| filter_expression=Tag("credit_score") == "high", | ||
| ) | ||
|
|
||
| @pytest.fixture | ||
| def index(sample_data): | ||
| fields_spec = [ | ||
| {"name": "credit_score", "type": "tag"}, | ||
| {"name": "user", "type": "tag"}, | ||
| {"name": "job", "type": "text"}, | ||
| {"name": "age", "type": "numeric"}, | ||
| { | ||
| "name": "user_embedding", | ||
| "type": "vector", | ||
| "attrs": { | ||
| "dims": 3, | ||
| "distance_metric": "cosine", | ||
| "algorithm": "flat", | ||
| "datatype": "float32", | ||
| }, | ||
| }, | ||
| ] | ||
|
|
||
| json_schema = { | ||
| "index": { | ||
| "name": "user_index_json", | ||
| "prefix": "users_json", | ||
| "storage_type": "json", | ||
| }, | ||
| "fields": fields_spec, | ||
| } | ||
|
|
||
| # construct a search index from the schema | ||
| index = SearchIndex.from_dict(json_schema) | ||
|
|
||
| # connect to local redis instance | ||
| index.connect("redis://localhost:6379") | ||
|
|
||
| # create the index (no data yet) | ||
| index.create(overwrite=True) | ||
|
|
||
| # Prepare and load the data | ||
| index.load(sample_data) | ||
|
|
||
| # run the test | ||
| yield index | ||
|
|
||
| # clean up | ||
| index.delete(drop=True) | ||
|
|
||
| def test_process_results_unpacks_json_properly(index, filter_query): | ||
| results = index.query(filter_query) | ||
| assert len(results) == 4 |
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
Oops, something went wrong.
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.