How to load a greatexpectations test suite from a JSON file and run the test

38 Views Asked by At

I am trying to declare a test suite in JSON for greatexpectations. Then I try to load that suite declaration and run it against any data frame.

def run_ge_test_suite(df, validation_suite_json):
        # Load the test suite from JSON
        context = ge.get_context()
        suite = context.get_expectation_suite(validation_suite_json)

        # Create a checkpoint using a unique name
        checkpoint_name = "checkpoint"
        context.create_expectation_suite_checkpoint(
            checkpoint_name=checkpoint_name, suite_name=suite.name
        )

        # Validate the DataFrame
        validation_result = suite.validate(df=df)

  # Print validation results
  for result in results:
    print(result)

So how to pass the test definition and add to the context?

0

There are 0 best solutions below