Implementation:Evidentlyai Evidently Legacy Load Snapshots
| Knowledge Sources | |
|---|---|
| Domains | ML Monitoring, Data Management |
| Last Updated | 2026-02-14 12:00 GMT |
Overview
Provides a utility function to load serialized Evidently report/test suite snapshots from a directory, with optional date filtering and error handling.
Description
The load_snapshots function scans a directory for snapshot files and loads each one using Snapshot.load(). It supports optional date range filtering via date_from and date_to parameters, which compare against each snapshot's timestamp attribute. Snapshots outside the specified date range are skipped.
The function also accepts a skip_errors flag. When set to True, any ValidationError raised during deserialization (e.g., from corrupted or incompatible snapshot files) is silently caught and the file is skipped. When False (the default), validation errors propagate as exceptions.
The result is a dictionary mapping SnapshotID to Snapshot objects, which can then be used for displaying historical reports in the Evidently UI workspace or for programmatic analysis of monitoring data over time.
Usage
Use this function when you need to bulk-load previously saved Evidently report or test suite snapshots from a local filesystem directory. This is particularly useful for populating an Evidently workspace dashboard, performing historical analysis of data quality metrics, or migrating snapshots between storage locations.
Code Reference
Source Location
- Repository: Evidentlyai_Evidently
- File:
src/evidently/legacy/experimental/report_set.py
Signature
def load_snapshots(
path: str,
date_from: Optional[datetime.datetime] = None,
date_to: Optional[datetime.datetime] = None,
skip_errors: bool = False,
) -> Dict[SnapshotID, Snapshot]:
...
Import
from evidently.legacy.experimental.report_set import load_snapshots
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| path | str | Yes | Filesystem path to the directory containing snapshot files. |
| date_from | Optional[datetime.datetime] | No | If provided, only snapshots with a timestamp >= this value are included. |
| date_to | Optional[datetime.datetime] | No | If provided, only snapshots with a timestamp <= this value are included. |
| skip_errors | bool | No | If True, silently skip files that raise ValidationError during loading. Defaults to False. |
Outputs
| Name | Type | Description |
|---|---|---|
| return | Dict[SnapshotID, Snapshot] | A dictionary mapping each snapshot's unique ID to its loaded Snapshot object. |
Usage Examples
import datetime
from evidently.legacy.experimental.report_set import load_snapshots
# Load all snapshots from a directory
all_snapshots = load_snapshots("/path/to/snapshots")
# Load snapshots within a date range, skipping corrupted files
snapshots = load_snapshots(
path="/path/to/snapshots",
date_from=datetime.datetime(2025, 1, 1),
date_to=datetime.datetime(2025, 12, 31),
skip_errors=True,
)
# Iterate over loaded snapshots
for snapshot_id, snapshot in snapshots.items():
print(f"Snapshot {snapshot_id}: timestamp={snapshot.timestamp}")