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 # This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree. # the root directory of this source tree.
from typing import Any, Dict
from pydantic import BaseModel from pydantic import BaseModel
class SampleConfig(BaseModel): class SampleConfig(BaseModel):
host: str = "localhost" host: str = "localhost"
port: int = 9999 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 # This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree. # the root directory of this source tree.
from typing import Any, Dict
from pydantic import BaseModel from pydantic import BaseModel
class SampleConfig(BaseModel): class SampleConfig(BaseModel):
host: str = "localhost" host: str = "localhost"
port: int = 9999 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 # This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree. # the root directory of this source tree.
from typing import Any, Dict
from pydantic import BaseModel from pydantic import BaseModel
class SampleConfig(BaseModel): class SampleConfig(BaseModel):
host: str = "localhost" host: str = "localhost"
port: int = 9999 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 # This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree. # the root directory of this source tree.
from typing import Any, Dict
from pydantic import BaseModel from pydantic import BaseModel
class SampleConfig(BaseModel): class SampleConfig(BaseModel):
host: str = "localhost" host: str = "localhost"
port: int = 9999 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 # This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree. # the root directory of this source tree.
from typing import Any, Dict
from pydantic import BaseModel from pydantic import BaseModel
class SampleVectorIOConfig(BaseModel): class SampleVectorIOConfig(BaseModel):
host: str = "localhost" host: str = "localhost"
port: int = 9999 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(): def test_all_provider_configs_can_be_instantiated():
""" """
Test that all provider configs can be instantiated. Test that all provider configs can be instantiated "lightly". If a config class ends up
This ensures that all config classes are correctly defined and can be instantiated without errors. importing the implementation class, this will likely fail because we don't run unit tests
with tons of dependencies.
""" """
# Get all provider registries # Get all provider registries
provider_registry = get_provider_registry() 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) config_type = instantiate_class_type(config_class_name)
assert issubclass(config_type, BaseModel) 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: except Exception as e:
failures.append(f"Failed to instantiate {provider_type} config: {str(e)}") failures.append(f"Failed to instantiate {provider_type} config: {str(e)}")