How to create a new Expectation Suite without the CLI

In some environments, you might not be able to use the CLI to create a new Expectation Suite. This guide shows how to create a new Expectation Suite and start adding Expectations using Python code, for example in a Jupyter notebook. Note: If you want to get started creating Expectations with the fewest possible dependencies, e.g. without configuring a Data Context, you should check out How to quickly explore Expectations in a notebook.

Prerequisites: This how-to guide assumes you have already:

This code is very similar to the boilerplate you see after creating an Expectation Suite using the CLI, with the only difference being that the Expectation Suite is created not loaded from the Data Context:

import great_expectations as ge

context = ge.data_context.DataContext()
suite = context.create_expectation_suite(
    "my_suite_name", overwrite_existing=True # Configure these parameters for your needs

This block just creates an empty Expectation Suite object. Next up, you want to create a Batch to start creating Expectations:

batch_kwargs = {
    "datasource": "my_datasource",
    "schema": "my_schema",
    "table": "my_table_name",
batch = context.get_batch(batch_kwargs, suite)

Note: The batch_kwargs depend on what type of data asset you want to connect to (a database table or view, Pandas datasource, etc.). See Creating Batches for your configuration. You can then start creating Expectations on your batch using the methods described in the Glossary of Expectations and eventually save the Suite to JSON:

# Start creating Expectations here


# And save the final state to JSON

This will create a JSON file with your Expectation Suite in the Store you have configured, which you can then load and use for Validation.