mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-14 18:32:37 +00:00
group all server stores under storage.stores
This commit is contained in:
parent
636764c2a1
commit
2bba56a0a8
35 changed files with 806 additions and 503 deletions
|
|
@ -16,6 +16,7 @@ from llama_stack.core.datatypes import (
|
|||
from llama_stack.core.storage.datatypes import (
|
||||
InferenceStoreReference,
|
||||
KVStoreReference,
|
||||
ServerStoresConfig,
|
||||
SqliteKVStoreConfig,
|
||||
SqliteSqlStoreConfig,
|
||||
SqlStoreReference,
|
||||
|
|
@ -24,13 +25,30 @@ from llama_stack.core.storage.datatypes import (
|
|||
|
||||
|
||||
def _base_run_config(**overrides):
|
||||
metadata_reference = overrides.pop(
|
||||
"metadata_reference",
|
||||
KVStoreReference(backend="kv_default", namespace="registry"),
|
||||
)
|
||||
inference_reference = overrides.pop(
|
||||
"inference_reference",
|
||||
InferenceStoreReference(backend="sql_default", table_name="inference"),
|
||||
)
|
||||
conversations_reference = overrides.pop(
|
||||
"conversations_reference",
|
||||
SqlStoreReference(backend="sql_default", table_name="conversations"),
|
||||
)
|
||||
storage = overrides.pop(
|
||||
"storage",
|
||||
StorageConfig(
|
||||
backends={
|
||||
"kv_default": SqliteKVStoreConfig(db_path="/tmp/kv.db"),
|
||||
"sql_default": SqliteSqlStoreConfig(db_path="/tmp/sql.db"),
|
||||
}
|
||||
},
|
||||
stores=ServerStoresConfig(
|
||||
metadata=metadata_reference,
|
||||
inference=inference_reference,
|
||||
conversations=conversations_reference,
|
||||
),
|
||||
),
|
||||
)
|
||||
return StackRunConfig(
|
||||
|
|
@ -39,39 +57,28 @@ def _base_run_config(**overrides):
|
|||
apis=[],
|
||||
providers={},
|
||||
storage=storage,
|
||||
metadata_store=overrides.pop(
|
||||
"metadata_store",
|
||||
KVStoreReference(backend="kv_default", namespace="registry"),
|
||||
),
|
||||
inference_store=overrides.pop(
|
||||
"inference_store",
|
||||
InferenceStoreReference(backend="sql_default", table_name="inference"),
|
||||
),
|
||||
conversations_store=overrides.pop(
|
||||
"conversations_store",
|
||||
SqlStoreReference(backend="sql_default", table_name="conversations"),
|
||||
),
|
||||
**overrides,
|
||||
)
|
||||
|
||||
|
||||
def test_references_require_known_backend():
|
||||
with pytest.raises(ValidationError, match="unknown backend 'missing'"):
|
||||
_base_run_config(metadata_store=KVStoreReference(backend="missing", namespace="registry"))
|
||||
_base_run_config(metadata_reference=KVStoreReference(backend="missing", namespace="registry"))
|
||||
|
||||
|
||||
def test_references_must_match_backend_family():
|
||||
with pytest.raises(ValidationError, match="kv_.* is required"):
|
||||
_base_run_config(metadata_store=KVStoreReference(backend="sql_default", namespace="registry"))
|
||||
_base_run_config(metadata_reference=KVStoreReference(backend="sql_default", namespace="registry"))
|
||||
|
||||
with pytest.raises(ValidationError, match="sql_.* is required"):
|
||||
_base_run_config(
|
||||
inference_store=InferenceStoreReference(backend="kv_default", table_name="inference"),
|
||||
inference_reference=InferenceStoreReference(backend="kv_default", table_name="inference"),
|
||||
)
|
||||
|
||||
|
||||
def test_valid_configuration_passes_validation():
|
||||
config = _base_run_config()
|
||||
assert config.metadata_store.backend == "kv_default"
|
||||
assert config.inference_store.backend == "sql_default"
|
||||
assert config.conversations_store.backend == "sql_default"
|
||||
stores = config.storage.stores
|
||||
assert stores.metadata is not None and stores.metadata.backend == "kv_default"
|
||||
assert stores.inference is not None and stores.inference.backend == "sql_default"
|
||||
assert stores.conversations is not None and stores.conversations.backend == "sql_default"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue