Skip to main content

accept()

Execute the revised plan and return the resulting Validate object.

Usage

Source

accept(data=None)

The returned Validate has NOT been interrogated; call .interrogate() on it to run the validation. Before running the code, accept() applies the same check as validate_syntax() and raises a ValueError if it fails. It then runs the code with the table bound to your_data and returns the Validate object that the code assigns to validation (or the last Validate object it assigns). Any .interrogate() call in the revised code is removed first.

Warning

accept() runs the revised code with Python’s exec(). Read the code (with to_code() or review()) before accepting an edit, as you would any other code you didn’t write.

Parameters

data: Any = None
The data table to bind to the plan’s your_data placeholder. If omitted, the data= provided to EditValidation is used. One of the two must be present.

Returns

Validate
The revised validation plan as a Validate object.

Examples

import pointblank as pb

small_table = pb.load_dataset("small_table")

edit = pb.EditValidation.from_plans(
    pb.Validate(data=small_table).col_vals_gt(columns="d", value=100),
    (
        pb.Validate(data=small_table)
        .col_vals_gt(columns="d", value=50)
        .col_vals_not_null(columns="a")
    ),
)

validation = edit.accept(data=small_table).interrogate()

validation
STEP COLUMNS VALUES TBL EVAL UNITS PASS FAIL W E C EXT
#4CA64C 1
col_vals_gt
col_vals_gt()
d 50 ✓ 13 13
1.00
0
0.00
— — — —
#4CA64C 2
col_vals_not_null
col_vals_not_null()
a — ✓ 13 13
1.00
0
0.00
— — — —

The revised plan has both steps, and it ran against small_table because that’s the table passed to accept(). An EditValidation built by from_plans() has no data= of its own, so the table has to be given here. Passing a different table is also how to run the same revised plan on new data.