Implementation:Evidentlyai Evidently Legacy Collector Config
| Knowledge Sources | |
|---|---|
| Domains | Collector, Configuration, Data_Monitoring, Legacy |
| Last Updated | 2026-02-14 12:00 GMT |
Overview
legacy/collector/config.py defines the configuration model hierarchy for the Evidently collector service, including trigger strategies, report configurations, collector settings, and the top-level service configuration.
Description
This module provides a layered configuration system:
Base:
Config-- A PydanticBaseModelwithload(path)andsave(path)methods for JSON serialization/deserialization. UsesNumpyEncoderfor safe serialization of numpy types.
Triggers (polymorphic):
CollectorTrigger-- Abstract base for trigger strategies that determine when to create a snapshot. Uses Evidently'sPolymorphicModelfor type-based deserialization.IntervalTrigger-- Fires when a specified time interval (in seconds) has elapsed since the last trigger.RowsCountTrigger-- Fires when the data buffer reaches a specified row count.RowsCountOrIntervalTrigger-- Composite trigger that fires when either the row count or the interval condition is met.
Report Configuration:
ReportConfig-- Holds lists ofMetricandTestinstances,Options, metadata, and tags. Provides factory methodsfrom_reportandfrom_test_suitefor creating configs from existing report/test suite objects, andto_report_basefor reconstructing aReportorTestSuite.
Collector Configuration:
CollectorConfig-- Individual collector settings including ID, trigger, report config, reference data path, workspace connection details (project_id,api_url,api_secret), and cloud detection. Provides lazy-loadedworkspaceproperty that creates either aCloudWorkspaceorRemoteWorkspace. Reference data is loaded from parquet with optional caching.
Service Configuration:
CollectorServiceConfig-- Top-level configuration holding thecheck_interval, a dictionary ofCollectorConfiginstances, aCollectorStoragebackend, andautosaveflag. Includesload_or_defaultfor safe initialization.
Usage
Use these configuration classes to define and manage collector service behavior. They are typically loaded from a JSON file at service startup and can be modified at runtime via the collector REST API.
Code Reference
Source Location
- Repository: Evidentlyai_Evidently
- File:
src/evidently/legacy/collector/config.py
Signature
class Config(BaseModel):
@classmethod
def load(cls, path: str): ...
def save(self, path: str): ...
class CollectorTrigger(PolymorphicModel):
@abc.abstractmethod
def is_ready(self, config: "CollectorConfig", storage: "CollectorStorage") -> bool: ...
class IntervalTrigger(CollectorTrigger):
interval: float
last_triggered: float = 0
def is_ready(self, config, storage) -> bool: ...
class RowsCountTrigger(CollectorTrigger):
rows_count: int = 1
def is_ready(self, config, storage) -> bool: ...
class RowsCountOrIntervalTrigger(CollectorTrigger):
rows_count_trigger: RowsCountTrigger
interval_trigger: IntervalTrigger
def is_ready(self, config, storage) -> bool: ...
class ReportConfig(Config):
metrics: List[Metric]
tests: List[Test]
options: Options
metadata: Dict[str, MetadataValueType]
tags: List[str]
@classmethod
def from_report(cls, report: Report): ...
@classmethod
def from_test_suite(cls, test_suite: TestSuite): ...
def to_report_base(self) -> Union[TestSuite, Report]: ...
class CollectorConfig(Config):
id: str
trigger: CollectorTrigger
report_config: ReportConfig
reference_path: Optional[str]
project_id: str
api_url: str
api_secret: Optional[str]
@property
def workspace(self) -> WorkspaceView: ...
@property
def reference(self) -> Optional[pd.DataFrame]: ...
class CollectorServiceConfig(Config):
check_interval: float = 1
collectors: Dict[str, CollectorConfig]
storage: CollectorStorage
autosave: bool = True
@classmethod
def load_or_default(cls, path: str): ...
Import
from evidently.legacy.collector.config import (
CollectorConfig,
CollectorServiceConfig,
ReportConfig,
IntervalTrigger,
RowsCountTrigger,
RowsCountOrIntervalTrigger,
CONFIG_PATH,
)
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| path | str |
Yes | File path for loading/saving configuration JSON. |
| interval | float |
Yes (IntervalTrigger) | Time interval in seconds between trigger activations. |
| rows_count | int |
No (default 1) | Number of buffered rows required to trigger a snapshot. |
| project_id | str |
Yes (CollectorConfig) | Evidently project ID for uploading snapshots. |
| api_url | str |
No (default "http://localhost:8000") | URL of the Evidently workspace API. |
| api_secret | Optional[str] |
No | API token for authenticated workspace access. |
Outputs
| Name | Type | Description |
|---|---|---|
| Config.load return | Config |
Deserialized configuration instance from a JSON file. |
| is_ready return | bool |
Whether the trigger condition is met. |
| to_report_base return | Union[TestSuite, Report] |
Reconstructed report or test suite from configuration. |
| workspace property | WorkspaceView |
Lazily instantiated workspace (cloud or remote). |
| reference property | Optional[pd.DataFrame] |
Reference data loaded from parquet, optionally cached. |
Usage Examples
from evidently.legacy.collector.config import (
CollectorConfig,
CollectorServiceConfig,
ReportConfig,
IntervalTrigger,
)
from evidently.legacy.report import Report
# Create a report config from an existing report
report = Report(metrics=[...])
report_config = ReportConfig.from_report(report)
# Build a collector config
collector = CollectorConfig(
id="my_collector",
trigger=IntervalTrigger(interval=60.0),
report_config=report_config,
reference_path="reference.parquet",
project_id="my-project-id",
api_url="https://app.evidently.cloud",
api_secret="my-api-token",
)
# Load or create service config
service_config = CollectorServiceConfig.load_or_default("collector_config.json")