Skip to main content
Version: 1.0 prerelease

ExpectationSuite

class great_expectations.core.ExpectationSuite(name: Optional[str] = None, expectations: Optional[Sequence[Union[dict, ExpectationConfiguration, Expectation]]] = None, suite_parameters: Optional[dict] = None, execution_engine_type: Optional[Type[ExecutionEngine]] = None, meta: Optional[dict] = None, notes: str | list[str] | None = None, id: Optional[str] = None)#

Set-like collection of Expectations.

Parameters:
  • name – Name of the Expectation Suite

  • expectations – Expectation Configurations to associate with this Expectation Suite.

  • suite_parameters – Suite parameters to be substituted when evaluating Expectations.

  • execution_engine_type – Name of the execution engine type.

  • meta – Metadata related to the suite.

  • id – Great Expectations Cloud id for this Expectation Suite.

add_expectation(expectation: _TExpectation) _TExpectation#

Add an Expectation to the collection.

add_expectation_configuration(expectation_configuration: ExpectationConfiguration, match_type: str = 'domain', overwrite_existing: bool = True) ExpectationConfiguration#

Upsert specified ExpectationConfiguration into this ExpectationSuite.

Parameters:
  • expectation_configuration – The ExpectationConfiguration to add or update.

  • match_type – The criteria used to determine whether the Suite already has an ExpectationConfiguration and so whether we should add or replace.

  • overwrite_existing – If the expectation already exists, this will overwrite if True and raise an error if False.

Returns:

The ExpectationConfiguration to add or replace.

Raises:
  • ValueError – More than one match

  • DataContextError – One match if overwrite_existing = False

# noqa: DAR402

delete_expectation(expectation: Expectation) Expectation#

Delete an Expectation from the collection.

Raises:

KeyError – Expectation not found in suite.

find_expectations(expectation_configuration: Optional[ExpectationConfiguration] = None, match_type: str = 'domain', id: Optional[str] = None) List[ExpectationConfiguration]#

Find Expectations matching the given ExpectationConfiguration on the given match_type. If a id is provided, match_type is ignored and only Expectations with matching id are returned.

Parameters:
  • expectation_configuration – A potentially incomplete (partial) Expectation Configuration to match against to find the index of any matching Expectation Configurations on the suite.

  • match_type

    This determines what kwargs to use when matching. Options are ‘domain’ to match based on the data evaluated by that expectation, ‘success’ to match based on all configuration parameters

    that influence whether an expectation succeeds based on a given batch of data, and ‘runtime’ to match based on all configuration parameters

  • id – Great Expectations Cloud id

Returns: A list of matching ExpectationConfigurations

remove_expectation(expectation_configuration: Optional[ExpectationConfiguration] = None, match_type: str = 'domain', remove_multiple_matches: bool = False, id: Optional[Union[str, uuid.UUID]] = None) List[ExpectationConfiguration]#

Remove an ExpectationConfiguration from the ExpectationSuite.

Parameters:
  • expectation_configuration – A potentially incomplete (partial) Expectation Configuration to match against.

  • match_type – This determines what kwargs to use when matching. Options are ‘domain’ to match based on the data evaluated by that expectation, ‘success’ to match based on all configuration parameters that influence whether an expectation succeeds based on a given batch of data, and ‘runtime’ to match based on all configuration parameters.

  • remove_multiple_matches – If True, will remove multiple matching expectations.

  • id – Great Expectations Cloud id for an Expectation.

Returns:

The list of deleted ExpectationConfigurations.

Raises:
  • TypeError – Must provide either expectation_configuration or id.

  • ValueError – No match or multiple matches found (and remove_multiple_matches=False).

save() None#

Save this ExpectationSuite.

show_expectations_by_domain_type() None#

Displays “ExpectationConfiguration” list, grouped by “domain_type”, in predetermined designated order.

The means of displaying is through the use of the “Pretty Print” library method “pprint.pprint()”.

to_json_dict() Dict[str, JSONValues]#

Returns a JSON-serializable dict representation of this ExpectationSuite.

Returns:

A JSON-serializable dict representation of this ExpectationSuite.