Skip to main content
Version: 1.0 prerelease

ExpectationSuite

class great_expectations.ExpectationSuite(name: Optional[str] = None, expectations: Optional[Sequence[Union[dict, ExpectationConfiguration, Expectation]]] = None, suite_parameters: Optional[dict] = 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.

  • 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.

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.

to_json_dict() Dict[str, JSONValues]#

Returns a JSON-serializable dict representation of this ExpectationSuite.

Returns:

A JSON-serializable dict representation of this ExpectationSuite.