I’m currently working on a POC for the GX OSS. I want to have the following behavior. After reading the file yellow_tripdata_sample_2019-01.csv
, I create an expectation to inspect that file. After that, I hope to be able to view the report as html.
But when I write the code below and run it, I get a result of 0. The result I expect is failure. I guess the suite is not applied, but I don’t know how to apply it.
from great_expectations.core.expectation_configuration import (
ExpectationConfiguration,
)
import great_expectations as gx
context = gx.get_context()
validator = context.sources.pandas_default.read_csv(
"./yellow_tripdata_sample_2019-01.csv"
)
suite = context.add_or_update_expectation_suite(expectation_suite_name="checkpoint1")
expectation_configuration = ExpectationConfiguration(
# Name of expectation type being added
expectation_type="expect_table_columns_to_match_ordered_list",
# These are the arguments of the expectation
# The keys allowed in the dictionary are Parameters and
# Keyword Arguments of this Expectation Type
kwargs={
"column_list": [
"account_id",
"user_id",
"transaction_id",
"transaction_type",
"transaction_amt_usd",
]
},
# This is how you can optionally add a comment about this expectation.
# It will be rendered in Data Docs.
# See this guide for details:
# `How to add comments to Expectations and display them in Data Docs`.
meta={
"notes": {
"format": "markdown",
"content": "Some clever comment about this expectation. **Markdown** `Supported`",
}
},
)
suite.add_expectation(expectation_configuration=expectation_configuration)
context.save_expectation_suite(expectation_suite=suite)
context.run_checkpoint(checkpoint_name="checkpoint1", validator=validator)