Implementation:Evidentlyai Evidently Legacy Options
| Knowledge Sources | |
|---|---|
| Domains | ML Monitoring, Configuration |
| Last Updated | 2026-02-14 12:00 GMT |
Overview
Options is the central configuration container class that aggregates all option types (color, render, data definition, and custom) for configuring Evidently legacy reports and metrics.
Description
The Options class extends BaseModel and serves as the unified options container for the Evidently legacy pipeline. It holds the following fields:
- color (
Optional[ColorOptions]) -- color scheme options for data visualization - render (
Optional[RenderOptions]) -- rendering configuration options - custom (
Dict[Type[Option], Option]) -- a dictionary of custom option objects keyed by their type - data_definition (
Optional[DataDefinitionOptions]) -- data definition configuration
The class provides several convenience properties that return default instances when no explicit option is set:
color_options-- returns the color options or a defaultColorOptions()render_options-- returns the render options or a defaultRenderOptions()data_definition_options-- returns the data definition options or a defaultDataDefinitionOptions()
Key methods include:
- get(option_type) -- retrieves an option by type, checking first the known fields, then the custom dict (including subclass matching), and falling back to a default instance
- from_list(values) -- class method that creates an
Optionsinstance from a list ofOptionobjects, automatically routing each to the appropriate field or the custom dict - from_any_options(options) -- class method that normalizes various input formats (dict, single Option, list of Options, or Options instance) into an
Optionsobject - override(other) -- merges another
Optionsinstance, with the other's non-None values taking precedence - dict(...) -- overrides the Pydantic
dict()method to always exclude thecustomfield (since it is not JSON-serializable)
The module also defines:
- _option_cls_mapping -- an auto-generated mapping from option types to field names
- AnyOptions -- a type alias representing all accepted option input formats:
Union[Options, Option, dict, List[Option], None]
Usage
Use the Options class to configure reports, metrics, and renderers in the Evidently legacy API. It provides a flexible interface for passing configuration in multiple formats.
Code Reference
Source Location
- Repository: Evidentlyai_Evidently
- File:
src/evidently/legacy/options/base.py
Signature
class Options(BaseModel):
color: Optional[ColorOptions] = None
render: Optional[RenderOptions] = None
custom: Dict[Type[Option], Option] = {}
data_definition: Optional[DataDefinitionOptions] = None
@property
def color_options(self) -> ColorOptions: ...
@property
def render_options(self) -> RenderOptions: ...
@property
def data_definition_options(self) -> DataDefinitionOptions: ...
def get(self, option_type: Type[TypeParam]) -> TypeParam: ...
@classmethod
def from_list(cls, values: List[Option]) -> "Options": ...
@classmethod
def from_any_options(cls, options: "AnyOptions") -> "Options": ...
def override(self, other: "Options") -> "Options": ...
def dict(self, *, include=None, exclude=None, ...) -> "DictStrAny": ...
AnyOptions = Union[Options, Option, dict, List[Option], None]
Import
from evidently.legacy.options.base import Options, AnyOptions
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| color | Optional[ColorOptions] |
No | Color scheme options for visualization. |
| render | Optional[RenderOptions] |
No | Rendering configuration options. |
| custom | Dict[Type[Option], Option] |
No | Dictionary of custom option objects. Defaults to empty dict. |
| data_definition | Optional[DataDefinitionOptions] |
No | Data definition options. |
Outputs
| Name | Type | Description |
|---|---|---|
| Options | Options |
A unified options container that can be passed to metrics, reports, and renderers. |
Usage Examples
from evidently.legacy.options.base import Options
from evidently.legacy.options import ColorOptions
# Create options with custom color scheme
options = Options(color=ColorOptions(primary_color="#0000ff"))
# Create options from a list of Option objects
options = Options.from_list([ColorOptions(primary_color="#ff0000")])
# Create options from any supported format
options = Options.from_any_options({"color": {"primary_color": "#00ff00"}})
# Retrieve a specific option type
color_opts = options.get(ColorOptions)
# Override options
base_options = Options(color=ColorOptions(primary_color="#0000ff"))
override_options = Options(color=ColorOptions(primary_color="#ff0000"))
merged = base_options.override(override_options)