rary directly in your custom pipeline steps, e.g.:from typing_extensions import Annotated  # or `from typing import Annotated` on Python 3.9+

from typing import Tuple

import pandas as pd

from evidently.report import Report

import evidently.metric_preset as metric_preset

from evidently.test_suite import TestSuite

import evidently.test_preset as test_preset

from evidently.pipeline.column_mapping import ColumnMapping

from zenml.types import HTMLString

from zenml import step

@step

def data_profiler(

dataset: pd.DataFrame,

) -> Tuple[

Annotated[str, "report_json"],

Annotated[HTMLString, "report_html"]

]:

"""Custom data profiler step with Evidently

Args:

dataset: a Pandas DataFrame

Returns:

Evidently report generated for the dataset in JSON and HTML format.

"""

# pre-processing (e.g. dataset preparation) can take place here

report = Report(metrics=[metric_preset.DataQualityPreset()])

report.run(

current_data=dataset,

reference_data=dataset,

# post-processing (e.g. interpret results, take actions) can happen here

return report.json(), HTMLString(report.show(mode="inline").data)

@step

def data_tester(

dataset: pd.DataFrame,

) -> Tuple[

Annotated[str, "test_json"],

Annotated[HTMLString, "test_html"]

]:

"""Custom data tester step with Evidently

Args:

dataset: a Pandas DataFrame

Returns:

Evidently test results generated for the dataset in JSON and HTML format.

"""

# pre-processing (e.g. dataset preparation) can take place here

test_suite = TestSuite(metrics=[test_preset.DataQualityTestPreset()])

report.run(

current_data=dataset,

reference_data=dataset,

# post-processing (e.g. interpret results, take actions) can happen here

return test_suite.json(), HTMLString(test_suite.show(mode="inline").data)

Visualizing Evidently Reports

You can view visualizations of the Evidently reports generated by your pipeline steps directly in the ZenML dashboard by clicking on the respective artifact in the pipeline run DAG.