Skip to content

Commit fe361b6

Browse files
authored
[MAINTENANCE] fixed warnings logs (#118)
* feat: updated libs * feat: disable warnings * fix: added handle case then std is zero * fix: ignore warnings for all envs
1 parent c33ab86 commit fe361b6

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

functions/data_test/data_test/data_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
import json
77
from datasource import prepare_final_ds, get_source_name, get_file_extension
88
from loguru import logger
9+
import warnings
910

1011

1112
def handler(event, context):
1213
logger.info("Starting data test")
14+
_ignore_warnings()
1315
if os.environ['ENVIRONMENT'] == 'local':
1416
endpoint_url = (f"http://{os.environ['S3_HOST']}:"
1517
f"{os.environ['S3_PORT']}")
@@ -90,3 +92,12 @@ def handler(event, context):
9092
}
9193
logger.info("Data test is finished successfully")
9294
return report
95+
96+
97+
def _ignore_warnings():
98+
warnings.filterwarnings("ignore", category=FutureWarning)
99+
warnings.filterwarnings("ignore", category=DeprecationWarning)
100+
# issue for this warning
101+
# https://github.com/great-expectations/great_expectations/issues/7338
102+
warnings.filterwarnings("ignore", category=UserWarning,
103+
message="`result_format` configured at the Validator-level")

functions/data_test/data_test/profiling.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,11 @@ def calculate_z_score(summary):
242242
std = summary["std"]
243243
maximum = summary["max"]
244244
significance_level = 0.005
245-
threshold = (maximum - mean) / std
246245
if std and not np.isnan(std):
246+
threshold = (maximum - mean) / std
247247
return threshold + significance_level
248+
else:
249+
return None
248250

249251

250252
def calculate_q_ranges(summary):
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
boto3==1.26.66
22
botocore==1.29.66
33
importlib-metadata==6.0.0
4-
great-expectations==0.16.14
4+
great-expectations==0.17.15
55
s3fs==0.4.2
66
python-dateutil==2.8.2
77
fastparquet==0.8.1
88
awswrangler==2.19.0
9-
ydata-profiling==4.2.0
9+
ydata-profiling==4.5.1
1010
jinja2==3.0.3
1111
loguru==0.7.0

functions/data_test/tests/test_profiling.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ def test_expectations_z_score(mean, std, max, threshold, applied, before_and_aft
205205
assert (expectation_type in str(batch.expectation_suite)) == applied
206206

207207

208+
@pytest.mark.parametrize("summary, expected_result", [
209+
({"mean": 5.0, "std": 2.0, "max": 10.0}, 2.505),
210+
({"mean": 5.0, "std": 0.0, "max": 10.0}, None),
211+
({"mean": 5.0, "std": np.nan, "max": 10.0}, None),
212+
({"mean": 5.0, "std": 2.0, "max": 5.0}, 0.005), ])
213+
def test_calculate_z_score(summary, expected_result):
214+
assert calculate_z_score(summary) == expected_result
215+
216+
208217
@pytest.mark.parametrize("q1,q2,q3,q4,q5,q6",
209218
[(912.85, 996.25, 1100.5, 1204.75, 1288.15, 1309)])
210219
def test_expectations_quantile(q1, q2, q3, q4, q5, q6, before_and_after_test):

0 commit comments

Comments
 (0)