def create_empty_suite(context: DataContext, expectation_suite_name: str, batch_kwargs) -> None: cli_message(""" Great Expectations will create a new Expectation Suite '{:s}' and store it here: {:s} """.format( expectation_suite_name, context.stores[ context.expectations_store_name].store_backend.get_url_for_key( ExpectationSuiteIdentifier( expectation_suite_name=expectation_suite_name).to_tuple()), )) suite = context.create_expectation_suite(expectation_suite_name) suite.add_citation(comment="New suite added via CLI", batch_kwargs=batch_kwargs) context.save_expectation_suite(suite, expectation_suite_name)
def load_expectation_suite( data_context: DataContext, expectation_suite_name: str, usage_event: str, suppress_usage_message: Optional[bool] = False, create_if_not_exist: Optional[bool] = True, ) -> Optional[ExpectationSuite]: """ Load an expectation suite from a given context. Handles a suite name with or without `.json` :param data_context: :param expectation_suite_name: :param usage_event: :param suppress_usage_message: :param create_if_not_exist: """ if expectation_suite_name.endswith(".json"): expectation_suite_name = expectation_suite_name[:-5] suite: Optional[ExpectationSuite] try: suite = data_context.get_expectation_suite( expectation_suite_name=expectation_suite_name ) return suite except ge_exceptions.DataContextError: if create_if_not_exist: suite = data_context.create_expectation_suite( expectation_suite_name=expectation_suite_name ) return suite else: suite = None exit_with_failure_message_and_stats( data_context=data_context, usage_event=usage_event, suppress_usage_message=suppress_usage_message, message=f"<red>Could not find a suite named `{expectation_suite_name}`.</red> Please check " "the name by running `great_expectations suite list` and try again.", ) return suite