tests: call searcher.cleanup()/chat.cleanup() to ensure background embedding servers terminate after tests
This commit is contained in:
@@ -64,6 +64,9 @@ def test_backend_basic(backend_name):
|
|||||||
assert isinstance(results[0], SearchResult)
|
assert isinstance(results[0], SearchResult)
|
||||||
assert "topic 2" in results[0].text or "document" in results[0].text
|
assert "topic 2" in results[0].text or "document" in results[0].text
|
||||||
|
|
||||||
|
# Ensure cleanup to avoid hanging background servers
|
||||||
|
searcher.cleanup()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
os.environ.get("CI") == "true", reason="Skip model tests in CI to avoid MPS memory issues"
|
os.environ.get("CI") == "true", reason="Skip model tests in CI to avoid MPS memory issues"
|
||||||
@@ -90,3 +93,5 @@ def test_large_index():
|
|||||||
searcher = LeannSearcher(index_path)
|
searcher = LeannSearcher(index_path)
|
||||||
results = searcher.search(["word10 word20"], top_k=10)
|
results = searcher.search(["word10 word20"], top_k=10)
|
||||||
assert len(results[0]) == 10
|
assert len(results[0]) == 10
|
||||||
|
# Cleanup
|
||||||
|
searcher.cleanup()
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ def test_readme_basic_example(backend_name):
|
|||||||
# The second text about banana-crocodile should be more relevant
|
# The second text about banana-crocodile should be more relevant
|
||||||
assert "banana" in results[0].text or "crocodile" in results[0].text
|
assert "banana" in results[0].text or "crocodile" in results[0].text
|
||||||
|
|
||||||
|
# Ensure we cleanup background embedding server
|
||||||
|
searcher.cleanup()
|
||||||
|
|
||||||
# Chat with your data (using simulated LLM to avoid external dependencies)
|
# Chat with your data (using simulated LLM to avoid external dependencies)
|
||||||
chat = LeannChat(INDEX_PATH, llm_config={"type": "simulated"})
|
chat = LeannChat(INDEX_PATH, llm_config={"type": "simulated"})
|
||||||
response = chat.ask("How much storage does LEANN save?", top_k=1)
|
response = chat.ask("How much storage does LEANN save?", top_k=1)
|
||||||
@@ -66,6 +69,8 @@ def test_readme_basic_example(backend_name):
|
|||||||
# Verify chat works
|
# Verify chat works
|
||||||
assert isinstance(response, str)
|
assert isinstance(response, str)
|
||||||
assert len(response) > 0
|
assert len(response) > 0
|
||||||
|
# Cleanup chat resources
|
||||||
|
chat.cleanup()
|
||||||
|
|
||||||
|
|
||||||
def test_readme_imports():
|
def test_readme_imports():
|
||||||
|
|||||||
Reference in New Issue
Block a user