Skip to content

Conversation

@rich-iannone
Copy link
Member

@rich-iannone rich-iannone commented Mar 27, 2025

When defining actions for thresholds, the case may be that:

  1. three thresholds are set
  2. three actions are set (only per threshold level)
  3. all three thresholds are exceeded and all three actions are triggered/executed

Having all three actions fire can result in undesired redundancy (i.e., over-signalling failure) and it's likely more often the case you'll want only the action from the most severe threshold that was exceeded.

This PR solves this by adding the highest_level= parameter to Actions class. It's set to True by default so the less common scenario (the one above) can be accessed with highest_level=False.

Here's an example of its use:

import pointblank as pb

(
     Validate(
         data=pb.load_dataset(dataset="small_table"),
         thresholds=pb.Thresholds(warning=1, error=2, critical=3),
     )
     .col_vals_gt(
         columns="d",
         value=10000,
         actions=pb.Actions(
             warning="W_local", error="E_local", critical="C_local", highest_only=True
         ),
     )
     .interrogate()
)
C_local

With highest_only=False we'd get this in the console:

C_local
E_local
W_local

@rich-iannone rich-iannone marked this pull request as ready for review March 27, 2025 00:38
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 99.03%. Comparing base (b2a910e) to head (b883922).

Files with missing lines Patch % Lines
pointblank/validate.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #124      +/-   ##
==========================================
- Coverage   99.05%   99.03%   -0.03%     
==========================================
  Files          17       17              
  Lines        3603     3610       +7     
==========================================
+ Hits         3569     3575       +6     
- Misses         34       35       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rich-iannone rich-iannone merged commit cb4582d into main Mar 27, 2025
5 checks passed
@rich-iannone rich-iannone deleted the feat-actions-highest-level-only branch March 27, 2025 00:42
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.

3 participants