great_expectations.core.expectation_suite

Module Contents

Classes

ExpectationSuite(expectation_suite_name, expectations=None, evaluation_parameters=None, data_asset_type=None, execution_engine_type=None, meta=None)

This ExpectationSuite object has create, read, update, and delete functionality for its expectations:

ExpectationSuiteSchema(*, only: types.StrSequenceOrSet = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: typing.Dict = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: typing.Union[bool, types.StrSequenceOrSet] = False, unknown: str = None)

Base schema class with which to define custom schemas.

great_expectations.core.expectation_suite.logger
class great_expectations.core.expectation_suite.ExpectationSuite(expectation_suite_name, expectations=None, evaluation_parameters=None, data_asset_type=None, execution_engine_type=None, meta=None)

Bases: great_expectations.types.SerializableDictDot

This ExpectationSuite object has create, read, update, and delete functionality for its expectations: -create: self.add_expectation() -read: self.find_expectation_indexes() -update: self.add_expectation() or self.patch_expectation() -delete: self.remove_expectation()

add_citation(self, comment: str, batch_request: Optional[Union[str, Dict[str, Union[str, Dict[str, Any]]]]] = None, batch_definition: Optional[dict] = None, batch_spec: Optional[dict] = None, batch_kwargs: Optional[dict] = None, batch_markers: Optional[dict] = None, batch_parameters: Optional[dict] = None, citation_date: Optional[Union[str, datetime.datetime]] = None)
isEquivalentTo(self, other)

ExpectationSuite equivalence relies only on expectations and evaluation parameters. It does not include: - data_asset_name - expectation_suite_name - meta - data_asset_type

__eq__(self, other)

ExpectationSuite equality ignores instance identity, relying only on properties.

__ne__(self, other)

Return self!=value.

__repr__(self)

Return repr(self).

__str__(self)

Return str(self).

to_json_dict(self)
get_evaluation_parameter_dependencies(self)
get_citations(self, sort: Optional[bool] = True, require_batch_kwargs: Optional[bool] = False, require_batch_request: Optional[bool] = False)
get_table_expectations(self)

Return a list of table expectations.

get_column_expectations(self)

Return a list of column map expectations.

static _filter_citations(citations: List[Dict[str, Any]], filter_key)
static _sort_citations(citations: List[Dict[str, Any]])
append_expectation(self, expectation_config)

Appends an expectation.

Parameters

expectation_config (ExpectationConfiguration) – The expectation to be added to the list.

Notes

May want to add type-checking in the future.

remove_expectation(self, expectation_configuration: ExpectationConfiguration, match_type: str = 'domain', remove_multiple_matches: bool = False)
Parameters
  • expectation_configuration – A potentially incomplete (partial) Expectation Configuration to match against for for the removal of expectations.

  • 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. If False, will raise a ValueError.

Returns: The list of deleted ExpectationConfigurations

Raises
  • No match

  • More than 1 match, if remove_multiple_matches = False

remove_all_expectations_of_type(self, expectation_types: Union[List[str], str])
find_expectation_indexes(self, expectation_configuration: ExpectationConfiguration, match_type: str = 'domain')
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

Returns: A list of indexes of matching ExpectationConfiguration

Raises

InvalidExpectationConfigurationError

find_expectations(self, expectation_configuration: ExpectationConfiguration, match_type: str = 'domain')
patch_expectation(self, expectation_configuration: ExpectationConfiguration, op: str, path: str, value: Any, match_type: str)
Parameters
  • expectation_configuration – A potentially incomplete (partial) Expectation Configuration to match against to find the expectation to patch.

  • op – A jsonpatch operation (one of ‘add’,’update’, or ‘remove’) (see http://jsonpatch.com/)

  • path – A jsonpatch path for the patch operation (see http://jsonpatch.com/)

  • value – The value to patch (see http://jsonpatch.com/)

  • match_type – The match type to use for find_expectation_index()

Returns: The patched ExpectationConfiguration

Raises
  • No match

  • More than 1 match

add_expectation(self, expectation_configuration: ExpectationConfiguration, match_type: str = 'domain', overwrite_existing: bool = True)
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
  • More than one match

  • One match if overwrite_existing = False

class great_expectations.core.expectation_suite.ExpectationSuiteSchema(*, only: types.StrSequenceOrSet = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: typing.Dict = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: typing.Union[bool, types.StrSequenceOrSet] = False, unknown: str = None)

Bases: great_expectations.marshmallow__shade.Schema

Base schema class with which to define custom schemas.

Example usage:

import datetime as dt
from dataclasses import dataclass

from great_expectations.marshmallow__shade import Schema, fields


@dataclass
class Album:
    title: str
    release_date: dt.date


class AlbumSchema(Schema):
    title = fields.Str()
    release_date = fields.Date()


album = Album("Beggars Banquet", dt.date(1968, 12, 6))
schema = AlbumSchema()
data = schema.dump(album)
data  # {'release_date': '1968-12-06', 'title': 'Beggars Banquet'}
Parameters
  • only – Whitelist of the declared fields to select when instantiating the Schema. If None, all fields are used. Nested fields can be represented with dot delimiters.

  • exclude – Blacklist of the declared fields to exclude when instantiating the Schema. If a field appears in both only and exclude, it is not used. Nested fields can be represented with dot delimiters.

  • many – Should be set to True if obj is a collection so that the object will be serialized to a list.

  • context – Optional context passed to fields.Method and fields.Function fields.

  • load_only – Fields to skip during serialization (write-only fields)

  • dump_only – Fields to skip during deserialization (read-only fields)

  • partial – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

Changed in version 3.0.0: prefix parameter removed.

Changed in version 2.0.0: __validators__, __preprocessors__, and __data_handlers__ are removed in favor of marshmallow.decorators.validates_schema, marshmallow.decorators.pre_load and marshmallow.decorators.post_dump. __accessor__ and __error_handler__ are deprecated. Implement the handle_error and get_attribute methods instead.

expectation_suite_name
expectations
evaluation_parameters
data_asset_type
meta
clean_empty(self, data)
prepare_dump(self, data, **kwargs)
make_expectation_suite(self, data, **kwargs)
great_expectations.core.expectation_suite.expectationSuiteSchema