chore: add storage sane defaults (#4182)
Some checks failed
Integration Auth Tests / test-matrix (oauth2_token) (push) Failing after 2s
SqlStore Integration Tests / test-postgres (3.13) (push) Failing after 1s
SqlStore Integration Tests / test-postgres (3.12) (push) Failing after 1s
Test External Providers Installed via Module / test-external-providers-from-module (venv) (push) Has been skipped
Integration Tests (Replay) / generate-matrix (push) Successful in 4s
Python Package Build Test / build (3.12) (push) Failing after 5s
API Conformance Tests / check-schema-compatibility (push) Successful in 14s
Python Package Build Test / build (3.13) (push) Failing after 12s
Test External API and Providers / test-external (venv) (push) Failing after 32s
Vector IO Integration Tests / test-matrix (push) Failing after 1m16s
Unit Tests / unit-tests (3.12) (push) Failing after 1m32s
UI Tests / ui-tests (22) (push) Successful in 1m38s
Unit Tests / unit-tests (3.13) (push) Failing after 1m42s
Pre-commit / pre-commit (push) Successful in 3m4s
Integration Tests (Replay) / Integration Tests (, , , client=, ) (push) Failing after 4m8s

# What does this PR do?

since `StackRunConfig` requires certain parts of `StorageConfig`, it'd
probably make sense to template in some defaults that will "just work"
for most usecases

specifically introduce`ServerStoresConfig` defaults for inference,
metadata, conversations and prompts. We already actually funnel in
defaults for these sections ad-hoc throughout the codebase

additionally set some `backends` defaults for the `StorageConfig`.

This will alleviate some weirdness for `--providers` for run/list-deps
and also some work I have to better align our list-deps/run datatypes

---------

Signed-off-by: Charlie Doern <cdoern@redhat.com>
This commit is contained in:
Charlie Doern 2025-11-18 18:22:26 -05:00 committed by GitHub
parent bd5ad2963e
commit 91f1b352b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 49 additions and 7 deletions

View file

@ -12,6 +12,8 @@ from typing import Annotated, Literal
from pydantic import BaseModel, Field, field_validator from pydantic import BaseModel, Field, field_validator
from llama_stack.core.utils.config_dirs import DISTRIBS_BASE_DIR
class StorageBackendType(StrEnum): class StorageBackendType(StrEnum):
KV_REDIS = "kv_redis" KV_REDIS = "kv_redis"
@ -256,15 +258,24 @@ class ResponsesStoreReference(InferenceStoreReference):
class ServerStoresConfig(BaseModel): class ServerStoresConfig(BaseModel):
metadata: KVStoreReference | None = Field( metadata: KVStoreReference | None = Field(
default=None, default=KVStoreReference(
backend="kv_default",
namespace="registry",
),
description="Metadata store configuration (uses KV backend)", description="Metadata store configuration (uses KV backend)",
) )
inference: InferenceStoreReference | None = Field( inference: InferenceStoreReference | None = Field(
default=None, default=InferenceStoreReference(
backend="sql_default",
table_name="inference_store",
),
description="Inference store configuration (uses SQL backend)", description="Inference store configuration (uses SQL backend)",
) )
conversations: SqlStoreReference | None = Field( conversations: SqlStoreReference | None = Field(
default=None, default=SqlStoreReference(
backend="sql_default",
table_name="openai_conversations",
),
description="Conversations store configuration (uses SQL backend)", description="Conversations store configuration (uses SQL backend)",
) )
responses: ResponsesStoreReference | None = Field( responses: ResponsesStoreReference | None = Field(
@ -272,13 +283,21 @@ class ServerStoresConfig(BaseModel):
description="Responses store configuration (uses SQL backend)", description="Responses store configuration (uses SQL backend)",
) )
prompts: KVStoreReference | None = Field( prompts: KVStoreReference | None = Field(
default=None, default=KVStoreReference(backend="kv_default", namespace="prompts"),
description="Prompts store configuration (uses KV backend)", description="Prompts store configuration (uses KV backend)",
) )
class StorageConfig(BaseModel): class StorageConfig(BaseModel):
backends: dict[str, StorageBackendConfig] = Field( backends: dict[str, StorageBackendConfig] = Field(
default={
"kv_default": SqliteKVStoreConfig(
db_path=f"${{env.SQLITE_STORE_DIR:={DISTRIBS_BASE_DIR}}}/kvstore.db",
),
"sql_default": SqliteSqlStoreConfig(
db_path=f"${{env.SQLITE_STORE_DIR:={DISTRIBS_BASE_DIR}}}/sql_store.db",
),
},
description="Named backend configurations (e.g., 'default', 'cache')", description="Named backend configurations (e.g., 'default', 'cache')",
) )
stores: ServerStoresConfig = Field( stores: ServerStoresConfig = Field(

View file

@ -38,6 +38,9 @@ async def service():
}, },
stores=ServerStoresConfig( stores=ServerStoresConfig(
conversations=SqlStoreReference(backend="sql_test", table_name="openai_conversations"), conversations=SqlStoreReference(backend="sql_test", table_name="openai_conversations"),
metadata=None,
inference=None,
prompts=None,
), ),
) )
register_sqlstore_backends({"sql_test": storage.backends["sql_test"]}) register_sqlstore_backends({"sql_test": storage.backends["sql_test"]})
@ -142,6 +145,9 @@ async def test_policy_configuration():
}, },
stores=ServerStoresConfig( stores=ServerStoresConfig(
conversations=SqlStoreReference(backend="sql_test", table_name="openai_conversations"), conversations=SqlStoreReference(backend="sql_test", table_name="openai_conversations"),
metadata=None,
inference=None,
prompts=None,
), ),
) )
register_sqlstore_backends({"sql_test": storage.backends["sql_test"]}) register_sqlstore_backends({"sql_test": storage.backends["sql_test"]})

View file

@ -10,8 +10,9 @@ from unittest.mock import AsyncMock
import pytest import pytest
from llama_stack.core.datatypes import QualifiedModel, SafetyConfig, StackRunConfig, StorageConfig, VectorStoresConfig from llama_stack.core.datatypes import QualifiedModel, SafetyConfig, StackRunConfig, VectorStoresConfig
from llama_stack.core.stack import validate_safety_config, validate_vector_stores_config from llama_stack.core.stack import validate_safety_config, validate_vector_stores_config
from llama_stack.core.storage.datatypes import ServerStoresConfig, StorageConfig
from llama_stack_api import Api, ListModelsResponse, ListShieldsResponse, Model, ModelType, Shield from llama_stack_api import Api, ListModelsResponse, ListShieldsResponse, Model, ModelType, Shield
@ -21,7 +22,15 @@ class TestVectorStoresValidation:
run_config = StackRunConfig( run_config = StackRunConfig(
image_name="test", image_name="test",
providers={}, providers={},
storage=StorageConfig(backends={}, stores={}), storage=StorageConfig(
backends={},
stores=ServerStoresConfig(
metadata=None,
inference=None,
conversations=None,
prompts=None,
),
),
vector_stores=VectorStoresConfig( vector_stores=VectorStoresConfig(
default_provider_id="faiss", default_provider_id="faiss",
default_embedding_model=QualifiedModel( default_embedding_model=QualifiedModel(
@ -41,7 +50,15 @@ class TestVectorStoresValidation:
run_config = StackRunConfig( run_config = StackRunConfig(
image_name="test", image_name="test",
providers={}, providers={},
storage=StorageConfig(backends={}, stores={}), storage=StorageConfig(
backends={},
stores=ServerStoresConfig(
metadata=None,
inference=None,
conversations=None,
prompts=None,
),
),
vector_stores=VectorStoresConfig( vector_stores=VectorStoresConfig(
default_provider_id="faiss", default_provider_id="faiss",
default_embedding_model=QualifiedModel( default_embedding_model=QualifiedModel(