Skip to content

Conversation

@rich-iannone
Copy link
Member

This PR adds a new send_slack_notification() function that enables sending validation results to Slack via webhooks. The main features here are:

  • support for both step-level notifications and validation summaries (in one function)
  • customizable message templates for nice message formatting
  • debug mode for testing message formatting
  • complete set of template variables for both step and summary messages
  • error handling and dry-run capabilities

Here's an example of how it generally works:

import pointblank as pb

notify = pb.send_slack_notification(
    webhook_url="https://hooks.slack.com/services/...",
    step_msg="🚨 Step {step}: {failure_text}",
    summary_msg="📊 Summary: {n_failing_steps} of {n_steps} steps failed"
)

validation = (
    pb.Validate(data, 
        actions=pb.Actions(default=notify),
        final_actions=pb.FinalActions(notify)
    )
    .col_vals_gt(...)
    .interrogate()
)

validation

If the user should want to iterate on the template locally, the function can run at top level like this:

```{python}
import pointblank as pb

pb.send_slack_notification(
    step_msg="""🚨 *Validation Step Alert*
• Step Number: {step}
• Column: {column}
• Test Type: {type}
• Value Tested: {value}
• Severity: {level} (level {level_num})
• Brief: {autobrief}
• Details: {failure_text}
• Time: {time}""",
    summary_msg="""📊 *Validation Summary Report*
*Overview*
• Status: {highest_severity}
• All Passed: {all_passed}
• Total Steps: {n_steps}

*Step Results*
• Passing Steps: {n_passing_steps}
• Failing Steps: {n_failing_steps}
• Warning Level: {n_warning_steps}
• Error Level: {n_error_steps}
• Critical Level: {n_critical_steps}

*Table Info*
• Table Name: {tbl_name}
• Row Count: {tbl_row_count}
• Column Count: {tbl_column_count}

*Timing*
• Duration: {validation_duration}s
• Completed: {time}""",
    debug=True
)

Note that webhook_url= is unset (None) and debug=True.

@rich-iannone rich-iannone marked this pull request as ready for review April 8, 2025 21:54
@rich-iannone rich-iannone merged commit cc32071 into main Apr 8, 2025
5 checks passed
@rich-iannone rich-iannone deleted the feat-slack-action branch April 8, 2025 21:54
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.13%. Comparing base (f58865f) to head (a2e28d1).
Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #147   +/-   ##
=======================================
  Coverage   99.13%   99.13%           
=======================================
  Files          17       18    +1     
  Lines        3809     3828   +19     
=======================================
+ Hits         3776     3795   +19     
  Misses         33       33           

☔ 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.

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