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
d0f30887
Commit
d0f30887
authored
5 months ago
by
James Briggs
Browse files
Options
Downloads
Patches
Plain Diff
fix: sync tests
parent
4094c792
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/unit/test_sync.py
+19
-14
19 additions, 14 deletions
tests/unit/test_sync.py
with
19 additions
and
14 deletions
tests/unit/test_sync.py
+
19
−
14
View file @
d0f30887
...
...
@@ -12,7 +12,7 @@ from semantic_router.route import Route
from
platform
import
python_version
PINECONE_SLEEP
=
12
PINECONE_SLEEP
=
6
def
mock_encoder_call
(
utterances
):
...
...
@@ -199,7 +199,7 @@ class TestRouteLayer:
def
test_second_initialization_sync
(
self
,
openai_encoder
,
routes
,
index_cls
):
index
=
init_index
(
index_cls
)
route_layer
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes
,
top_k
=
10
,
index
=
index
encoder
=
openai_encoder
,
routes
=
routes
,
index
=
index
,
auto_sync
=
"
local
"
)
if
index_cls
is
PineconeIndex
:
time
.
sleep
(
PINECONE_SLEEP
)
# allow for index to be populated
...
...
@@ -212,7 +212,10 @@ class TestRouteLayer:
self
,
openai_encoder
,
routes
,
routes_2
,
index_cls
):
index
=
init_index
(
index_cls
,
sync
=
None
)
_
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes
,
index
=
index
)
_
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes
,
index
=
index
,
auto_sync
=
"
local
"
)
route_layer
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes_2
,
index
=
index
)
if
index_cls
is
PineconeIndex
:
time
.
sleep
(
PINECONE_SLEEP
)
# allow for index to be populated
...
...
@@ -223,21 +226,23 @@ class TestRouteLayer:
)
def
test_utterance_diff
(
self
,
openai_encoder
,
routes
,
routes_2
,
index_cls
):
index
=
init_index
(
index_cls
)
_
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes
,
top_k
=
10
,
index
=
index
)
if
index_cls
is
PineconeIndex
:
time
.
sleep
(
PINECONE_SLEEP
)
# allow for index to be populated
_
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes
,
index
=
index
,
auto_sync
=
"
local
"
)
route_layer_2
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes_2
,
top_k
=
10
,
index
=
index
encoder
=
openai_encoder
,
routes
=
routes_2
,
index
=
index
)
if
index_cls
is
PineconeIndex
:
time
.
sleep
(
PINECONE_SLEEP
)
# allow for index to be populated
diff
=
route_layer_2
.
get_utterance_diff
()
assert
"
Route 1: Hello
"
in
diff
assert
"
+ Route 1: Hi
"
in
diff
assert
"
+ Route 2: Au revoir
"
in
diff
assert
"
+ Route 2: Bye
"
in
diff
assert
"
+ Route 2: Goodbye
"
in
diff
assert
"
Route 2: Hi
"
in
diff
diff
=
route_layer_2
.
get_utterance_diff
(
include_metadata
=
True
)
assert
"
+ Route 1: Hello | None | {
'
type
'
:
'
default
'
}
"
in
diff
assert
"
+ Route 1: Hi | None | {
'
type
'
:
'
default
'
}
"
in
diff
assert
"
- Route 1: Hello | None | {}
"
in
diff
assert
"
+ Route 2: Au revoir | None | {}
"
in
diff
assert
"
- Route 2: Hi | None | {}
"
in
diff
assert
"
+ Route 2: Bye | None | {}
"
in
diff
assert
"
+ Route 2: Goodbye | None | {}
"
in
diff
@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