Skip to content

Commit b372ad0

Browse files
authored
Merge pull request #128 from posit-dev/feat-global-brief-setting
feat: add global setting option for `brief=`
2 parents 09d9aef + eb5c763 commit b372ad0

File tree

3 files changed

+387
-38
lines changed

3 files changed

+387
-38
lines changed

pointblank/validate.py

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,12 @@ class Validate:
17921792
The actions to take when validation steps meet or exceed any set threshold levels. This
17931793
should be provided in the form of an `Actions` object. If `None` then no default actions
17941794
will be set.
1795+
brief
1796+
A global setting for briefs, which are optional brief descriptions for validation steps
1797+
(they be displayed in the reporting table). For such a global setting, templating elements
1798+
like `"{step}"` (to insert the step number) or `"{auto}"` (to include an automatically
1799+
generated brief) are useful. If `True` then each brief will be automatically generated. If
1800+
`None` (the default) then briefs aren't globally set.
17951801
lang
17961802
The language to use for automatic creation of briefs (short descriptions for each validation
17971803
step). By default, `None` will create English (`"en"`) text. Other options include French
@@ -1906,6 +1912,7 @@ class Validate:
19061912
label: str | None = None
19071913
thresholds: int | float | bool | tuple | dict | Thresholds | None = None
19081914
actions: Actions | None = None
1915+
brief: str | bool | None = None
19091916
lang: str | None = None
19101917
locale: str | None = None
19111918

@@ -1924,6 +1931,9 @@ def __post_init__(self):
19241931
if self.locale is None:
19251932
self.locale = self.lang
19261933

1934+
# Transform any shorthands of `brief` to string representations
1935+
self.brief = _transform_auto_brief(brief=self.brief)
1936+
19271937
# TODO: Add functionality to obtain the column names and types from the table
19281938
self.col_names = None
19291939
self.col_types = None
@@ -2089,8 +2099,8 @@ def col_vals_gt(
20892099
if isinstance(columns, (Column, str)):
20902100
columns = [columns]
20912101

2092-
# Transform any shorthands of `brief=` to string representations
2093-
brief = _transform_auto_brief(brief=brief)
2102+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
2103+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
20942104

20952105
# Iterate over the columns and create a validation step for each
20962106
for column in columns:
@@ -2262,8 +2272,8 @@ def col_vals_lt(
22622272
if isinstance(columns, (Column, str)):
22632273
columns = [columns]
22642274

2265-
# Transform any shorthands of `brief=` to string representations
2266-
brief = _transform_auto_brief(brief=brief)
2275+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
2276+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
22672277

22682278
# Iterate over the columns and create a validation step for each
22692279
for column in columns:
@@ -2434,8 +2444,8 @@ def col_vals_eq(
24342444
if isinstance(columns, (Column, str)):
24352445
columns = [columns]
24362446

2437-
# Transform any shorthands of `brief=` to string representations
2438-
brief = _transform_auto_brief(brief=brief)
2447+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
2448+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
24392449

24402450
# Iterate over the columns and create a validation step for each
24412451
for column in columns:
@@ -2604,8 +2614,8 @@ def col_vals_ne(
26042614
if isinstance(columns, (Column, str)):
26052615
columns = [columns]
26062616

2607-
# Transform any shorthands of `brief=` to string representations
2608-
brief = _transform_auto_brief(brief=brief)
2617+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
2618+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
26092619

26102620
# Iterate over the columns and create a validation step for each
26112621
for column in columns:
@@ -2778,8 +2788,8 @@ def col_vals_ge(
27782788
if isinstance(columns, (Column, str)):
27792789
columns = [columns]
27802790

2781-
# Transform any shorthands of `brief=` to string representations
2782-
brief = _transform_auto_brief(brief=brief)
2791+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
2792+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
27832793

27842794
# Iterate over the columns and create a validation step for each
27852795
for column in columns:
@@ -2952,8 +2962,8 @@ def col_vals_le(
29522962
if isinstance(columns, (Column, str)):
29532963
columns = [columns]
29542964

2955-
# Transform any shorthands of `brief=` to string representations
2956-
brief = _transform_auto_brief(brief=brief)
2965+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
2966+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
29572967

29582968
# Iterate over the columns and create a validation step for each
29592969
for column in columns:
@@ -3149,8 +3159,8 @@ def col_vals_between(
31493159
if isinstance(columns, (Column, str)):
31503160
columns = [columns]
31513161

3152-
# Transform any shorthands of `brief=` to string representations
3153-
brief = _transform_auto_brief(brief=brief)
3162+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
3163+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
31543164

31553165
# Iterate over the columns and create a validation step for each
31563166
for column in columns:
@@ -3350,8 +3360,8 @@ def col_vals_outside(
33503360
if isinstance(columns, (Column, str)):
33513361
columns = [columns]
33523362

3353-
# Transform any shorthands of `brief=` to string representations
3354-
brief = _transform_auto_brief(brief=brief)
3363+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
3364+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
33553365

33563366
# Iterate over the columns and create a validation step for each
33573367
for column in columns:
@@ -3510,8 +3520,8 @@ def col_vals_in_set(
35103520
if isinstance(columns, (Column, str)):
35113521
columns = [columns]
35123522

3513-
# Transform any shorthands of `brief=` to string representations
3514-
brief = _transform_auto_brief(brief=brief)
3523+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
3524+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
35153525

35163526
# Iterate over the columns and create a validation step for each
35173527
for column in columns:
@@ -3669,8 +3679,8 @@ def col_vals_not_in_set(
36693679
if isinstance(columns, (Column, str)):
36703680
columns = [columns]
36713681

3672-
# Transform any shorthands of `brief=` to string representations
3673-
brief = _transform_auto_brief(brief=brief)
3682+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
3683+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
36743684

36753685
# Iterate over the columns and create a validation step for each
36763686
for column in columns:
@@ -3820,8 +3830,8 @@ def col_vals_null(
38203830
if isinstance(columns, (Column, str)):
38213831
columns = [columns]
38223832

3823-
# Transform any shorthands of `brief=` to string representations
3824-
brief = _transform_auto_brief(brief=brief)
3833+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
3834+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
38253835

38263836
# Iterate over the columns and create a validation step for each
38273837
for column in columns:
@@ -3970,8 +3980,8 @@ def col_vals_not_null(
39703980
if isinstance(columns, (Column, str)):
39713981
columns = [columns]
39723982

3973-
# Transform any shorthands of `brief=` to string representations
3974-
brief = _transform_auto_brief(brief=brief)
3983+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
3984+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
39753985

39763986
# Iterate over the columns and create a validation step for each
39773987
for column in columns:
@@ -4131,8 +4141,8 @@ def col_vals_regex(
41314141
if isinstance(columns, (Column, str)):
41324142
columns = [columns]
41334143

4134-
# Transform any shorthands of `brief=` to string representations
4135-
brief = _transform_auto_brief(brief=brief)
4144+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
4145+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
41364146

41374147
# Iterate over the columns and create a validation step for each
41384148
for column in columns:
@@ -4263,8 +4273,8 @@ def col_vals_expr(
42634273
self.thresholds if thresholds is None else _normalize_thresholds_creation(thresholds)
42644274
)
42654275

4266-
# Transform any shorthands of `brief=` to string representations
4267-
brief = _transform_auto_brief(brief=brief)
4276+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
4277+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
42684278

42694279
val_info = _ValidationInfo(
42704280
assertion_type=assertion_type,
@@ -4409,8 +4419,8 @@ def col_exists(
44094419
if isinstance(columns, (Column, str)):
44104420
columns = [columns]
44114421

4412-
# Transform any shorthands of `brief=` to string representations
4413-
brief = _transform_auto_brief(brief=brief)
4422+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
4423+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
44144424

44154425
# Iterate over the columns and create a validation step for each
44164426
for column in columns:
@@ -4559,8 +4569,8 @@ def rows_distinct(
45594569

45604570
# TODO: incorporate Column object
45614571

4562-
# Transform any shorthands of `brief=` to string representations
4563-
brief = _transform_auto_brief(brief=brief)
4572+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
4573+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
45644574

45654575
val_info = _ValidationInfo(
45664576
assertion_type=assertion_type,
@@ -4741,8 +4751,8 @@ def col_schema_match(
47414751
"full_match_dtypes": full_match_dtypes,
47424752
}
47434753

4744-
# Transform any shorthands of `brief=` to string representations
4745-
brief = _transform_auto_brief(brief=brief)
4754+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
4755+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
47464756

47474757
val_info = _ValidationInfo(
47484758
assertion_type=assertion_type,
@@ -4918,8 +4928,8 @@ def row_count_match(
49184928
# Package up the `count=` and boolean params into a dictionary for later interrogation
49194929
values = {"count": count, "inverse": inverse, "abs_tol_bounds": bounds}
49204930

4921-
# Transform any shorthands of `brief=` to string representations
4922-
brief = _transform_auto_brief(brief=brief)
4931+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
4932+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
49234933

49244934
val_info = _ValidationInfo(
49254935
assertion_type=assertion_type,
@@ -5052,8 +5062,8 @@ def col_count_match(
50525062
# Package up the `count=` and boolean params into a dictionary for later interrogation
50535063
values = {"count": count, "inverse": inverse}
50545064

5055-
# Transform any shorthands of `brief=` to string representations
5056-
brief = _transform_auto_brief(brief=brief)
5065+
# Determine brief to use (global or local) and transform any shorthands of `brief=`
5066+
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)
50575067

50585068
val_info = _ValidationInfo(
50595069
assertion_type=assertion_type,

0 commit comments

Comments
 (0)