Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Evidentlyai Evidently Legacy Collector Config

From Leeroopedia
Revision as of 12:28, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Evidentlyai_Evidently_Legacy_Collector_Config.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 Pydantic BaseModel with load(path) and save(path) methods for JSON serialization/deserialization. Uses NumpyEncoder for safe serialization of numpy types.

Triggers (polymorphic):

  • CollectorTrigger -- Abstract base for trigger strategies that determine when to create a snapshot. Uses Evidently's PolymorphicModel for 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 of Metric and Test instances, Options, metadata, and tags. Provides factory methods from_report and from_test_suite for creating configs from existing report/test suite objects, and to_report_base for reconstructing a Report or TestSuite.

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-loaded workspace property that creates either a CloudWorkspace or RemoteWorkspace. Reference data is loaded from parquet with optional caching.

Service Configuration:

  • CollectorServiceConfig -- Top-level configuration holding the check_interval, a dictionary of CollectorConfig instances, a CollectorStorage backend, and autosave flag. Includes load_or_default for 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

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")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment