great_expectations.core.expectation_configuration

Module Contents

Classes

ExpectationContext(description: Optional[str] = None)

A convenience class for migrating away from untyped dictionaries to stronger typed objects.

ExpectationContextSchema(*, 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.

ExpectationConfiguration(expectation_type: str, kwargs: dict, meta: Optional[dict] = None, success_on_last_run: Optional[bool] = None, ge_cloud_id: Optional[str] = None, expectation_context: Optional[ExpectationContext] = None)

ExpectationConfiguration defines the parameters and name of a specific expectation.

ExpectationConfigurationSchema(*, 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.

Functions

parse_result_format(result_format: Union[str, dict])

This is a simple helper utility that can be used to parse a string result_format into the dict format used

great_expectations.core.expectation_configuration.logger
great_expectations.core.expectation_configuration.parse_result_format(result_format: Union[str, dict]) → dict

This is a simple helper utility that can be used to parse a string result_format into the dict format used internally by great_expectations. It is not necessary but allows shorthand for result_format in cases where there is no need to specify a custom partial_unexpected_count.

class great_expectations.core.expectation_configuration.ExpectationContext(description: Optional[str] = None)

Bases: great_expectations.types.SerializableDictDot

A convenience class for migrating away from untyped dictionaries to stronger typed objects.

Can be instantiated with arguments:

my_A = MyClassA(

foo=”a string”, bar=1,

)

Can be instantiated from a dictionary:

my_A = MyClassA(
**{

“foo”: “a string”, “bar”: 1,

}

)

Can be accessed using both dictionary and dot notation

my_A.foo == “a string” my_A.bar == 1

my_A[“foo”] == “a string” my_A[“bar”] == 1

Pairs nicely with @dataclass:

@dataclass() class MyClassA(DictDot):

foo: str bar: int

Can be made immutable:

@dataclass(frozen=True) class MyClassA(DictDot):

foo: str bar: int

For more examples of usage, please see test_dataclass_serializable_dot_dict_pattern.py in the tests folder.

property description(self)
class great_expectations.core.expectation_configuration.ExpectationContextSchema(*, 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.

description
make_expectation_context(self, data, **kwargs)
class great_expectations.core.expectation_configuration.ExpectationConfiguration(expectation_type: str, kwargs: dict, meta: Optional[dict] = None, success_on_last_run: Optional[bool] = None, ge_cloud_id: Optional[str] = None, expectation_context: Optional[ExpectationContext] = None)

Bases: great_expectations.types.SerializableDictDot

ExpectationConfiguration defines the parameters and name of a specific expectation.

kwarg_lookup_dict
runtime_kwargs = ['result_format', 'include_config', 'catch_exceptions']
process_evaluation_parameters(self, evaluation_parameters, interactive_evaluation: bool = True, data_context: Optional[Any] = None)
get_raw_configuration(self)
patch(self, op: str, path: str, value: Any)
Parameters
  • op – A jsonpatch operation. One of ‘add’, ‘replace’, or ‘remove’

  • path – A jsonpatch path for the patch operation

  • value – The value to patch

Returns

The patched ExpectationConfiguration object

property ge_cloud_id(self)
property expectation_context(self)
property expectation_type(self)
property kwargs(self)
_get_default_custom_kwargs(self)
get_domain_kwargs(self)
get_success_kwargs(self)
get_runtime_kwargs(self, runtime_configuration: Optional[dict] = None)
applies_to_same_domain(self, other_expectation_configuration: ExpectationConfiguration)
isEquivalentTo(self, other: Union[dict, 'ExpectationConfiguration'], match_type: str = 'success')

ExpectationConfiguration equivalence does not include meta, and relies on equivalence of kwargs.

__eq__(self, other)

ExpectationConfiguration equality does include meta, but ignores instance identity.

__ne__(self, other)

Return self!=value.

__repr__(self)

Return repr(self).

__str__(self)

Return str(self).

to_json_dict(self)

# TODO: <Alex>2/4/2022</Alex> A reference implementation can be provided, once circular import dependencies, caused by relative locations of the “great_expectations/types/__init__.py” and “great_expectations/core/util.py” modules are resolved.

get_evaluation_parameter_dependencies(self)
_update_dependencies_with_expectation_suite_urn(self, dependencies: dict, urn: ParseResults)
_get_expectation_impl(self)
validate(self, validator: Any, runtime_configuration=None)
metrics_validate(self, metrics: Dict, runtime_configuration: dict = None, execution_engine=None)
class great_expectations.core.expectation_configuration.ExpectationConfigurationSchema(*, 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_type
kwargs
meta
ge_cloud_id
expectation_context
REMOVE_KEYS_IF_NONE = ['ge_cloud_id', 'expectation_context']
clean_null_attrs(self, data: dict, **kwargs)
make_expectation_configuration(self, data: dict, **kwargs)
great_expectations.core.expectation_configuration.expectationConfigurationSchema
great_expectations.core.expectation_configuration.expectationContextSchema