Implementation:Evidentlyai Evidently Legacy UI Config
| Knowledge Sources | |
|---|---|
| Domains | Configuration, UI |
| Last Updated | 2026-02-14 12:00 GMT |
Overview
Defines the configuration system for the Evidently legacy UI, including component context management, configuration loading from Dynaconf settings, and application configuration models.
Description
The Legacy UI Config module provides the core configuration infrastructure for the Evidently UI application. It centers around the following key classes:
- ConfigContext -- Implements ComponentContext and serves as the runtime context during application startup. It manages a mapping of component types to their instances, provides methods to retrieve components by type (get_component), collect dependencies (get_dependencies), collect middlewares (get_middlewares), apply components to an AppBuilder (apply), finalize a Litestar app (finalize), and validate that all component requirements are satisfied (validate). Components are sorted by priority (highest first).
- Config -- A Pydantic BaseModel that serves as the base configuration class. It discovers Component instances from its own fields and from an additional_components dictionary. The context context manager creates a ConfigContext, validates it, and yields it for use during app construction.
- AppConfig -- Extends Config with required security (SecurityComponent) and service (ServiceComponent) fields.
- load_config -- Parses a Dynaconf settings dictionary (or DynaBox) into a typed Config subclass. It handles named fields, additional_components, and section-to-component-type mapping via SECTION_COMPONENT_TYPE_MAPPING.
- load_config_from_file -- Loads configuration from a file path using Dynaconf, with support for environment variable prefixes (default: "EVIDENTLY").
- settings -- A module-level Dynaconf instance with the "EVIDENTLY" prefix, used as the global settings store.
Usage
Use this module when bootstrapping the Evidently UI application. Create or load an AppConfig (or subclass) via load_config or load_config_from_file, then use its context() context manager to obtain a ConfigContext for building the application. The configuration system supports both file-based and environment-variable-based settings through Dynaconf.
Code Reference
Source Location
- Repository: Evidentlyai_Evidently
- File:
src/evidently/legacy/ui/config.py
Signature
class ConfigContext(ComponentContext):
def __init__(self, config: "Config", components_mapping: Dict[Type[Component], Component]):
...
def get_component(self, type_: Type[T]) -> T:
...
def get_dependencies(self) -> Dict[str, Provide]:
...
def get_middlewares(self):
...
def apply(self, builder: AppBuilder):
...
def finalize(self, app: Litestar):
...
def validate(self):
...
class Config(BaseModel):
additional_components: Dict[str, Component] = {}
@property
def components(self) -> List[Component]:
...
def context(self) -> Iterator[ConfigContext]:
...
class AppConfig(Config):
security: SecurityComponent
service: ServiceComponent
def load_config(config_type: Type[TConfig], box: dict) -> TConfig:
...
def load_config_from_file(cls: Type[TConfig], path: str, envvar_prefix: str = "EVIDENTLY") -> TConfig:
...
settings = dynaconf.Dynaconf(envvar_prefix="EVIDENTLY")
Import
from evidently.legacy.ui.config import AppConfig, Config, ConfigContext, load_config, load_config_from_file, settings
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config_type | Type[TConfig] | Yes (for load_config) | The target Config subclass to instantiate |
| box | dict | Yes (for load_config) | A Dynaconf settings dictionary or DynaBox with section keys mapping to component configs |
| path | str | Yes (for load_config_from_file) | File path to a configuration file (YAML, TOML, etc.) |
| envvar_prefix | str | No | Environment variable prefix for Dynaconf (default: "EVIDENTLY") |
| security | SecurityComponent | Yes (for AppConfig) | Security component configuration |
| service | ServiceComponent | Yes (for AppConfig) | Service component configuration (host, port, etc.) |
| additional_components | Dict[str, Component] | No | Extra components keyed by section name |
Outputs
| Name | Type | Description |
|---|---|---|
| load_config return | TConfig | An instantiated Config subclass populated from the settings dictionary |
| load_config_from_file return | TConfig | An instantiated Config subclass loaded from a file |
| Config.context() yield | ConfigContext | A validated component context for building the application |
Usage Examples
from evidently.legacy.ui.config import AppConfig, load_config_from_file, settings, load_config
from evidently.legacy.ui.local_service import LocalConfig
# Load config from a file
config = load_config_from_file(LocalConfig, "config.yaml")
# Load config from Dynaconf settings
settings.configure(settings_module="settings.toml")
config = load_config(LocalConfig, settings)
# Use the configuration context
with config.context() as ctx:
component = ctx.get_component(StorageComponent)
deps = ctx.get_dependencies()