Move ingester telemetry setup behind argument parsing

This commit is contained in:
Yiorgis Gozadinos 2026-08-13 11:32:07 +03:00
parent 614be8b2a7
commit 6186dae83f
No known key found for this signature in database
4 changed files with 19 additions and 15 deletions

View file

@ -4,7 +4,7 @@
### Fixed
- `cross-encoder` reranking no longer ties the scores of strongly-relevant candidates, which left their order to the sort. Scores remain 0-1.
- haiku-rag CLI startup no longer imports `lancedb`, `pyarrow` and `pydantic_ai`.
- `haiku-rag` and `haiku-ingester` CLI startup no longer imports `lancedb`, `pyarrow` and `pydantic_ai`.
- `haiku.rag.store` no longer re-exports `Store`; import it from `haiku.rag.store.engine`.
## [0.73.0] - 2026-08-06

View file

@ -59,15 +59,15 @@ def main(
) -> None:
"""Top-level callback so every subcommand inherits --config without
each one redeclaring it. Mirrors haiku-rag's CLI shape."""
from haiku.rag.telemetry import configure as configure_telemetry
_load_config_with_override(config)
configure_cli_logging()
configure_telemetry(service_name="haiku-ingester")
def cli() -> None:
"""Entry point that translates store-state errors into a clean exit."""
from haiku.rag.telemetry import configure as configure_telemetry
configure_cli_logging()
configure_telemetry(service_name="haiku-ingester")
try:
_cli()
except (MigrationRequiredError, ReadOnlyError) as e:

View file

@ -26,15 +26,17 @@ from haiku.rag.ingester.queue.models import JobOp
runner = CliRunner()
def test_importing_ingester_cli_does_not_load_lancedb():
"""Test that lancedb is not imported automatically by the cli. Doing so is
expensive. Must be run in a subprocess because lancedb might be imported by
other tests in the same session."""
def test_importing_ingester_cli_does_not_load_heavy_dependencies():
"""Importing the CLI must not pull the heavy runtime dependencies; they cost
seconds of startup. Runs in a subprocess because another test in the same
session may already have imported them."""
result = subprocess.run(
[
sys.executable,
"-c",
"import haiku.rag.ingester.cli, sys; assert 'lancedb' not in sys.modules",
"import haiku.rag.ingester.cli, sys; "
"loaded = {'lancedb', 'pyarrow', 'pydantic_ai'} & sys.modules.keys(); "
"assert not loaded, loaded",
],
capture_output=True,
text=True,

View file

@ -14,15 +14,17 @@ from haiku.rag.store.exceptions import MigrationRequiredError
runner = CliRunner()
def test_importing_cli_does_not_load_lancedb():
"""Test that lancedb is not imported automatically by the cli. Doing so is
expensive. Must be run in a subprocess because lancedb might be imported by
other tests in the same session."""
def test_importing_cli_does_not_load_heavy_dependencies():
"""Importing the CLI must not pull the heavy runtime dependencies; they cost
seconds of startup. Runs in a subprocess because another test in the same
session may already have imported them."""
result = subprocess.run(
[
sys.executable,
"-c",
"import haiku.rag.cli, sys; assert 'lancedb' not in sys.modules",
"import haiku.rag.cli, sys; "
"loaded = {'lancedb', 'pyarrow', 'pydantic_ai'} & sys.modules.keys(); "
"assert not loaded, loaded",
],
capture_output=True,
text=True,