Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d2c001735 |
@@ -13,6 +13,7 @@ from sqlalchemy import literal, select
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from python.ebook_search.bm25_corpus import (
|
from python.ebook_search.bm25_corpus import (
|
||||||
|
BM25CorpusUnavailableError,
|
||||||
load_bm25_corpus,
|
load_bm25_corpus,
|
||||||
score_bm25_corpus,
|
score_bm25_corpus,
|
||||||
)
|
)
|
||||||
@@ -252,7 +253,12 @@ def vector_candidates(engine: Engine, query: str, config: EbookSearchConfig) ->
|
|||||||
|
|
||||||
def bm25_candidates(query: str, config: EbookSearchConfig) -> list[SearchResult]:
|
def bm25_candidates(query: str, config: EbookSearchConfig) -> list[SearchResult]:
|
||||||
"""Return BM25-ranked lexical candidates using the persisted corpus."""
|
"""Return BM25-ranked lexical candidates using the persisted corpus."""
|
||||||
corpus = load_bm25_corpus(config)
|
try:
|
||||||
|
corpus = load_bm25_corpus(config)
|
||||||
|
except BM25CorpusUnavailableError as error:
|
||||||
|
logger.warning("ebook_bm25_index_unavailable_skipping error=%s", error)
|
||||||
|
return []
|
||||||
|
|
||||||
if not corpus.records:
|
if not corpus.records:
|
||||||
logger.info("ebook_bm25_search_complete corpus=0 candidates=0")
|
logger.info("ebook_bm25_search_complete corpus=0 candidates=0")
|
||||||
return []
|
return []
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ def test_validate_system(mocker: MockerFixture, fs: FakeFilesystem) -> None:
|
|||||||
"""test_validate_system."""
|
"""test_validate_system."""
|
||||||
fs.create_file(
|
fs.create_file(
|
||||||
"/mock_snapshot_config.toml",
|
"/mock_snapshot_config.toml",
|
||||||
contents='zpool = ["root_pool", "storage", "media"]\nservices = ["docker"]\n',
|
contents='zpools = ["root_pool", "storage", "media"]\nservices = ["docker"]\n',
|
||||||
)
|
)
|
||||||
|
|
||||||
mocker.patch(f"{VALIDATE_SYSTEM}.systemd_tests", return_value=None)
|
mocker.patch(f"{VALIDATE_SYSTEM}.systemd_tests", return_value=None)
|
||||||
@@ -33,9 +33,10 @@ def test_validate_system_errors(mocker: MockerFixture, fs: FakeFilesystem) -> No
|
|||||||
"""test_validate_system_errors."""
|
"""test_validate_system_errors."""
|
||||||
fs.create_file(
|
fs.create_file(
|
||||||
"/mock_snapshot_config.toml",
|
"/mock_snapshot_config.toml",
|
||||||
contents='zpool = ["root_pool", "storage", "media"]\nservices = ["docker"]\n',
|
contents='zpools = ["root_pool", "storage", "media"]\nservices = ["docker"]\n',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
mocker.patch(f"{VALIDATE_SYSTEM}.signal_alert")
|
||||||
mocker.patch(f"{VALIDATE_SYSTEM}.systemd_tests", return_value=["systemd_tests error"])
|
mocker.patch(f"{VALIDATE_SYSTEM}.systemd_tests", return_value=["systemd_tests error"])
|
||||||
mocker.patch(f"{VALIDATE_SYSTEM}.zpool_tests", return_value=["zpool_tests error"])
|
mocker.patch(f"{VALIDATE_SYSTEM}.zpool_tests", return_value=["zpool_tests error"])
|
||||||
|
|
||||||
@@ -49,9 +50,11 @@ def test_validate_system_execution(mocker: MockerFixture, fs: FakeFilesystem) ->
|
|||||||
"""test_validate_system_execution."""
|
"""test_validate_system_execution."""
|
||||||
fs.create_file(
|
fs.create_file(
|
||||||
"/mock_snapshot_config.toml",
|
"/mock_snapshot_config.toml",
|
||||||
contents='zpool = ["root_pool", "storage", "media"]\nservices = ["docker"]\n',
|
contents='zpools = ["root_pool", "storage", "media"]\nservices = ["docker"]\n',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
mocker.patch(f"{VALIDATE_SYSTEM}.signal_alert")
|
||||||
|
mocker.patch(f"{VALIDATE_SYSTEM}.systemd_tests", return_value=None)
|
||||||
mocker.patch(f"{VALIDATE_SYSTEM}.zpool_tests", side_effect=RuntimeError("zpool_tests error"))
|
mocker.patch(f"{VALIDATE_SYSTEM}.zpool_tests", side_effect=RuntimeError("zpool_tests error"))
|
||||||
|
|
||||||
with pytest.raises(SystemExit) as exception_info:
|
with pytest.raises(SystemExit) as exception_info:
|
||||||
|
|||||||
Reference in New Issue
Block a user