Skip to content

Commit 9a82658

Browse files
committed
Update docstring for send_slack_notification()
1 parent e401e09 commit 9a82658

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

pointblank/actions.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,39 @@ def send_slack_notification(
1717
debug: bool = False,
1818
) -> Callable:
1919
"""
20-
Creates a Slack notification function using a webhook URL.
20+
Create a Slack notification function using a webhook URL.
2121
2222
This function can be used in two ways:
2323
24-
1. With `Actions` to notify about individual validation step failures
25-
2. With `FinalActions` to provide a summary after all validation steps complete
24+
1. With [`Actions`](`pointblank.Actions`) to notify about individual validation step failures
25+
2. With [`FinalActions`](`pointblank.FinalActions`) to provide a summary notification after all
26+
validation steps have undergone interrogation
2627
2728
The function creates a callable that sends notifications through a Slack webhook. Message
2829
formatting can be customized using templates for both individual steps and summary reports.
2930
3031
Parameters
3132
----------
3233
webhook_url
33-
The Slack webhook URL. If `None`, performs a dry run.
34+
The Slack webhook URL. If `None` (and `debug=True`), a dry run is performed (see the
35+
*Offline Testing* section below for information on this).
3436
step_msg
3537
Template string for step notifications. Some of the available variables include: `"{step}"`,
3638
`"{column}"`, `"{value}"`, `"{type}"`, `"{time}"`, `"{level}"`, etc. See the *Available
37-
Template Variables for Step Notifications* section below for more details.
39+
Template Variables for Step Notifications* section below for more details. If not provided,
40+
a default step message template will be used.
3841
summary_msg
3942
Template string for summary notifications. Some of the available variables are:
4043
`"{n_steps}"`, `"{n_passing_steps}"`, `"{n_failing_steps}"`, `"{all_passed}"`,
4144
`"{highest_severity}"`, etc. See the *Available Template Variables for Summary
42-
Notifications* section below for more details.
45+
Notifications* section below for more details. If not provided, a default summary message
46+
template will be used.
4347
debug
44-
Print debug information and message previews.
48+
Print debug information if `True`. This includes the message content and the response from
49+
Slack. This is useful for testing and debugging the notification function. If `webhook_url`
50+
is `None`, the function will print the message to the console instead of sending it to
51+
Slack. This is useful for debugging and ensuring that your templates are formatted
52+
correctly.
4553
4654
Returns
4755
-------
@@ -134,7 +142,7 @@ def send_slack_notification(
134142
Offline Testing
135143
---------------
136144
If you want to test the function without sending actual notifications, you can leave the
137-
`webhook_url` as `None` and set `debug=True`. This will print the message to the console
145+
`webhook_url=` as `None` and set `debug=True`. This will print the message to the console
138146
instead of sending it to Slack. This is useful for debugging and ensuring that your templates
139147
are formatted correctly. Furthermore, the function could be run globally (i.e., outside of the
140148
context of a validation plan) to show the message templates with all possible variables. Here's
@@ -188,11 +196,11 @@ def send_slack_notification(
188196
189197
Examples
190198
--------
191-
When using an Action with one or more validation steps, you typically provide callables that
199+
When using an action with one or more validation steps, you typically provide callables that
192200
fire when a matched threshold of failed test units is exceeded. The callable can be
193201
a function or a lambda. The `send_slack_notification()` function creates a callable that sends
194202
a Slack notification when the validation step fails. Here is how it can be set up to work for
195-
multiple validation steps:
203+
multiple validation steps by using of [Actions](`pointblank.Actions`):
196204
197205
```python
198206
import pointblank as pb
@@ -222,9 +230,9 @@ def send_slack_notification(
222230
set here, when 15% or more of the test units fail). The notification will include information
223231
about the validation step that triggered the alert.
224232
225-
When using a `FinalActions` object, the notification will be sent after all validation steps
226-
have been completed. This is useful for providing a summary of the validation process. Here is
227-
an example of how to set up a summary notification:
233+
When using a [`FinalActions`](`pointblank.FinalActions`) object, the notification will be sent
234+
after all validation steps have been completed. This is useful for providing a summary of the
235+
validation process. Here is an example of how to set up a summary notification:
228236
229237
```python
230238
import pointblank as pb
@@ -316,11 +324,10 @@ def send_slack_notification(
316324
```
317325
318326
In this example, we have customized the templates for both step and summary notifications. The
319-
step notification includes details about the validation step, including the step number,
320-
column name, test type, value tested, severity level, brief description, and time of the
321-
notification. The summary notification includes an overview of the validation process,
322-
including the status, number of steps, passing and failing steps, table information, and
323-
timing details.
327+
step notification includes details about the validation step, including the step number, column
328+
name, test type, value tested, severity level, brief description, and time of the notification.
329+
The summary notification includes an overview of the validation process, including the status,
330+
number of steps, passing and failing steps, table information, and timing details.
324331
"""
325332
# Default templates
326333
default_step = """*Data Validation Alert*

0 commit comments

Comments
 (0)