mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-15 17:12:39 +00:00
simplified some, walked back some decisions
This commit is contained in:
parent
af7472cdb0
commit
636764c2a1
90 changed files with 887 additions and 570 deletions
|
|
@ -1,3 +1,9 @@
|
|||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the terms described in the LICENSE file in
|
||||
# the root directory of this source tree.
|
||||
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
# All rights reserved.
|
||||
# This source code is licensed under the terms described in the LICENSE file in
|
||||
|
|
@ -47,36 +53,19 @@ class InmemoryKVStoreImpl(KVStore):
|
|||
|
||||
|
||||
_KVSTORE_BACKENDS: dict[str, KVStoreConfig] = {}
|
||||
_KVSTORE_DEFAULT_BACKEND: str | None = None
|
||||
|
||||
|
||||
def register_kvstore_backends(backends: dict[str, StorageBackendConfig]) -> None:
|
||||
"""Register the set of available KV store backends for reference resolution."""
|
||||
global _KVSTORE_BACKENDS
|
||||
|
||||
def _set_default_backend(name: str) -> None:
|
||||
global _KVSTORE_DEFAULT_BACKEND
|
||||
if _KVSTORE_DEFAULT_BACKEND and _KVSTORE_DEFAULT_BACKEND != name:
|
||||
raise ValueError(
|
||||
f"Multiple KVStore backends marked as default: '{_KVSTORE_DEFAULT_BACKEND}' and '{name}'. "
|
||||
"Only one backend can be the default."
|
||||
)
|
||||
_KVSTORE_DEFAULT_BACKEND = name
|
||||
|
||||
_KVSTORE_BACKENDS.clear()
|
||||
for name, cfg in backends.items():
|
||||
if cfg.default:
|
||||
_set_default_backend(name)
|
||||
_KVSTORE_BACKENDS[name] = cfg
|
||||
|
||||
|
||||
async def kvstore_impl(reference: KVStoreReference) -> KVStore:
|
||||
backend_name = reference.backend or _KVSTORE_DEFAULT_BACKEND
|
||||
if not backend_name:
|
||||
raise ValueError(
|
||||
"KVStore reference did not specify a backend and no default backend is configured. "
|
||||
f"Available backends: {sorted(_KVSTORE_BACKENDS)}"
|
||||
)
|
||||
backend_name = reference.backend
|
||||
|
||||
backend_config = _KVSTORE_BACKENDS.get(backend_name)
|
||||
if backend_config is None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue