Skip to content

Commit adb4c5c

Browse files
committed
Update api-docs.txt
1 parent 9a82658 commit adb4c5c

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

pointblank/data/api-docs.txt

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7712,31 +7712,39 @@ table information, and timing details.
77127712

77137713
send_slack_notification(webhook_url: 'str | None' = None, step_msg: 'str | None' = None, summary_msg: 'str | None' = None, debug: 'bool' = False) -> 'Callable'
77147714

7715-
Creates a Slack notification function using a webhook URL.
7715+
Create a Slack notification function using a webhook URL.
77167716

77177717
This function can be used in two ways:
77187718

7719-
1. With `Actions` to notify about individual validation step failures
7720-
2. With `FinalActions` to provide a summary after all validation steps complete
7719+
1. With [`Actions`](`pointblank.Actions`) to notify about individual validation step failures
7720+
2. With [`FinalActions`](`pointblank.FinalActions`) to provide a summary notification after all
7721+
validation steps have undergone interrogation
77217722

77227723
The function creates a callable that sends notifications through a Slack webhook. Message
77237724
formatting can be customized using templates for both individual steps and summary reports.
77247725

77257726
Parameters
77267727
----------
77277728
webhook_url
7728-
The Slack webhook URL. If `None`, performs a dry run.
7729+
The Slack webhook URL. If `None` (and `debug=True`), a dry run is performed (see the
7730+
*Offline Testing* section below for information on this).
77297731
step_msg
77307732
Template string for step notifications. Some of the available variables include: `"{step}"`,
77317733
`"{column}"`, `"{value}"`, `"{type}"`, `"{time}"`, `"{level}"`, etc. See the *Available
7732-
Template Variables for Step Notifications* section below for more details.
7734+
Template Variables for Step Notifications* section below for more details. If not provided,
7735+
a default step message template will be used.
77337736
summary_msg
77347737
Template string for summary notifications. Some of the available variables are:
77357738
`"{n_steps}"`, `"{n_passing_steps}"`, `"{n_failing_steps}"`, `"{all_passed}"`,
77367739
`"{highest_severity}"`, etc. See the *Available Template Variables for Summary
7737-
Notifications* section below for more details.
7740+
Notifications* section below for more details. If not provided, a default summary message
7741+
template will be used.
77387742
debug
7739-
Print debug information and message previews.
7743+
Print debug information if `True`. This includes the message content and the response from
7744+
Slack. This is useful for testing and debugging the notification function. If `webhook_url`
7745+
is `None`, the function will print the message to the console instead of sending it to
7746+
Slack. This is useful for debugging and ensuring that your templates are formatted
7747+
correctly.
77407748

77417749
Returns
77427750
-------
@@ -7761,15 +7769,15 @@ send_slack_notification(webhook_url: 'str | None' = None, step_msg: 'str | None'
77617769
Here's an example of how to construct a `step_msg=` template:
77627770

77637771
```python
7764-
step_msg = \"\"\"🚨 *Validation Step Alert*
7772+
step_msg = '''🚨 *Validation Step Alert*
77657773
• Step Number: {step}
77667774
• Column: {column}
77677775
• Test Type: {type}
77687776
• Value Tested: {value}
77697777
• Severity: {level} (level {level_num})
77707778
• Brief: {autobrief}
77717779
• Details: {failure_text}
7772-
• Time: {time}\"\"\"
7780+
• Time: {time}'''
77737781
```
77747782

77757783
This template will be filled with the relevant information when a validation step fails. The
@@ -7799,7 +7807,7 @@ send_slack_notification(webhook_url: 'str | None' = None, step_msg: 'str | None'
77997807
Here's an example of how to put together a `summary_msg=` template:
78007808

78017809
```python
7802-
summary_msg = \"\"\"📊 *Validation Summary Report*
7810+
summary_msg = '''📊 *Validation Summary Report*
78037811
*Overview*
78047812
• Status: {highest_severity}
78057813
• All Passed: {all_passed}
@@ -7819,7 +7827,7 @@ send_slack_notification(webhook_url: 'str | None' = None, step_msg: 'str | None'
78197827

78207828
*Timing*
78217829
• Duration: {validation_duration}s
7822-
• Completed: {time}\"\"\"
7830+
• Completed: {time}'''
78237831
```
78247832

78257833
This template will be filled with the relevant information when the validation summary is
@@ -7829,7 +7837,7 @@ send_slack_notification(webhook_url: 'str | None' = None, step_msg: 'str | None'
78297837
Offline Testing
78307838
---------------
78317839
If you want to test the function without sending actual notifications, you can leave the
7832-
`webhook_url` as `None` and set `debug=True`. This will print the message to the console
7840+
`webhook_url=` as `None` and set `debug=True`. This will print the message to the console
78337841
instead of sending it to Slack. This is useful for debugging and ensuring that your templates
78347842
are formatted correctly. Furthermore, the function could be run globally (i.e., outside of the
78357843
context of a validation plan) to show the message templates with all possible variables. Here's
@@ -7862,17 +7870,17 @@ send_slack_notification(webhook_url: 'str | None' = None, step_msg: 'str | None'
78627870
# Create a Slack notification function with custom templates
78637871
notify_slack = pb.send_slack_notification(
78647872
webhook_url=None, # Leave as None for dry run
7865-
step_msg=\"\"\"*Data Validation Alert*
7873+
step_msg='''*Data Validation Alert*
78667874
• Type: {type}
78677875
• Level: {level}
78687876
• Step: {step}
78697877
• Column: {column}
7870-
• Time: {time}\"\"\",
7871-
summary_msg=\"\"\"*Data Validation Summary*
7878+
• Time: {time}''',
7879+
summary_msg='''*Data Validation Summary*
78727880
• Highest Severity: {highest_severity}
78737881
• Total Steps: {n_steps}
78747882
• Failed Steps: {n_failing_steps}
7875-
• Time: {time}\"\"\",
7883+
• Time: {time}''',
78767884
debug=True, # Enable debug mode to print message previews
78777885
)
78787886
```
@@ -7883,11 +7891,11 @@ send_slack_notification(webhook_url: 'str | None' = None, step_msg: 'str | None'
78837891

78847892
Examples
78857893
--------
7886-
When using an Action with one or more validation steps, you typically provide callables that
7894+
When using an action with one or more validation steps, you typically provide callables that
78877895
fire when a matched threshold of failed test units is exceeded. The callable can be
78887896
a function or a lambda. The `send_slack_notification()` function creates a callable that sends
78897897
a Slack notification when the validation step fails. Here is how it can be set up to work for
7890-
multiple validation steps:
7898+
multiple validation steps by using of [Actions](`pointblank.Actions`):
78917899

78927900
```python
78937901
import pointblank as pb
@@ -7917,9 +7925,10 @@ send_slack_notification(webhook_url: 'str | None' = None, step_msg: 'str | None'
79177925
set here, when 15% or more of the test units fail). The notification will include information
79187926
about the validation step that triggered the alert.
79197927

7920-
When using a `FinalActions` object, the notification will be sent after all validation steps
7921-
have been completed. This is useful for providing a summary of the validation process. Here is
7922-
an example of how to set up a summary notification:
7928+
When using a [`FinalActions`](`pointblank.FinalActions`) object, the notification will be sent
7929+
after all validation steps have been completed. This is useful for providing a summary of the
7930+
validation process. Here is an example of how to set up a summary notification:
7931+
79237932
```python
79247933
import pointblank as pb
79257934

@@ -7960,7 +7969,7 @@ send_slack_notification(webhook_url: 'str | None' = None, step_msg: 'str | None'
79607969

79617970
notify_slack = pb.send_slack_notification(
79627971
webhook_url="https://hooks.slack.com/services/your/webhook/url",
7963-
step_msg=\"\"\"
7972+
step_msg='''
79647973
🚨 *Validation Step Alert*
79657974
• Step Number: {step}
79667975
• Column: {column}
@@ -7969,8 +7978,8 @@ send_slack_notification(webhook_url: 'str | None' = None, step_msg: 'str | None'
79697978
• Severity: {level} (level {level_num})
79707979
• Brief: {autobrief}
79717980
• Details: {failure_text}
7972-
• Time: {time}\"\"\",
7973-
summary_msg=\"\"\"
7981+
• Time: {time}''',
7982+
summary_msg='''
79747983
📊 *Validation Summary Report*
79757984
*Overview*
79767985
• Status: {highest_severity}
@@ -7991,7 +8000,7 @@ send_slack_notification(webhook_url: 'str | None' = None, step_msg: 'str | None'
79918000

79928001
*Timing*
79938002
• Duration: {validation_duration}s
7994-
• Completed: {time}\"\"\",
8003+
• Completed: {time}''',
79958004
)
79968005

79978006
# Create a validation plan
@@ -8010,11 +8019,10 @@ send_slack_notification(webhook_url: 'str | None' = None, step_msg: 'str | None'
80108019
```
80118020

80128021
In this example, we have customized the templates for both step and summary notifications. The
8013-
step notification includes details about the validation step, including the step number,
8014-
column name, test type, value tested, severity level, brief description, and time of the
8015-
notification. The summary notification includes an overview of the validation process,
8016-
including the status, number of steps, passing and failing steps, table information, and
8017-
timing details.
8022+
step notification includes details about the validation step, including the step number, column
8023+
name, test type, value tested, severity level, brief description, and time of the notification.
8024+
The summary notification includes an overview of the validation process, including the status,
8025+
number of steps, passing and failing steps, table information, and timing details.
80188026

80198027

80208028

0 commit comments

Comments
 (0)