Skip to content

Commit e176878

Browse files
committed
fix for 3.9
1 parent 50dabf8 commit e176878

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

tests/integration/test_threshold_optimizer.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
import sys
2+
13
import pytest
24

5+
if sys.version_info.major == 3 and sys.version_info.minor < 10:
6+
pytest.skip("Test requires Python 3.10 or higher", allow_module_level=True)
7+
38
from redisvl.extensions.llmcache import SemanticCache
49
from redisvl.extensions.router import Route, SemanticRouter
510
from redisvl.extensions.router.schema import RoutingConfig
@@ -114,6 +119,7 @@ def test_routes_different_distance_thresholds_optimizer_default(
114119
def test_routes_different_distance_thresholds_optimizer_precision(
115120
semantic_router, routes, redis_url, test_data_optimization
116121
):
122+
117123
redis_version = semantic_router._index.client.info()["redis_version"]
118124
if not compare_versions(redis_version, "7.0.0"):
119125
pytest.skip("Not using a late enough version of Redis")
@@ -189,6 +195,10 @@ def test_optimize_threshold_cache_default(redis_url):
189195
distance_threshold=null_threshold,
190196
)
191197

198+
redis_version = cache.client.info()["redis_version"]
199+
if not compare_versions(redis_version, "7.0.0"):
200+
pytest.skip("Not using a late enough version of Redis")
201+
192202
paris_key = cache.store(prompt="what is the capital of france?", response="paris")
193203
rabat_key = cache.store(prompt="what is the capital of morocco?", response="rabat")
194204

@@ -213,6 +223,10 @@ def test_optimize_threshold_cache_precision(redis_url):
213223
distance_threshold=null_threshold,
214224
)
215225

226+
redis_version = cache.client.info()["redis_version"]
227+
if not compare_versions(redis_version, "7.0.0"):
228+
pytest.skip("Not using a late enough version of Redis")
229+
216230
paris_key = cache.store(prompt="what is the capital of france?", response="paris")
217231
rabat_key = cache.store(prompt="what is the capital of morocco?", response="rabat")
218232

@@ -237,6 +251,10 @@ def test_optimize_threshold_cache_recall(redis_url):
237251
distance_threshold=null_threshold,
238252
)
239253

254+
redis_version = cache.client.info()["redis_version"]
255+
if not compare_versions(redis_version, "7.0.0"):
256+
pytest.skip("Not using a late enough version of Redis")
257+
240258
paris_key = cache.store(prompt="what is the capital of france?", response="paris")
241259
rabat_key = cache.store(prompt="what is the capital of morocco?", response="rabat")
242260

tests/unit/test_threshold_optimizer_utility.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import sys
2+
13
import pytest
4+
5+
if sys.version_info.major == 3 and sys.version_info.minor < 10:
6+
pytest.skip("Test requires Python 3.10 or higher", allow_module_level=True)
7+
28
from ranx import evaluate
39

410
from redisvl.extensions.threshold_optimizer.cache import _generate_run_cache
511
from redisvl.extensions.threshold_optimizer.schema import TestData
6-
from redisvl.extensions.threshold_optimizer.utils import (
7-
NULL_RESPONSE_KEY,
8-
_format_qrels,
9-
)
12+
from redisvl.extensions.threshold_optimizer.utils import _format_qrels
1013

1114
# Note: these tests are not intended to test ranx but to test that our data formatting for the package is correct
1215

0 commit comments

Comments
 (0)