fix: suppress legacy warnings in machine JSON paths
This commit is contained in:
@@ -61,6 +61,18 @@ embeddings:
|
|||||||
return cfg
|
return cfg
|
||||||
|
|
||||||
|
|
||||||
|
def _legacy_qdrant_runtime_config(tmp_path: Path) -> Path:
|
||||||
|
cfg = _qdrant_runtime_config(tmp_path)
|
||||||
|
text = cfg.read_text()
|
||||||
|
text = text.replace(
|
||||||
|
"dwh:\n type: postgres_direct\n connection: {database: analytics, schema: mart, user: reader, password: secret}\n",
|
||||||
|
"database: {database: analytics, schema: mart, user: reader, password: secret}\n",
|
||||||
|
)
|
||||||
|
text = text.replace("roots:\n", "paths:\n")
|
||||||
|
cfg.write_text(text)
|
||||||
|
return cfg
|
||||||
|
|
||||||
|
|
||||||
def _write_schema_artifacts(tmp_path: Path) -> None:
|
def _write_schema_artifacts(tmp_path: Path) -> None:
|
||||||
(tmp_path / "artifacts" / "mschema").mkdir(parents=True, exist_ok=True)
|
(tmp_path / "artifacts" / "mschema").mkdir(parents=True, exist_ok=True)
|
||||||
(tmp_path / "artifacts" / "mschema" / "physical.yaml").write_text(
|
(tmp_path / "artifacts" / "mschema" / "physical.yaml").write_text(
|
||||||
@@ -252,3 +264,33 @@ def test_vector_index_schema_human_missing_config_has_original_error(tmp_path):
|
|||||||
assert response.exit_code == 1
|
assert response.exit_code == 1
|
||||||
assert response.output
|
assert response.output
|
||||||
assert "ERRORE:" in response.output
|
assert "ERRORE:" in response.output
|
||||||
|
|
||||||
|
|
||||||
|
def test_vector_index_schema_json_legacy_config_has_no_stderr_on_success(monkeypatch, tmp_path):
|
||||||
|
cfg = _legacy_qdrant_runtime_config(tmp_path)
|
||||||
|
_write_schema_artifacts(tmp_path)
|
||||||
|
store = _FakeVectorStore()
|
||||||
|
monkeypatch.setattr("tht.adapters.factory.build_vector_store", lambda cfg, require_write: store)
|
||||||
|
monkeypatch.setattr("tht.cli.vector_cmd.make_embedder", lambda _: _FakeEmbedder())
|
||||||
|
|
||||||
|
response = CliRunner().invoke(app, ["vector", "index-schema", "--json", "-c", str(cfg)])
|
||||||
|
|
||||||
|
assert response.exit_code == 0, response.output
|
||||||
|
assert response.stderr == ""
|
||||||
|
assert response.stdout.count("\n") == 1
|
||||||
|
assert json.loads(response.stdout)["status"] == "succeeded"
|
||||||
|
|
||||||
|
|
||||||
|
def test_vector_index_schema_json_legacy_config_has_no_stderr_on_failure(tmp_path):
|
||||||
|
cfg = _legacy_qdrant_runtime_config(tmp_path)
|
||||||
|
_write_schema_artifacts(tmp_path)
|
||||||
|
(tmp_path / "artifacts" / "mschema" / "physical.yaml").unlink()
|
||||||
|
|
||||||
|
response = CliRunner().invoke(app, ["vector", "index-schema", "--json", "-c", str(cfg)])
|
||||||
|
|
||||||
|
assert response.exit_code == 1
|
||||||
|
assert response.stderr == ""
|
||||||
|
assert response.stdout.count("\n") == 1
|
||||||
|
assert json.loads(response.stdout) == {
|
||||||
|
"status": "failed", "code": "physical_schema_missing"
|
||||||
|
}
|
||||||
|
|||||||
@@ -241,6 +241,7 @@ def test_suggest_fks_json_is_single_deterministic_document_without_writing(tmp_p
|
|||||||
app, ["schema", "suggest-fks", "--json", "-c", str(cfg), "--from-sql", str(staged)]
|
app, ["schema", "suggest-fks", "--json", "-c", str(cfg), "--from-sql", str(staged)]
|
||||||
)
|
)
|
||||||
assert response.exit_code == 0, response.output
|
assert response.exit_code == 0, response.output
|
||||||
|
assert response.stderr == ""
|
||||||
assert response.stdout.count("\n") == 1
|
assert response.stdout.count("\n") == 1
|
||||||
payload = json.loads(response.stdout)
|
payload = json.loads(response.stdout)
|
||||||
assert payload["status"] == "succeeded"
|
assert payload["status"] == "succeeded"
|
||||||
@@ -261,6 +262,7 @@ def test_suggest_fks_json_failure_is_safe_and_single_document(tmp_path):
|
|||||||
(tmp_path / "artifacts" / "mschema" / "physical.yaml").unlink()
|
(tmp_path / "artifacts" / "mschema" / "physical.yaml").unlink()
|
||||||
response = CliRunner().invoke(app, ["schema", "suggest-fks", "--json", "-c", str(cfg)])
|
response = CliRunner().invoke(app, ["schema", "suggest-fks", "--json", "-c", str(cfg)])
|
||||||
assert response.exit_code != 0
|
assert response.exit_code != 0
|
||||||
|
assert response.stderr == ""
|
||||||
assert response.stdout.count("\n") == 1
|
assert response.stdout.count("\n") == 1
|
||||||
payload = json.loads(response.stdout)
|
payload = json.loads(response.stdout)
|
||||||
assert payload == {"status": "failed", "code": "physical_schema_missing"}
|
assert payload == {"status": "failed", "code": "physical_schema_missing"}
|
||||||
@@ -276,6 +278,7 @@ def test_schema_check_json_reports_orphan_count_without_prose(tmp_path):
|
|||||||
)
|
)
|
||||||
response = CliRunner().invoke(app, ["schema", "check", "--json", "-c", str(cfg)])
|
response = CliRunner().invoke(app, ["schema", "check", "--json", "-c", str(cfg)])
|
||||||
assert response.exit_code == 3
|
assert response.exit_code == 3
|
||||||
|
assert response.stderr == ""
|
||||||
assert response.stdout.count("\n") == 1
|
assert response.stdout.count("\n") == 1
|
||||||
assert json.loads(response.stdout) == {
|
assert json.loads(response.stdout) == {
|
||||||
"status": "failed", "code": "annotation_orphans", "orphan_count": 1,
|
"status": "failed", "code": "annotation_orphans", "orphan_count": 1,
|
||||||
@@ -327,11 +330,14 @@ def test_schema_check_json_success_and_reviewed_annotations_are_preserved(tmp_pa
|
|||||||
|
|
||||||
check = CliRunner().invoke(app, ["schema", "check", "--json", "-c", str(cfg)])
|
check = CliRunner().invoke(app, ["schema", "check", "--json", "-c", str(cfg)])
|
||||||
assert check.exit_code == 0, check.output
|
assert check.exit_code == 0, check.output
|
||||||
|
assert check.stderr == ""
|
||||||
|
assert check.stdout.count("\n") == 1
|
||||||
assert json.loads(check.stdout) == {
|
assert json.loads(check.stdout) == {
|
||||||
"status": "succeeded", "code": "ok", "orphan_count": 0, "orphans": []
|
"status": "succeeded", "code": "ok", "orphan_count": 0, "orphans": []
|
||||||
}
|
}
|
||||||
suggest = CliRunner().invoke(app, ["schema", "suggest-fks", "--json", "-c", str(cfg)])
|
suggest = CliRunner().invoke(app, ["schema", "suggest-fks", "--json", "-c", str(cfg)])
|
||||||
assert suggest.exit_code == 0, suggest.output
|
assert suggest.exit_code == 0, suggest.output
|
||||||
|
assert suggest.stderr == ""
|
||||||
assert json.loads(suggest.stdout)["candidate_count"] == 0
|
assert json.loads(suggest.stdout)["candidate_count"] == 0
|
||||||
assert annotations_path.read_text() == before
|
assert annotations_path.read_text() == before
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# ruff: noqa: BLE001, S110, B008
|
# ruff: noqa: BLE001, S110, B008
|
||||||
import logging
|
import logging
|
||||||
|
import warnings
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TypedDict
|
from typing import TypedDict
|
||||||
|
|
||||||
@@ -143,6 +144,15 @@ def _schema_json(payload: dict) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def _machine_config(config: Path):
|
def _machine_config(config: Path):
|
||||||
|
# Legacy resource keys remain accepted, but their deprecation warning is not part of
|
||||||
|
# the JSON machine contract. Keep this filter scoped to this call so human commands
|
||||||
|
# (and unrelated warnings/errors) retain their existing behavior.
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
warnings.filterwarnings(
|
||||||
|
"ignore",
|
||||||
|
message=r"^DEPRECATION: legacy workspace resource keys are deprecated;",
|
||||||
|
category=FutureWarning,
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
return load_config(config)
|
return load_config(config)
|
||||||
except ConfigError:
|
except ConfigError:
|
||||||
|
|||||||
Reference in New Issue
Block a user