Implementation:Evidentlyai Evidently Snapshot Export Methods
Appearance
| Knowledge Sources | |
|---|---|
| Domains | ML_Monitoring, Data_Serialization |
| Last Updated | 2026-02-14 12:00 GMT |
Overview
Concrete methods for exporting Evidently Snapshot results to HTML, JSON, and Python dict formats provided by the Evidently library.
Description
The Snapshot class provides three export methods:
- save_html(filename): Writes an interactive HTML report with Plotly visualizations
- json(): Returns a JSON string of metrics and test results
- dict(): Returns a Python dictionary with structure
{"metrics": [...], "tests": [...]}
Additionally, save_json(filename) writes the JSON to a file.
Usage
Call these methods on a Snapshot returned by Report.run() to persist or transmit evaluation results.
Code Reference
Source Location
- Repository: evidently
- File: src/evidently/core/report.py
- Lines: L639-780
Signature
class Snapshot:
def dict(self) -> dict:
"""Returns {"metrics": [...], "tests": [...]} simplified format."""
def json(self) -> str:
"""Returns JSON string of metrics and test results."""
def save_html(self, filename: Union[str, typing.IO]):
"""Saves interactive HTML report to file."""
def save_json(self, filename: Union[str, typing.IO]):
"""Saves JSON to file."""
Import
# Snapshot is returned by Report.run(), no direct import needed
from evidently import Report
snapshot = report.run(data) # Returns Snapshot
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| filename (save_html) | Union[str, IO] | Yes | Output file path or file-like object |
| filename (save_json) | Union[str, IO] | Yes | Output file path or file-like object |
Outputs
| Name | Type | Description |
|---|---|---|
| dict() returns | dict | {"metrics": [...], "tests": [...]} with metric values |
| json() returns | str | JSON string of metrics and test results |
| save_html() | File | Interactive HTML report written to disk |
| save_json() | File | JSON written to disk |
Usage Examples
Export to HTML
snapshot = report.run(current_data, reference_data)
snapshot.save_html("drift_report.html")
Extract Metric Values
snapshot = report.run(current_data, reference_data)
result = snapshot.dict()
# Access individual metric values
for metric in result["metrics"]:
print(metric)
# Access test results
for test in result["tests"]:
print(test)
Store as JSON
import json
snapshot = report.run(current_data, reference_data)
# Get JSON string
json_str = snapshot.json()
# Or save directly to file
snapshot.save_json("results.json")
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment