Implementation:Evidentlyai Evidently Legacy UI Local Service
| Knowledge Sources | |
|---|---|
| Domains | UI, Web Service |
| Last Updated | 2026-02-14 12:00 GMT |
Overview
Implements the local service component and default configuration for running the Evidently UI dashboard as a standalone local web service.
Description
The Legacy UI Local Service module provides two key classes:
- LocalServiceComponent -- A ServiceComponent subclass that configures the Litestar application for local operation. It sets up API route handlers for project management (create_projects_api) and general service endpoints (service_api), registers static asset routes (assets_router), and injects project API dependencies. The apply method registers custom exception handlers for EvidentlyServiceError and EvidentlyError, and optionally configures detailed logging when debug mode is enabled. The logging configuration uses GMT-formatted timestamps with structured formatters for default, access, and standard handlers.
- LocalConfig -- A preconfigured AppConfig subclass that provides sensible defaults for local deployment. It uses NoSecurityComponent (no authentication), LocalServiceComponent (local HTTP service), LocalStorageComponent (file-system-based workspace storage), and TelemetryComponent (usage telemetry collection).
The module also includes create_logging which returns a comprehensive logging dictionary configuration for the Uvicorn/Litestar stack, and two exception handler functions (evidently_service_exception_handler and evidently_exception_handler) that convert Evidently exceptions into HTTP responses.
Usage
Use LocalConfig as the default configuration when running the Evidently UI locally. It is the default config type used by app.run_local() and app.get_config(). Subclass LocalServiceComponent or LocalConfig if you need to customize the local service behavior (e.g., adding additional routes, changing security, or enabling debug mode).
Code Reference
Source Location
- Repository: Evidentlyai_Evidently
- File:
src/evidently/legacy/ui/local_service.py
Signature
class LocalServiceComponent(ServiceComponent):
debug: bool = False
def get_api_route_handlers(self, ctx: ComponentContext):
...
def get_dependencies(self, ctx: ComponentContext) -> Dict[str, Provide]:
...
def get_route_handlers(self, ctx: ComponentContext):
...
def apply(self, ctx: ComponentContext, builder: AppBuilder):
...
class LocalConfig(AppConfig):
security: SecurityComponent = NoSecurityComponent()
service: ServiceComponent = LocalServiceComponent()
storage: StorageComponent = LocalStorageComponent()
telemetry: TelemetryComponent = TelemetryComponent()
def create_logging() -> dict:
...
def evidently_service_exception_handler(_: Request, exc: EvidentlyServiceError) -> Response:
...
def evidently_exception_handler(_: Request, exc: EvidentlyError) -> Response:
...
Import
from evidently.legacy.ui.local_service import LocalConfig, LocalServiceComponent, create_logging
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| debug | bool | No | Enable debug mode with detailed logging (default: False) |
| ctx | ComponentContext | Yes (for component methods) | The component context providing access to other components |
| builder | AppBuilder | Yes (for apply) | The application builder to register routes, dependencies, and exception handlers on |
Outputs
| Name | Type | Description |
|---|---|---|
| get_api_route_handlers return | List | List of API route handler functions (projects API and service API) |
| get_route_handlers return | List | List of static asset route handlers |
| get_dependencies return | Dict[str, Provide] | Dictionary of Litestar dependency providers for the service |
| create_logging return | dict | Logging dictionary configuration compatible with Python logging.config.dictConfig |
| LocalConfig instance | AppConfig | A fully configured AppConfig ready for local deployment |
Usage Examples
from evidently.legacy.ui.local_service import LocalConfig, LocalServiceComponent
from evidently.legacy.ui.app import create_app, run
# Use default LocalConfig
config = LocalConfig()
app = create_app(config)
# Enable debug logging
config = LocalConfig(service=LocalServiceComponent(debug=True))
run(config)
# Customize security while keeping local defaults
from evidently.legacy.ui.security.token import TokenSecurityComponent
from evidently._pydantic_compat import SecretStr
config = LocalConfig(security=TokenSecurityComponent(token=SecretStr("my-secret")))
run(config)