ensure everything has sample_run_config

This commit is contained in:
Ashwin Bharambe 2025-03-12 21:28:16 -07:00
parent 36e7bc6fbf
commit c70bbab793
6 changed files with 53 additions and 2 deletions

View file

@ -4,9 +4,18 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import Any, Dict
from pydantic import BaseModel
class SampleConfig(BaseModel):
host: str = "localhost"
port: int = 9999
@classmethod
def sample_run_config(cls, __distro_dir__: str, **kwargs: Any) -> Dict[str, Any]:
return {
"host": "localhost",
"port": 9999,
}

View file

@ -4,9 +4,18 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import Any, Dict
from pydantic import BaseModel
class SampleConfig(BaseModel):
host: str = "localhost"
port: int = 9999
@classmethod
def sample_run_config(cls, __distro_dir__: str, **kwargs: Any) -> Dict[str, Any]:
return {
"host": "localhost",
"port": 9999,
}

View file

@ -4,9 +4,18 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import Any, Dict
from pydantic import BaseModel
class SampleConfig(BaseModel):
host: str = "localhost"
port: int = 9999
@classmethod
def sample_run_config(cls, __distro_dir__: str, **kwargs: Any) -> Dict[str, Any]:
return {
"host": "localhost",
"port": 9999,
}

View file

@ -4,9 +4,18 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import Any, Dict
from pydantic import BaseModel
class SampleConfig(BaseModel):
host: str = "localhost"
port: int = 9999
@classmethod
def sample_run_config(cls, __distro_dir__: str, **kwargs: Any) -> Dict[str, Any]:
return {
"host": "localhost",
"port": 9999,
}

View file

@ -4,9 +4,18 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import Any, Dict
from pydantic import BaseModel
class SampleVectorIOConfig(BaseModel):
host: str = "localhost"
port: int = 9999
@classmethod
def sample_run_config(cls, __distro_dir__: str, **kwargs: Any) -> Dict[str, Any]:
return {
"host": "localhost",
"port": 9999,
}

View file

@ -13,8 +13,9 @@ from llama_stack.distribution.utils.dynamic import instantiate_class_type
def test_all_provider_configs_can_be_instantiated():
"""
Test that all provider configs can be instantiated.
This ensures that all config classes are correctly defined and can be instantiated without errors.
Test that all provider configs can be instantiated "lightly". If a config class ends up
importing the implementation class, this will likely fail because we don't run unit tests
with tons of dependencies.
"""
# Get all provider registries
provider_registry = get_provider_registry()
@ -34,6 +35,11 @@ def test_all_provider_configs_can_be_instantiated():
config_type = instantiate_class_type(config_class_name)
assert issubclass(config_type, BaseModel)
assert hasattr(config_type, "sample_run_config"), (
f"{config_class_name} does not have sample_run_config method"
)
sample_config = config_type.sample_run_config(__distro_dir__="foobarbaz")
assert isinstance(sample_config, dict)
except Exception as e:
failures.append(f"Failed to instantiate {provider_type} config: {str(e)}")