Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 48 additions & 38 deletions pointblank/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,12 @@ class Validate:
The actions to take when validation steps meet or exceed any set threshold levels. This
should be provided in the form of an `Actions` object. If `None` then no default actions
will be set.
brief
A global setting for briefs, which are optional brief descriptions for validation steps
(they be displayed in the reporting table). For such a global setting, templating elements
like `"{step}"` (to insert the step number) or `"{auto}"` (to include an automatically
generated brief) are useful. If `True` then each brief will be automatically generated. If
`None` (the default) then briefs aren't globally set.
lang
The language to use for automatic creation of briefs (short descriptions for each validation
step). By default, `None` will create English (`"en"`) text. Other options include French
Expand Down Expand Up @@ -1906,6 +1912,7 @@ class Validate:
label: str | None = None
thresholds: int | float | bool | tuple | dict | Thresholds | None = None
actions: Actions | None = None
brief: str | bool | None = None
lang: str | None = None
locale: str | None = None

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

# Transform any shorthands of `brief` to string representations
self.brief = _transform_auto_brief(brief=self.brief)

# TODO: Add functionality to obtain the column names and types from the table
self.col_names = None
self.col_types = None
Expand Down Expand Up @@ -2089,8 +2099,8 @@ def col_vals_gt(
if isinstance(columns, (Column, str)):
columns = [columns]

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

val_info = _ValidationInfo(
assertion_type=assertion_type,
Expand Down Expand Up @@ -4409,8 +4419,8 @@ def col_exists(
if isinstance(columns, (Column, str)):
columns = [columns]

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# TODO: incorporate Column object

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

val_info = _ValidationInfo(
assertion_type=assertion_type,
Expand Down Expand Up @@ -4741,8 +4751,8 @@ def col_schema_match(
"full_match_dtypes": full_match_dtypes,
}

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

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

# Transform any shorthands of `brief=` to string representations
brief = _transform_auto_brief(brief=brief)
# Determine brief to use (global or local) and transform any shorthands of `brief=`
brief = self.brief if brief is None else _transform_auto_brief(brief=brief)

val_info = _ValidationInfo(
assertion_type=assertion_type,
Expand Down
Loading