fix: harden model catalog projections
This commit is contained in:
@@ -214,7 +214,7 @@ embeddings: {provider: ollama_internal, base_url: http://embedding:11434, model:
|
||||
assert cfg.vectors.writer.api_key == "writer"
|
||||
|
||||
|
||||
def test_accepts_only_internal_ollama_embedding_contract(tmp_path):
|
||||
def test_accepts_catalog_selected_internal_ollama_embedding_contract(tmp_path):
|
||||
workspace = tmp_path / "workspace.yaml"
|
||||
workspace.write_text(
|
||||
"""
|
||||
@@ -225,8 +225,9 @@ resources:
|
||||
embeddings:
|
||||
provider: ollama_internal
|
||||
base_url: http://embedding:11434
|
||||
model: qwen3-embedding:0.6b
|
||||
dimensions: 1024
|
||||
id: ollama/bge-m3
|
||||
model: bge-m3
|
||||
dimensions: 1536
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -234,8 +235,59 @@ resources:
|
||||
|
||||
assert cfg.embeddings.provider == "ollama_internal"
|
||||
assert cfg.embeddings.base_url == "http://embedding:11434"
|
||||
assert cfg.embeddings.model == "qwen3-embedding:0.6b"
|
||||
assert cfg.embeddings.dim == 1024
|
||||
assert cfg.embeddings.id == "ollama/bge-m3"
|
||||
assert cfg.embeddings.model == "bge-m3"
|
||||
assert cfg.embeddings.dim == 1536
|
||||
|
||||
|
||||
def test_installation_embedding_projection_completes_model_free_runtime_source(
|
||||
tmp_path, monkeypatch,
|
||||
):
|
||||
monkeypatch.setenv("THT_INTERNAL_EMBEDDING_ID", "ollama/bge-m3")
|
||||
monkeypatch.setenv("THT_INTERNAL_EMBEDDING_MODEL", "bge-m3")
|
||||
monkeypatch.setenv("THT_INTERNAL_EMBEDDING_DIMENSIONS", "1536")
|
||||
workspace = tmp_path / "workspace.yaml"
|
||||
workspace.write_text(
|
||||
"""
|
||||
dwh:
|
||||
type: postgres_direct
|
||||
connection: {database: analytics, schema: mart, user: reader, password: secret}
|
||||
resources:
|
||||
embeddings:
|
||||
provider: ollama_internal
|
||||
base_url: http://embedding:11434
|
||||
"""
|
||||
)
|
||||
|
||||
cfg = load_config(workspace)
|
||||
|
||||
assert cfg.embeddings.id == "ollama/bge-m3"
|
||||
assert cfg.embeddings.model == "bge-m3"
|
||||
assert cfg.embeddings.dim == 1536
|
||||
|
||||
|
||||
def test_workspace_embedding_values_cannot_override_installation_projection(
|
||||
tmp_path, monkeypatch,
|
||||
):
|
||||
monkeypatch.setenv("THT_INTERNAL_EMBEDDING_ID", "ollama/bge-m3")
|
||||
monkeypatch.setenv("THT_INTERNAL_EMBEDDING_MODEL", "bge-m3")
|
||||
monkeypatch.setenv("THT_INTERNAL_EMBEDDING_DIMENSIONS", "1536")
|
||||
workspace = tmp_path / "workspace.yaml"
|
||||
workspace.write_text(
|
||||
"""
|
||||
dwh:
|
||||
type: postgres_direct
|
||||
connection: {database: analytics, schema: mart, user: reader, password: secret}
|
||||
resources:
|
||||
embeddings:
|
||||
provider: ollama_internal
|
||||
base_url: http://embedding:11434
|
||||
model: workspace-owned-model
|
||||
"""
|
||||
)
|
||||
|
||||
with pytest.raises(ConfigError, match="proprietà dell'installazione|diverge"):
|
||||
load_config(workspace)
|
||||
|
||||
|
||||
def test_accepts_internal_qdrant_resource_contract(tmp_path):
|
||||
|
||||
Reference in New Issue
Block a user