Skip to content

Personal AI, On Personal Devices

Python

fix: expose state_db param in ingest_sources, isolate test from global state

Jon Saad-Falcon326e6f9779c6
diff --git a/src/openjarvis/cli/deep_research_setup_cmd.py b/src/openjarvis/cli/deep_research_setup_cmd.py
index 765c31ea..08d1399d 100644
--- a/src/openjarvis/cli/deep_research_setup_cmd.py
+++ b/src/openjarvis/cli/deep_research_setup_cmd.py
@@ -104,13 +104,21 @@ def _instantiate_connector(connector_id: str, config: Dict[str, Any]) -> Any:
def ingest_sources(
sources: List[Dict[str, Any]],
store: KnowledgeStore,
+ *,
+ state_db: str = "",
) -> int:
"""Connect and ingest all sources into the KnowledgeStore.
+ Parameters
+ ----------
+ state_db:
+ Path for the SyncEngine checkpoint database. Defaults to
+ ``~/.openjarvis/sync_state.db`` when empty.
+
Returns total chunks indexed across all sources.
"""
pipeline = IngestionPipeline(store)
- engine = SyncEngine(pipeline)
+ engine = SyncEngine(pipeline, state_db=state_db)
total = 0
for src in sources:
connector = _instantiate_connector(src["connector_id"], src["config"])
diff --git a/tests/cli/test_deep_research_setup.py b/tests/cli/test_deep_research_setup.py
index 4a789abb..d4d88b9d 100644
--- a/tests/cli/test_deep_research_setup.py
+++ b/tests/cli/test_deep_research_setup.py
@@ -131,8 +131,9 @@ def test_ingest_sources(tmp_path: Path) -> None:
)
db_path = tmp_path / "knowledge.db"
+ state_db = str(tmp_path / "sync_state.db")
store = KnowledgeStore(str(db_path))
- total = ingest_sources(sources, store)
+ total = ingest_sources(sources, store, state_db=state_db)
assert total > 0
assert store.count() > 0