1+ #!/usr/bin/env python3
2+
3+ """
4+ Purpose: Loads json test files and performs data tests.
5+ """
6+
7+ import sys
8+ import os
9+
10+ project_root_dir = os .path .abspath ("../../.." )
11+ sys .path .append (project_root_dir )
12+ root_dir = "/Workspace/Repos/[email protected] /evidently_implementation" 13+
14+ import pandas as pd
15+ import pytest
16+ import json
17+
18+
19+ @pytest .fixture
20+ def loading_data_quality_json_as_dict () -> dict :
21+ """Returns "Data Quality" results from Evidently.ai lib
22+
23+ Returns:
24+ dict: data quality metrics.
25+ """
26+
27+ file_path = os .path .join (root_dir , "data/output" , "data_quality.json" )
28+
29+ with open (file_path , "r" ) as file :
30+ data = json .load (file )
31+
32+ return data
33+
34+
35+ @pytest .fixture ()
36+ def loading_data_drift_json_as_dict () -> dict :
37+ """Returns "Data Drift" results from Evidently.ai lib
38+
39+ Returns:
40+ dict: data drift metrics.
41+ """
42+
43+ file_path = os .path .join (root_dir , "data/output" , "data_drift.json" )
44+
45+ with open (file_path , "r" ) as file :
46+ data = json .load (file )
47+
48+ return data
49+
50+
51+ @pytest .fixture ()
52+ def loading_target_drift_json_as_dict () -> dict :
53+ """Returns "Target Drift" results from Evidently.ai lib
54+
55+ Returns:
56+ dict: target drift metrics.
57+ """
58+
59+ file_path = os .path .join (root_dir , "data/output" , "target_drift.json" )
60+
61+ with open (file_path , "r" ) as file :
62+ data = json .load (file )
63+
64+ return data
65+
66+
67+ def test_failed_tests_percentage (loading_data_quality_json_as_dict : dict ) -> None :
68+ """Checks whether the amount of failed tests are below 50% of the total tests.
69+
70+ Args:
71+ loading_data_quality (dict): evidently output json info
72+ """
73+
74+ ##### WRITE YOUR CODE HERE
75+
76+
77+ def test_pickup_date_data_drift (loading_data_drift_json_as_dict : dict ) -> None :
78+ """Checks whether the feature dropoff_latitude data drift is above threshold.
79+
80+ Args:
81+ loading_data_drift_json_as_dict (dict): evidently output json info
82+ """
83+
84+ ##### WRITE YOUR CODE HERE
85+
86+
87+ def test_negative_kendall_feature_target_correlation (
88+ loading_target_drift_json_as_dict : dict ,
89+ ) -> None :
90+ """Checks whether any feature in the current dataset has passed the
91+ kendall test for being negatively correlated with the target.
92+
93+ Args:
94+ loading_target_drift_json_as_dict (dict): evidently output json info
95+ """
96+
97+ ##### WRITE YOUR CODE HERE
0 commit comments