Skip to content

Commit 2cc884f

Browse files
Address PR review: fix month arithmetic, add detailed skip comments for Redshift/Dremio
Co-Authored-By: Yosef Arbiv <yosef.arbiv@gmail.com>
1 parent 02b5f56 commit 2cc884f

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

integration_tests/tests/test_column_anomalies.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,11 @@ def test_col_anom_excl_detect_train(test_id: str, dbt_project: DbtProject):
580580
)
581581

582582

583+
# Redshift and Dremio are skipped because their floating-point stddev/avg computations
584+
# produce slightly different z-scores than other engines. With monthly buckets the margin
585+
# between "absorbed anomaly passes" and "excluded anomaly fails" is narrow enough that
586+
# these engines' z-score differences cause the "without exclusion" case to also flag
587+
# as anomalous, making the test flaky.
583588
@pytest.mark.skip_targets(["clickhouse", "redshift", "dremio"])
584589
def test_col_excl_detect_train_monthly(test_id: str, dbt_project: DbtProject):
585590
"""
@@ -604,8 +609,12 @@ def test_col_excl_detect_train_monthly(test_id: str, dbt_project: DbtProject):
604609
utc_now = datetime.utcnow().date()
605610
current_month_1st = utc_now.replace(day=1)
606611

607-
anomaly_month_start = (current_month_1st - timedelta(days=31)).replace(day=1)
608-
normal_month_start = (anomaly_month_start - timedelta(days=365)).replace(day=1)
612+
anomaly_month_start = (current_month_1st - timedelta(days=1)).replace(day=1)
613+
normal_month_start = (
614+
(anomaly_month_start - timedelta(days=1))
615+
.replace(day=1)
616+
.replace(year=anomaly_month_start.year - 1)
617+
)
609618

610619
normal_data: List[Dict[str, Any]] = []
611620
day = normal_month_start

integration_tests/tests/test_volume_anomalies.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,11 @@ def test_exclude_detection_from_training(test_id: str, dbt_project: DbtProject):
621621
), "Test should fail when anomaly is excluded from training"
622622

623623

624+
# Redshift and Dremio are skipped because their floating-point stddev/avg computations
625+
# produce slightly different z-scores than other engines. With monthly buckets the margin
626+
# between "absorbed anomaly passes" and "excluded anomaly fails" is narrow enough that
627+
# these engines' z-score differences cause the "without exclusion" case to also flag
628+
# as anomalous, making the test flaky.
624629
@pytest.mark.skip_targets(["clickhouse", "redshift", "dremio"])
625630
def test_excl_detect_train_monthly(test_id: str, dbt_project: DbtProject):
626631
"""
@@ -647,8 +652,12 @@ def test_excl_detect_train_monthly(test_id: str, dbt_project: DbtProject):
647652
day=1, hour=0, minute=0, second=0, microsecond=0
648653
)
649654

650-
anomaly_month_start = (current_month_1st - timedelta(days=31)).replace(day=1)
651-
normal_month_start = (anomaly_month_start - timedelta(days=365)).replace(day=1)
655+
anomaly_month_start = (current_month_1st - timedelta(days=1)).replace(day=1)
656+
normal_month_start = (
657+
(anomaly_month_start - timedelta(days=1))
658+
.replace(day=1)
659+
.replace(year=anomaly_month_start.year - 1)
660+
)
652661

653662
normal_data = []
654663
day = normal_month_start

0 commit comments

Comments
 (0)