Skip to main content
Version: 1.2.1

Run a Checkpoint

Running a Checkpoint will cause it to validate all of its Validation Definitions. It will then execute its Actions based on the results returned from those Validation Definitions. Finally, the Validation Results will be returned by the Checkpoint.

At runtime, a Checkpoint can take in a batch_parameters dictionary that selects the Batch to validate from each Validation Definition. A Checkpoint will also accept an expectation_parameters dictionary that provides values for the parameters of the any Expectations that have been configured to accept parameters at runtime.

Prerequisites

Procedure

In this procedure your Data Context is assumed to be stored in the variable context and your Checkpoint is assumed to be stored in the variable checkpoint.

  1. Optional. Define Batch parameters.

    Batch parameters are used to specify a Batch of data for retrieval from a Batch Definition. Batch parameters are provided as a dictionary to the batch_parameters argument of a Checkpoint's run(...) method.

    The Batch parameters accepted by a Validation Definition are determined by its Batch Definition.

    Batch parameters apply to every Validation Definition in the Checkpoint. Therefore, the Validation Definitions grouped in a Checkpoint should have Batch Definitions that accept the same Batch filtering criteria.

    For more information and examples of how to configure a Batch Definition to accept Batch Parameters and how to format a batch_parameters dictionary, see Connect to data using SQL: Create a Batch Definition.

    If Batch parameters are not set, each Validation Definition will run on the default Batch determined by its Batch Definition.

  2. Optional. Define Expectation Parameters.

    To pass parameters to Expectations at runtime the Expectation must be configured to find parameter values through a dictionary lookup. This is done when the Expectation is created.

    You then pass a dictionary to the expectation_parameters argument of a Checkpoint's run method. The contents of this dictionary consist of keys that were defined for parameters when the Checkpoint's Expectations were created, paired with the values that should be used for the corresponding parmeters when the Checkpoint runs.

    Below is an example of an ExpectColumnMaxToBeBetween Expectation that is set to accept parameters at runtime:

    Python
    gx.expectations.ExpectColumnMaxToBeBetween(
    column="fare",
    min_value={"$PARAMETER": "expect_fare_max_to_be_above"},
    max_value={"$PARAMETER": "expect_fare_max_to_be_below"},
    )

    And this is an expectation_parameters dictionary that provides those parameters:

    Python
    expectation_parameters = {
    "expect_fare_max_to_be_above": 5.00,
    "expect_fare_max_to_be_below": 1000.00,
    }

    If none of the Expectations in a Validation Definition are configured to accept runtime Expectation parameters, the expectation_parameters argument can be omitted from the Checkpoint's run(...) method.

    For more information on configuring an Expectation to accept runtime parameters, how to set the lookup key for an Expectation's parameters, and additional examples of how to format an expectation_parameters dictionary see the runtime guidance under Create an Expectation.

  3. Run the Checkpoint.

    A Checkpoint is executed through its run(...) method. Pass the Batch and Expectation parameters to the batch_parameters and expectation_parameters arguments of the Checkpoint's run(...) method:

    Python
    validation_results = checkpoint.run(
    batch_parameters=batch_parameters, expectation_parameters=expectation_parameters
    )

    After the Checkpoint runs it will pass the Validation Results that are generated to its Actions and execute them. Finally, the Validation Results will be returned by the run(...) method.