diff --git a/evaluations/evaluations/capability_runner.py b/evaluations/evaluations/capability_runner.py index 67d95588..cccf2c1d 100644 --- a/evaluations/evaluations/capability_runner.py +++ b/evaluations/evaluations/capability_runner.py @@ -120,7 +120,7 @@ class _EvalDeps: def _prepare_agent( capability_factory: CapabilityFactory, - db_path: Path, + db_path: Path | None, config: AppConfig, capability_model: str | Model, document_filter: str | None, @@ -158,7 +158,7 @@ def _state_after_run( async def run_capability_question( capability_factory: CapabilityFactory, - db_path: Path, + db_path: Path | None, config: AppConfig, question: str, capability_model: str | Model, @@ -195,7 +195,7 @@ async def run_capability_question( async def run_capability_conversation( capability_factory: CapabilityFactory, - db_path: Path, + db_path: Path | None, config: AppConfig, questions: list[str], capability_model: str | Model, diff --git a/evaluations/evaluations/config.py b/evaluations/evaluations/config.py index 205905d2..8e94f504 100644 --- a/evaluations/evaluations/config.py +++ b/evaluations/evaluations/config.py @@ -83,6 +83,14 @@ class DatasetSpec: compaction: bool = False experiment_metadata: dict[str, Any] | None = None + def covers_a_set(self, config) -> bool: + """Whether `lancedb.databases` names the databases to evaluate over. + + A path names one database and wins over the configured set, so a run over + a set has to pass none — the client resolves it. + """ + return bool(config.lancedb.databases) + def db_path(self, override_path: Path | None = None) -> Path: """Get the database path. diff --git a/evaluations/evaluations/qa.py b/evaluations/evaluations/qa.py index e725366f..bb8082e9 100644 --- a/evaluations/evaluations/qa.py +++ b/evaluations/evaluations/qa.py @@ -195,7 +195,7 @@ def _filter_qa_corpus(corpus, case_ids: set[str] | None): class _QARun(NamedTuple): cases: list[Case[Any, Any, dict[str, Any]]] - db: Path + db: Path | None judge_config: ModelConfig eval_name: str experiment_metadata: dict[str, Any] @@ -243,7 +243,7 @@ def _prepare_qa_run( return _QARun( cases=cases, - db=spec.db_path(db_path), + db=None if spec.covers_a_set(config) else spec.db_path(db_path), judge_config=judge_config, eval_name=eval_name, experiment_metadata=experiment_metadata, diff --git a/evaluations/evaluations/retrieval.py b/evaluations/evaluations/retrieval.py index f42eb17f..48d24690 100644 --- a/evaluations/evaluations/retrieval.py +++ b/evaluations/evaluations/retrieval.py @@ -72,7 +72,7 @@ async def run_retrieval_benchmark( evaluators=list(spec.retrieval_evaluators), ) - db = spec.db_path(db_path) + db = None if spec.covers_a_set(config) else spec.db_path(db_path) async with HaikuRAG(db, config=config, read_only=True) as rag: async def retrieval_target(question: str) -> list[str]: diff --git a/evaluations/tests/test_config.py b/evaluations/tests/test_config.py index 38ad1c5c..a53c1b6a 100644 --- a/evaluations/tests/test_config.py +++ b/evaluations/tests/test_config.py @@ -145,3 +145,29 @@ class TestRetrievalSample: ) assert sample.skip is True assert sample.source_type == "image" + + +class TestCoversASet: + """A run over `lancedb.databases` must pass no path, since a path names one + database and wins over the configured set.""" + + def test_a_configured_set_is_covered(self): + from haiku.rag.config.models import AppConfig, LanceDBConfig + + from evaluations.datasets import DATASETS + + spec = next(iter(DATASETS.values())) + config = AppConfig( + lancedb=LanceDBConfig(databases={"a": "/a.lancedb", "b": "/b.lancedb"}) + ) + + assert spec.covers_a_set(config) is True + + def test_one_database_is_not_a_set(self): + from haiku.rag.config.models import AppConfig + + from evaluations.datasets import DATASETS + + spec = next(iter(DATASETS.values())) + + assert spec.covers_a_set(AppConfig()) is False