How to update Data Docs as a Validation Action
This guide will explain how to use a Validation Action to update Data Docs sites with new Validation Results from Validation Operator runs.
Prerequisites: This how-to guide assumes you have:
- Completed the Getting Started Tutorial
- Have a working installation of Great Expectations
- Learned How to add a Validation Operator
- Set up a
.pyclass:great_expectations.validation_operators.validation_operators.ActionListValidationOperatoror - Set up a
.pyclass:great_expectations.validation_operators.validation_operators.WarningAndFailureExpectationSuitesValidationOperator - Created at least one Expectation Suite.
- Created at least one Checkpoint. You will need it in order to test that your new Validation Operator is working.
Steps#
Update the action_list key in your Validation Operator config.
Add the
UpdateDataDocsActionaction to theaction_listkey of theActionListValidationOperatororWarningAndFailureExpectationSuitesValidationOperatorconfig in yourgreat_expectations.yml. This action will update all configured Data Docs sites with the new validation from the Validation Operator run.Note:
The
StoreValidationResultActionaction must appear before this action, since Data Docs are rendered from Validation Results from the store.validation_operators: action_list_operator: # this is a user-selected name class_name: ActionListValidationOperator action_list: - name: store_validation_result # this is a user-selected name action: class_name: StoreValidationResultAction - name: update_data_docs # this is a user-selected name action: class_name: UpdateDataDocsActionIf you only want to update certain configured Data Docs sites:
- Add a
site_nameskey to theUpdateDataDocsActionconfig.
validation_operators: action_list_operator: # this is a user-selected name class_name: ActionListValidationOperator action_list: - name: store_validation_result # this is a user-selected name action: class_name: StoreValidationResultAction - name: update_data_docs # this is a user-selected name action: class_name: UpdateDataDocsAction site_names: - team_site- Add a
Test your configuration.
Test that your new Validation Operator Action is configured correctly:
- Open the configuration file of a Checkpoint you created earlier and replace the value of
validation_operator_namewith the name of the Validation Operator you added theUpdateDataDocsaction to. The details of Checkpoint configuration can be found in this How to add validations data or suites to a Checkpoint. - Run the Checkpoint and verify that no errors are thrown. You can run the Checkpoint from the CLI as explained in How to run a Checkpoint in terminal or from Python, as explained in How to run a Checkpoint in Python.
- Check your configured Data Docs sites to confirm that a new Validation Result has been added.
- Open the configuration file of a Checkpoint you created earlier and replace the value of
Additional notes#
The UpdateDataDocsAction generates an HTML file for the latest Validation Result and updates the index page to link to the new file, and re-renders pages for the suite used for that validation. It does not perform a full rebuild of Data Docs sites. This means that if you wish to render older Validation Results, you should run full Data Docs rebuild (via CLI's great_expectations docs build command or by calling context.build_data_docs()).