Skip to content

Commit 1555e3b

Browse files
committed
Updated documentation for blacklist functionality
1 parent 38fa921 commit 1555e3b

1 file changed

Lines changed: 34 additions & 10 deletions

File tree

python/README.md

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,25 +126,49 @@ set `MY_APP_NO_CONSENT=1`, then again no reports will get sent back.
126126
On the other hand, if the user has set `MY_APP_CONSENT=true` and left `MY_APP_NO_CONSENT` unset or
127127
set to a value other than `1`, Humbug will send you any reports you have configured.
128128

129-
### Blacklist
129+
### Blacklisting parameters in feature reports
130130

131-
There is a possibility to provide custom functions or use predefined at `blacklist.filter_parameters_by_key` for blacklist functionality.
131+
Arguments to functions and other callables can sometimes contain sensitive information which you may
132+
not want to include in Humbug reports.
132133

133-
Just add a list of keys you want to remove from the `feature_report` result and specify the function:
134+
Blacklist functions allow you to specify which parameters from an argument list to filter out of your
135+
feature reports.
136+
137+
#### `blacklist.generate_filter_parameters_by_key_fn`
138+
139+
If you would just like to filter out all paramters with a given name, you can use the `blacklist.generate_filter_parameters_by_key_fn`.
140+
141+
For example, to ignore all parameters named `token` (case insensitive), you would instantiate your
142+
`HumbugReporter` as follows:
134143

135144
```python
136-
reporter = Reporter(
137-
...
138-
blacklist_keys=["private"],
139-
blacklist_fn=blacklist.filter_parameters_by_key,
145+
reporter = HumbugReporter(
146+
...,
147+
blacklist_fn=blacklist.generate_filter_parameters_by_key_fn(["token"]),
148+
)
149+
```
150+
151+
#### Custom blacklist functions
152+
153+
You could also implement a custom blacklist function to remove all parameters that contained the substring
154+
`token` (case insensitive):
155+
156+
```python
157+
def blacklist_token_parameters_fn(params: Dict[str, Any]) -> Dict[str, Any]:
158+
admissible_params = {k:v for k, v in params.items() if "token" not in k}
159+
return admissible_params
160+
161+
reporter = HumbugReporter(
162+
...,
163+
blacklist_fn=blacklist_token_parameters_fn
140164
)
141165
```
142166

143-
### Example: activeloopai/Hub
167+
### Case study: activeloopai/deeplake
144168

145-
[This pull request](https://github.com/activeloopai/Hub/pull/624) shows how
169+
[This pull request](https://github.com/activeloopai/deeplake/pull/624) shows how
146170
[Activeloop](https://www.activeloop.ai/) integrated Humbug into their popular
147-
[`Hub`](https://github.com/activeloopai/Hub) tool.
171+
[`deeplake`](https://github.com/activeloopai/deeplake) tool.
148172

149173
This example shows how to use Humbug to record consent in a configuration file that the user
150174
can modify at will. It also shows how to add custom tags to your Humbug reports.

0 commit comments

Comments
 (0)