Skip to main content
Version: 1.0 prerelease

Manage Checkpoints

You can use Checkpoints to group Validation Definitions and run them with shared parameters and automated Actions.

At runtime, a Checkpoint can take in dictionaries that filter the Batches in each Validation Definition and modify the parameters of the Expectations that will be validated against them. The 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. In addition, the Expectation Suites in each Validation Definition should also share a list of valid parameters.

After a Checkpoint receives Validation Results from a Validation Definition, it executes a list of Actions. The returned Validation Results determine what task is performed for each Action. Actions can include updating Data Docs with the new Validation Results or sending alerts when validations fail. The Actions list is executed once for each Validation Definition in a Checkpoint.

If the list of Actions for a Checkpoint is empty, the Checkpoint can still run. Its validation results are saved to the Data Context, but no tasks are executed.

Create a Checkpoint

  1. Import the GX library and the Checkpoint class:
Python
import great_expectations as gx
from great_expectations.core import Checkpoint
  1. Request a Data Context.

In this example the variable context is your Data Context.

  1. Get the Validation Definition or Definitions to add to the Checkpoint.

In this example the variable validation_definitions is a list object containing a single Validation Definition.

  1. Optional. Determine the Actions to add to the Checkpoint.

In this example, the variable actions is a list of two actions. The first updates your Data Docs with the results of the Validation Definition. The second sends a Slack notification if any of the Expectations in the Validation Definition failed:

Python
actions = [gx.UpdateDataDocs(...), gx.SlackNotification(...)]
tip

A list of available Actions is available with the Checkpoint class in the GX API documentation.

  1. Create the Checkpoint:
Python
checkpoint_name = "my_checkpoint"

checkpoint = Checkpoint(
name=checkpoint_name, validations=validation_definitions, actions=actions
)
  1. Add the Checkpoint to the Data Context:
Python
context.checkpoints.add(checkpoint)

List available Checkpoints

  1. Request a Data Context.

In this example the variable context is your Data Context.

  1. Use the Data Context to retrieve and print the names of the available Checkpoints:
Python
checkpoint_names = [checkpoint.name for checkpoint in context.checkpoints]
print(checkpoint_names)

Get a Checkpoint by name

  1. Request a Data Context.

In this example the variable context is your Data Context.

  1. Use the Data Context to request the Checkpoint:
Python
checkpoint_name = "my_checkpoint"
checkpoint = context.checkpoints.get(name=checkpoint_name)

Get Checkpoints by attributes

  1. Request a Data Context.

In this example the variable context is your Data Context.

  1. Determine the filter attributes.

Checkpoints associate a list of one or more Validation Definitions with a list of Actions to perform. The attributes used to filter the results include the attributes for the Validation Definitions, their Batch Definitions and Expectation Suites, and the Checkpoint Actions.

  1. Use a list comprehension to return all Checkpoints that match the filtered attributes.

For example, you can retrieve all Checkpoints that send alerts through Slack by filtering on the Actions of each Checkpoint:

Python
checkpoints_with_slack_alerts = [
checkpoint.name
for checkpoint in context.checkpoints
if any(isinstance(action, SlackNotificationAction) for action in checkpoint.actions)
]

print(checkpoints_with_slack_alerts)

Update a Checkpoint

  1. Request a Data Context.

In this example the variable context is your Data Context.

  1. Get the Checkpoint to update.

In this example the variable checkpoint is the Checkpoint that is updated.

  1. Overwrite the Checkpoint values with updated lists.

In this example, the Checkpoint Validation Definitions and Actions receive updates:

Python
new_validations_list = [context.validation_definitions.get(name="new_validation")]
new_actions_list = [gx.UpdateDataDocs(...)]

checkpoint.validations = new_validations_list
checkpoint.actions = new_actions_list
  1. Save the changes to the Data Context:
Python
checkpoint.save()

Delete a Checkpoint

  1. Request a Data Context.

In this example the variable context is your Data Context.

  1. Use the Data Context to delete the Checkpoint:
Python
checkpoint_name = "my_checkpoint"
context.checkpoints.delete(name=checkpoint_name)

Run a Checkpoint

🚧 Under construction 🚧

Updates for this page are in progress.