From b0cc00e490f3b8a379cce1d203f1cd9e049a1d2f Mon Sep 17 00:00:00 2001 From: Omar Abdelwahab Date: Mon, 15 Sep 2025 16:55:59 -0700 Subject: [PATCH] ran pre-commit --- llama_stack/core/store/registry.py | 40 ++++++++---------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/llama_stack/core/store/registry.py b/llama_stack/core/store/registry.py index ddb863349..6a81d1eae 100644 --- a/llama_stack/core/store/registry.py +++ b/llama_stack/core/store/registry.py @@ -31,9 +31,7 @@ class DistributionRegistry(Protocol): def get_cached(self, identifier: str) -> RoutableObjectWithProvider | None: ... - async def update( - self, obj: RoutableObjectWithProvider - ) -> RoutableObjectWithProvider: ... + async def update(self, obj: RoutableObjectWithProvider) -> RoutableObjectWithProvider: ... async def register(self, obj: RoutableObjectWithProvider) -> bool: ... @@ -59,9 +57,7 @@ def _parse_registry_values(values: list[str]) -> list[RoutableObjectWithProvider obj = pydantic.TypeAdapter(RoutableObjectWithProvider).validate_json(value) all_objects.append(obj) except pydantic.ValidationError as e: - logger.error( - f"Error parsing registry value, raw value: {value}. Error: {e}" - ) + logger.error(f"Error parsing registry value, raw value: {value}. Error: {e}") continue return all_objects @@ -74,9 +70,7 @@ class DiskDistributionRegistry(DistributionRegistry): async def initialize(self) -> None: pass - def get_cached( - self, type: str, identifier: str - ) -> RoutableObjectWithProvider | None: + def get_cached(self, type: str, identifier: str) -> RoutableObjectWithProvider | None: # Disk registry does not have a cache raise NotImplementedError("Disk registry does not have a cache") @@ -85,23 +79,15 @@ class DiskDistributionRegistry(DistributionRegistry): values = await self.kvstore.values_in_range(start_key, end_key) return _parse_registry_values(values) - async def get( - self, type: str, identifier: str - ) -> RoutableObjectWithProvider | None: - json_str = await self.kvstore.get( - KEY_FORMAT.format(type=type, identifier=identifier) - ) + async def get(self, type: str, identifier: str) -> RoutableObjectWithProvider | None: + json_str = await self.kvstore.get(KEY_FORMAT.format(type=type, identifier=identifier)) if not json_str: return None try: - return pydantic.TypeAdapter(RoutableObjectWithProvider).validate_json( - json_str - ) + return pydantic.TypeAdapter(RoutableObjectWithProvider).validate_json(json_str) except pydantic.ValidationError as e: - logger.error( - f"Error parsing registry value for {type}:{identifier}, raw value: {json_str}. Error: {e}" - ) + logger.error(f"Error parsing registry value for {type}:{identifier}, raw value: {json_str}. Error: {e}") return None async def update(self, obj: RoutableObjectWithProvider) -> None: @@ -166,9 +152,7 @@ class CachedDiskDistributionRegistry(DiskDistributionRegistry): async def initialize(self) -> None: await self._ensure_initialized() - def get_cached( - self, type: str, identifier: str - ) -> RoutableObjectWithProvider | None: + def get_cached(self, type: str, identifier: str) -> RoutableObjectWithProvider | None: return self.cache.get((type, identifier), None) async def get_all(self) -> list[RoutableObjectWithProvider]: @@ -176,9 +160,7 @@ class CachedDiskDistributionRegistry(DiskDistributionRegistry): async with self._locked_cache() as cache: return list(cache.values()) - async def get( - self, type: str, identifier: str - ) -> RoutableObjectWithProvider | None: + async def get(self, type: str, identifier: str) -> RoutableObjectWithProvider | None: await self._ensure_initialized() cache_key = (type, identifier) @@ -220,9 +202,7 @@ async def create_dist_registry( dist_kvstore = await kvstore_impl(metadata_store) else: dist_kvstore = await kvstore_impl( - SqliteKVStoreConfig( - db_path=(DISTRIBS_BASE_DIR / image_name / "kvstore.db").as_posix() - ) + SqliteKVStoreConfig(db_path=(DISTRIBS_BASE_DIR / image_name / "kvstore.db").as_posix()) ) dist_registry = CachedDiskDistributionRegistry(dist_kvstore) await dist_registry.initialize()