Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Semantic Router
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
aurelio-labs
Semantic Router
Commits
4930d46d
Commit
4930d46d
authored
2 months ago
by
James Briggs
Browse files
Options
Downloads
Patches
Plain Diff
fix: pinecone delays
parent
1141d73b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/unit/test_router.py
+16
-23
16 additions, 23 deletions
tests/unit/test_router.py
with
16 additions
and
23 deletions
tests/unit/test_router.py
+
16
−
23
View file @
4930d46d
...
...
@@ -752,37 +752,30 @@ class TestSemanticRouter:
)
if
index_cls
is
PineconeIndex
:
time
.
sleep
(
PINECONE_SLEEP
)
# allow for index to be populated
query_result
=
route_layer
(
text
=
"
Hello
"
,
route_filter
=
[
"
Route 1
"
]).
name
# with pytest.raises(ValueError):
# # Route 8 does not exist so should raise ValueError
# route_layer(text="Hello", route_filter=["Route 8"]).name
try
:
# TODO JB: currently LocalIndex raises ValueError but others don't
# they should all behave in the same way
route_layer
(
text
=
"
Hello
"
,
route_filter
=
[
"
Route 8
"
]).
name
except
ValueError
:
assert
True
assert
query_result
in
[
"
Route 1
"
]
@pytest.mark.skipif
(
os
.
environ
.
get
(
"
PINECONE_API_KEY
"
)
is
None
,
reason
=
"
Pinecone API key required
"
)
def
test_query_filter_pinecone
(
self
,
routes
,
index_cls
,
encoder_cls
,
router_cls
):
if
index_cls
is
PineconeIndex
:
encoder
=
encoder_cls
()
pineconeindex
=
init_index
(
index_cls
,
index_name
=
encoder
.
__class__
.
__name__
)
route_layer
=
router_cls
(
encoder
=
encoder
,
routes
=
routes
,
index
=
pineconeindex
,
auto_sync
=
"
local
"
,
)
time
.
sleep
(
PINECONE_SLEEP
)
# allow for index to be populated
count
=
0
# we allow for 5 retries to allow for index to be populated
while
count
<
RETRY_COUNT
:
query_result
=
route_layer
(
text
=
"
Hello
"
,
route_filter
=
[
"
Route 1
"
]).
name
try
:
route_layer
(
text
=
"
Hello
"
,
route_filter
=
[
"
Route 8
"
]).
name
except
ValueError
:
assert
True
assert
query_result
in
[
"
Route 1
"
]
assert
query_result
in
[
"
Route 1
"
]
break
except
AssertionError
:
logger
.
warning
(
f
"
Query result not in expected routes, waiting for retry (try
{
count
}
)
"
)
count
+=
1
time
.
sleep
(
PINECONE_SLEEP
)
# allow for index to be populated
@pytest.mark.skipif
(
os
.
environ
.
get
(
"
PINECONE_API_KEY
"
)
is
None
,
reason
=
"
Pinecone API key required
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment