Fix a client's coverage when it is first entered
`_resolve_scope` returned a scope without keeping it, so a client re-entered after its configuration was edited covered whatever the configuration then said. Resolving once is what the rest of the design rests on: the scope is what names results, citations and errors. A configuration is still free to change before first entry.
This commit is contained in:
parent
fa319596cc
commit
2325f187b5
2 changed files with 18 additions and 0 deletions
|
|
@ -314,6 +314,7 @@ class HaikuRAG:
|
|||
)
|
||||
if self._requested_sources is not None and self._requested_db_path is None:
|
||||
scope = scope.select(self._requested_sources)
|
||||
self._scope = scope
|
||||
return scope
|
||||
|
||||
async def __aenter__(self):
|
||||
|
|
|
|||
|
|
@ -94,6 +94,23 @@ class TestOpeningDatabases:
|
|||
|
||||
assert not alpha.store.db.is_open()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_client_keeps_the_databases_it_first_covered(self, tmp_path):
|
||||
"""Resolution happens once, so a configuration edited afterwards does not
|
||||
change what an already-entered client covers."""
|
||||
config = _config(tmp_path, ["alpha", "beta"])
|
||||
await _seed(config, "alpha", ["alpha document about cats"])
|
||||
await _seed(config, "beta", ["beta document about cats"])
|
||||
|
||||
rag = HaikuRAG(config=config)
|
||||
async with rag:
|
||||
assert rag.source_names == ("alpha", "beta")
|
||||
|
||||
config.lancedb.databases = {"gamma": str(tmp_path / "gamma.lancedb")}
|
||||
|
||||
async with rag:
|
||||
assert rag.source_names == ("alpha", "beta")
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_failing_read_leaves_no_sibling_reading(
|
||||
self, tmp_path, monkeypatch
|
||||
|
|
|
|||
Loading…
Reference in a new issue