'ExpectationSuite' object has no attribute 'add_expectation_configuration'

What am I doing wrong?

import great_expectations as gx
from great_expectations.core.expectation_configuration import ExpectationConfiguration

context = gx.get_context()

suite = context.add_expectation_suite(expectation_suite_name="my_suite")

config1=ExpectationConfiguration(
    expectation_type="expect_table_row_count_to_be_between",
    kwargs={
        "min_value":0,
        "max_value":100,
    },
)

suite.add_expectation_configuration(expectation_configuration=config1)

Error:

AttributeError: 'ExpectationSuite' object has no attribute 'add_expectation_configuration'

I belive I’ve followed the instructions here pretty closely.

Update: The code below seems to work.

suite.expectations.append(config1)

Perhaps the documentation needs updating?

The code should be

suite.add_expectation()

All the code blocks seem to use the wrong function but the actual text in some docs talk about the above command.

1 Like

@nevintan have seen this as well – are docs out of date with api?

Just to note, suite.add_expectation() and suite.expectations.append() sometimes behave differently when adding the same expectation type more than once. suite.add_expectation() will attempt to de-dupe, replacing existing expectations, whereas suite.expectations.append() simply appends.

Examples here:

Hi all! Thank you for flagging this. I’ll notify our docs team to make sure everything is correct and up to date on our side.

2 Likes