Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

fix(cli): align ingest CLI with unified ingest dispatcher

Sameer6305b22c93e9ece6
diff --git a/semantica/cli.py b/semantica/cli.py
index 831e696d..3169a5a2 100644
--- a/semantica/cli.py
+++ b/semantica/cli.py
@@ -661,9 +661,9 @@ def ingest(
_dry(cli_ctx, "ingest", json_out=_is_json(cli_ctx, local_json),
source=source, type=ingestor_type, format=fmt)
return
- kwargs: Dict[str, Any] = {"source": source, "batch_size": batch_size}
+ kwargs: Dict[str, Any] = {"batch_size": batch_size}
if ingestor_type:
- kwargs["ingestor_type"] = ingestor_type
+ kwargs["source_type"] = ingestor_type
if fmt:
kwargs["format"] = fmt
if recursive:
@@ -674,7 +674,7 @@ def ingest(
kwargs["output"] = output
try:
from .ingest import ingest as _ingest
- result = _ingest(**kwargs)
+ result = _ingest(source, **kwargs)
except ImportError as exc:
raise click.ClickException(f"Ingest module not available: {exc}") from exc
if _is_json(cli_ctx, local_json):
diff --git a/tests/test_cli_commands.py b/tests/test_cli_commands.py
index d5e13be5..66ba7e8e 100644
--- a/tests/test_cli_commands.py
+++ b/tests/test_cli_commands.py
@@ -272,11 +272,53 @@ class TestIngest:
result = runner.invoke(main, ["ingest", "data.pdf", "--dry-run"])
_ok(result, substr="Dry run")
+ def test_runtime_path_passes_source_positionally(self, runner, monkeypatch):
+ captured = {}
+
+ def fake_ingest_file(sources, **kwargs):
+ captured["sources"] = sources
+ captured["kwargs"] = kwargs
+ return [{"path": sources}]
+
+ monkeypatch.setattr("semantica.ingest.methods.ingest_file", fake_ingest_file)
+
+ result = runner.invoke(
+ main,
+ ["ingest", "README.md", "--type", "file", "--format", "csv", "--json"],
+ )
+
+ _ok(result)
+ data = _json_output(result)
+ assert data["files"] == [{"path": "README.md"}]
+ assert captured["sources"] == "README.md"
+ assert captured["kwargs"]["method"] == "file"
+ assert captured["kwargs"]["batch_size"] == 500
+ assert captured["kwargs"]["format"] == "csv"
+
+ def test_runtime_path_passes_source_positionally_with_auto_detection(self, runner, monkeypatch):
+ captured = {}
+
+ def fake_ingest_file(sources, **kwargs):
+ captured["sources"] = sources
+ captured["kwargs"] = kwargs
+ return [{"path": sources}]
+
+ monkeypatch.setattr("semantica.ingest.methods.ingest_file", fake_ingest_file)
+
+ result = runner.invoke(main, ["ingest", "README.md", "--json"])
+
+ _ok(result)
+ data = _json_output(result)
+ assert data["files"] == [{"path": "README.md"}]
+ assert captured["sources"] == "README.md"
+ assert captured["kwargs"]["method"] == "file"
+
def test_import_error_is_clean(self, runner, monkeypatch):
monkeypatch.setattr(cli_module, "__import__", _import_side_effect, raising=False)
+ original_import = __import__
with patch("builtins.__import__", side_effect=lambda n, *a, **k: (
(_ for _ in ()).throw(ImportError(n))
- if n.startswith("semantica.ingest") else __import__(n, *a, **k)
+ if n.startswith("semantica.ingest") else original_import(n, *a, **k)
)):
result = runner.invoke(main, ["ingest", "data.pdf"])
assert result.exit_code != 0