Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test suite dashboard panels #817

Merged
merged 10 commits into from
Oct 24, 2023
Merged

Conversation

mike0sv
Copy link
Collaborator

@mike0sv mike0sv commented Oct 16, 2023

Workspace to test:

import datetime
import os.path
import random
import shutil

import pandas as pd

from evidently.test_suite import TestSuite
from evidently.tests.base_test import TestResult, TestStatus
from evidently.ui.app import run
from evidently.ui.dashboards import DashboardPanelTestSuite, ReportFilter, TestFilter, TestSuitePanelType
from evidently.ui.workspace import Workspace
from evidently.tests.data_quality_tests import TestNumberOfUniqueValues

statuses = [TestStatus.FAIL, TestStatus.ERROR, TestStatus.WARNING, TestStatus.SUCCESS, TestStatus.SKIPPED]


def create_test_suite(date: datetime.datetime):
    df = pd.DataFrame([{"a": 1, "b": 2, "c": 3, "d": 4, "e": 5}])
    ts = TestSuite(timestamp=date, tests=[TestNumberOfUniqueValues(column_name=c) for c in df.columns],
                   tags=["a" if random.randint(0, 1) == 0 else "b"])
    ts.run(reference_data=df, current_data=df)
    ts._inner_suite.context.test_results = {
        TestNumberOfUniqueValues(column_name=c): TestResult(
            name="", description="", status=random.choice(statuses), group=""
        ) for c in df.columns
    }
    return ts


def main():
    if os.path.exists("workspace"):
        shutil.rmtree("workspace")
    ws = Workspace.create("workspace")
    p = ws.create_project("a")
    p.id = "71e77d73-d1a2-4639-8807-ff84800e67c2"
    p.save()

    p.dashboard.add_panel(DashboardPanelTestSuite(
        title="a and b",
        test_filters=[TestFilter(test_id="TestNumberOfUniqueValues", test_args={"column_name.name": "a"}),
                      TestFilter(test_id="TestNumberOfUniqueValues", test_args={"column_name.name": "b"})
                      ],
        filter=ReportFilter(metadata_values={}, tag_values=[], include_test_suites=True)
    ))
    p.dashboard.add_panel(DashboardPanelTestSuite(
        title="all",
        filter=ReportFilter(metadata_values={}, tag_values=[], include_test_suites=True)
    ))
    p.dashboard.add_panel(DashboardPanelTestSuite(
        title="detailed",
        filter=ReportFilter(metadata_values={}, tag_values=[], include_test_suites=True),
        panel_type=TestSuitePanelType.DETAILED
    ))

    for d in range(5):
        p.add_snapshot(create_test_suite(datetime.datetime.now() - datetime.timedelta(days=d)).to_snapshot())

    p.save()


if __name__ == '__main__':
    main()
    run()

@emeli-dral emeli-dral merged commit a544932 into main Oct 24, 2023
18 checks passed
@emeli-dral emeli-dral deleted the feature/test_suite_dashboards branch October 24, 2023 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants